NVIDIA/warp
GitHub: NVIDIA/warp
一个将 Python 函数 JIT 编译为 CPU/GPU 高效内核的框架,专为空间计算、物理仿真和可微分编程设计。
Stars: 6380 | Forks: 464
[](https://badge.fury.io/py/warp-lang)
[](https://opensource.org/licenses/Apache-2.0)

[](https://pepy.tech/project/warp-lang)
[](https://codecov.io/github/NVIDIA/warp)

# NVIDIA Warp
**[文档](https://nvidia.github.io/warp/)** | [更新日志](https://github.com/NVIDIA/warp/blob/main/CHANGELOG.md)
Warp 是一个用于编写高性能仿真和图形代码的 Python 框架。Warp 将常规 Python 函数进行 JIT 编译,生成可在 CPU 或 GPU 上运行的高效内核代码。
Warp 专为 [空间计算](https://en.wikipedia.org/wiki/Spatial_computing) 而设计,并提供了一套丰富的原语,使得编写物理仿真、感知、机器人和几何处理程序变得十分容易。此外,Warp 内核是可微的,可以作为 PyTorch、JAX 和 Paddle 等框架的机器学习流水线的一部分使用。
## 安装
需要 Python 3.9 或更高版本。Warp 可在 Windows 和 Linux 上的 x86-64 和 ARMv8 CPU 上运行,以及在 macOS 上的 Apple Silicon (ARMv8) 上运行。
GPU 支持需要支持 CUDA 的 NVIDIA GPU 和驱动程序(最低要求 GeForce GTX 9xx)。
安装 Warp 最简单的方法是从 [PyPI](https://pypi.org/project/warp-lang/) 安装:
```
pip install warp-lang
```
您也可以使用 `pip install warp-lang[examples]` 来安装运行示例和 USD 相关功能所需的额外依赖项。
有关每夜构建、conda、CUDA 13 构建、从源代码构建以及 CUDA 驱动程序要求,请参阅 [安装指南](https://nvidia.github.io/warp/user_guide/installation.html)。
## 教程 Notebooks
[NVIDIA Accelerated Computing Hub](https://github.com/NVIDIA/accelerated-computing-hub) 包含当前积极维护的 Warp 教程集:
| Notebook | Colab 链接 |
|----------|------------|
| [NVIDIA Warp 简介](https://github.com/NVIDIA/accelerated-computing-hub/blob/32fe3d5a448446fd52c14a6726e1b867cbfed2d9/Accelerated_Python_User_Guide/notebooks/Chapter_12_Intro_to_NVIDIA_Warp.ipynb) | [](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/32fe3d5a448446fd52c14a6726e1b867cbfed2d9/Accelerated_Python_User_Guide/notebooks/Chapter_12_Intro_to_NVIDIA_Warp.ipynb) |
| [NVIDIA Warp 中的 GPU 加速 Ising 模型仿真](https://github.com/NVIDIA/accelerated-computing-hub/blob/32fe3d5a448446fd52c14a6726e1b867cbfed2d9/Accelerated_Python_User_Guide/notebooks/Chapter_12.1_IsingModel_In_Warp.ipynb) | [](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/32fe3d5a448446fd52c14a6726e1b867cbfed2d9/Accelerated_Python_User_Guide/notebooks/Chapter_12.1_IsingModel_In_Warp.ipynb) |
此外,[notebooks](https://github.com/NVIDIA/warp/tree/main/notebooks) 目录中的几个 notebook 提供了额外的示例并涵盖了 Warp 的关键功能:
| Notebook | Colab 链接 |
|----------|------------|
| [Warp 核心教程:基础](https://github.com/NVIDIA/warp/blob/main/notebooks/core_01_basics.ipynb) | [](https://colab.research.google.com/github/NVIDIA/warp/blob/main/notebooks/core_01_basics.ipynb) |
| [Warp 核心教程:泛型](https://github.com/NVIDIA/warp/blob/main/notebooks/core_02_generics.ipynb) | [](https://colab.research.google.com/github/NVIDIA/warp/blob/main/notebooks/core_02_generics.ipynb) |
| [Warp 核心教程:点](https://github.com/NVIDIA/warp/blob/main/notebooks/core_03_points.ipynb) | [](https://colab.research.google.com/github/NVIDIA/warp/blob/main/notebooks/core_03_points.ipynb) |
| [Warp 核心教程:网格](https://github.com/NVIDIA/warp/blob/main/notebooks/core_04_meshes.ipynb) | [](https://colab.research.google.com/github/NVIDIA/warp/blob/main/notebooks/core_04_meshes.ipynb) |
| [Warp 核心教程:体积](https://github.com/NVIDIA/warp/blob/main/notebooks/core_05_volumes.ipynb) | [](https://colab.research.google.com/github/NVIDIA/warp/blob/main/notebooks/core_05_volumes.ipynb) |
| [Warp PyTorch 教程:基础](https://github.com/NVIDIA/warp/blob/main/notebooks/pytorch_01_basics.ipynb) | [](https://colab.research.google.com/github/NVIDIA/warp/blob/main/notebooks/pytorch_01_basics.ipynb) |
| [Warp PyTorch 教程:自定义算子](https://github.com/NVIDIA/warp/blob/main/notebooks/pytorch_02_custom_operators.ipynb) | [](https://colab.research.google.com/github/NVIDIA/warp/blob/main/notebooks/pytorch_02_custom_operators.ipynb) |
## 运行示例
[warp/examples](https://github.com/NVIDIA/warp/tree/main/warp/examples) 目录包含许多脚本,这些脚本分类在子目录下,展示了如何使用 Warp API 实现各种仿真方法。
大多数示例会在当前工作目录中生成包含时间采样动画的 USD 文件。
在运行示例之前,请使用以下命令安装可选的示例依赖项:
```
pip install warp-lang[examples]
```
在 Linux aarch64 系统(例如 NVIDIA DGX Spark)上,`[examples]` 额外依赖项会自动安装 [`usd-exchange`](https://pypi.org/project/usd-exchange/) 来代替 `usd-core` 作为直接替代品,因为该平台没有 `usd-core` 的 wheel 包。
可以按如下方式从命令行运行示例:
```
python -m warp.examples..
```
要浏览示例源代码,您可以像这样打开文件所在的目录:
```
python -m warp.examples.browse
```
大多数示例可以在 CPU 或支持 CUDA 的设备上运行,但也有少数需要支持 CUDA 的设备。这些都在示例脚本的顶部进行了标记。
USD 文件可以在 [NVIDIA Omniverse](https://developer.nvidia.com/omniverse)、Pixar 的 UsdView 和 Blender 中查看或渲染。请注意,不建议使用 macOS 中的“预览”应用,因为它对时间采样动画的支持有限。
内置单元测试可以按如下方式从命令行运行:
```
python -m warp.tests
```
### warp/examples/core
### warp/examples/fem
### warp/examples/tile
## 了解更多
请参阅以下资源以了解有关 Warp 的更多背景信息:
* [产品页面](https://developer.nvidia.com/warp-python)
* [SIGGRAPH 2024 课程幻灯片](https://dl.acm.org/doi/10.1145/3664475.3664543)
* [GTC 2024 演示](https://www.nvidia.com/en-us/on-demand/session/gtc24-s63345/)
* [GTC 2022 演示](https://www.nvidia.com/en-us/on-demand/session/gtcspring22-s41599)
* [GTC 2021 演示](https://www.nvidia.com/en-us/on-demand/session/gtcspring21-s31838)
* [SIGGRAPH Asia 2021 可微仿真课程](https://dl.acm.org/doi/abs/10.1145/3476117.3483433)
## 支持
请参阅 [常见问题解答 (FAQ)](https://nvidia.github.io/warp/user_guide/faq.html) 了解常见问题。
有关问题、疑问和功能请求,请在 [GitHub Issues](https://github.com/NVIDIA/warp/issues) 上提出。
对于不适合在 GitHub Issues 上提出的咨询,请发送电子邮件至 。
## 贡献
欢迎社区提供贡献和 Pull Requests。
有关为 Warp 开发做贡献的更多信息,请参阅 [贡献指南](https://nvidia.github.io/warp/user_guide/contribution_guide.html)。
## 许可证
Warp 是在 Apache License, Version 2.0 下提供的。
有关完整的许可证文本,请参阅 [LICENSE.md](https://github.com/NVIDIA/warp/blob/main/LICENSE.md)。
本项目将下载并安装额外的第三方开源软件项目。
使用前请查看这些开源项目的许可条款。
## 出版物与引用
### 使用 Warp 的研究
我们的 [PUBLICATIONS.md](https://github.com/NVIDIA/warp/blob/main/PUBLICATIONS.md) 文件列出了利用 Warp 能力的学术和研究出版物。
我们鼓励您将使用 Warp 发表的作品添加到此列表中。
### 引用 Warp
如果您在研究中使用 Warp,请使用 [GitHub repository](https://github.com/NVIDIA/warp) 页面上的“Cite this repository”按钮,或参考 [CITATION.cff](https://github.com/NVIDIA/warp/blob/main/CITATION.cff) 文件获取引用信息。
A selection of physical simulations computed with Warp
![]() |
![]() |
![]() |
![]() |
| dem | fluid | graph capture | marching cubes |
![]() |
![]() |
![]() |
![]() |
| mesh | nvdb | raycast | raymarch |
![]() |
![]() |
![]() |
![]() |
| sample mesh | sph | torch | wave |
![]() |
|||
| 2-D incompressible turbulence in a periodic box |
![]() |
![]() |
![]() |
![]() |
| diffray | fluid checkpoint | particle repulsion | navier-stokes perturbation |
![]() |
![]() |
![]() |
|
| mlp | nbody | mcgp |
标签:Apex, CUDA, JAX, JIT编译, Python框架, PyTorch, Vectored Exception Handling, 几何处理, 凭据扫描, 可微分编程, 感知, 数字孪生, 数据生成, 机器人, 机器学习, 物理仿真, 科学计算, 空间计算, 自动驾驶, 计算机图形学, 逆向工具, 高性能计算































