A Python framework for high-performance simulation and graphics programming
Project description
NVIDIA Warp
Warp is a Python framework for writing high-performance simulation and graphics code. Warp takes regular Python functions and JIT compiles them to efficient kernel code that can run on the CPU or GPU.
Warp is designed for spatial computing and comes with a rich set of primitives that make it easy to write programs for physics simulation, perception, robotics, and geometry processing. In addition, Warp kernels are differentiable and can be used as part of machine-learning pipelines with frameworks such as PyTorch and JAX.
Please refer to the project Documentation for API and language reference and CHANGELOG.md for release history.
A selection of physical simulations computed with Warp
Installing
Python version 3.9 or newer is recommended. Warp can run on x86-64 and ARMv8 CPUs on Windows, Linux, and macOS. GPU support requires a CUDA capable NVIDIA GPU and driver (minimum GeForce GTX 9xx).
The easiest way to install Warp is from PyPI:
pip install warp-lang
Pre-built binary packages are also available on the Releases page. To install in your local Python environment run the following command from the download directory:
pip install warp_lang-<version and platform>.whl
Getting Started
An example first program that computes the lengths of random 3D vectors is given below:
import warp as wp
import numpy as np
wp.init()
num_points = 1024
@wp.kernel
def length(points: wp.array(dtype=wp.vec3),
lengths: wp.array(dtype=float)):
# thread index
tid = wp.tid()
# compute distance of each point from origin
lengths[tid] = wp.length(points[tid])
# allocate an array of 3d points
points = wp.array(np.random.rand(num_points, 3), dtype=wp.vec3)
lengths = wp.zeros(num_points, dtype=float)
# launch kernel
wp.launch(kernel=length,
dim=len(points),
inputs=[points, lengths])
print(lengths)
Running Examples
The examples
directory contains a number of scripts that show how to implement different simulation methods using the Warp API. Most examples will generate USD files containing time-sampled animations (stored in the current working directory). Before running examples, users should ensure that the usd-core
, matplotlib
, and pyglet
packages are installed using:
pip install usd-core matplotlib pyglet
Examples can be run from the command-line as follows:
python -m warp.examples.<example_subdir>.<example>
To browse the example source code, you can open the directory where the files are located like this:
python -m warp.examples.browse
Most examples can be run on either the CPU or a CUDA-capable device, but a handful require a CUDA-capable device. These are marked at the top of the example script.
USD files can be viewed or rendered inside NVIDIA Omniverse, Pixar's UsdView, and Blender. Note that Preview in macOS is not recommended as it has limited support for time-sampled animations.
Built-in unit tests can be run from the command-line as follows:
python -m warp.tests
examples/core
dem | fluid | graph capture | marching cubes |
mesh | nvdb | raycast | raymarch |
sph | torch | wave |
examples/fem
apic fluid | convection diffusion | diffusion 3d | diffusion |
mixed elasticity | navier stokes | stokes transfer | stokes |
examples/optim
bounce | cloth throw | diffray | drone |
inverse kinematics | spring cage | trajectory | walker |
examples/sim
cartpole | cloth | granular | granular collision sdf |
jacobian ik | quadruped | rigid chain | rigid contact |
rigid force | rigid gyroscopic | rigid soft contact | soft body |
Building
For developers who want to build the library themselves, the following tools are required:
- Microsoft Visual Studio 2019 upwards (Windows)
- GCC 9.4 upwards (Linux)
- CUDA Toolkit 11.5 or higher
- Git LFS installed
After cloning the repository, users should run:
python build_lib.py
This will generate the warp.dll
/ warp.so
core library respectively. It will search for the CUDA Toolkit in the default install directory. This path can be overridden by setting the CUDA_PATH
environment variable. Alternatively, the path to the CUDA Toolkit can be passed to the build command as --cuda_path="..."
. After building, the Warp package should be installed using:
pip install -e .
This ensures that subsequent modifications to the library will be reflected in the Python package.
Omniverse
A Warp Omniverse extension is available in the extension registry inside Omniverse Kit or USD Composer:
Enabling the extension will automatically install and initialize the Warp Python module inside the Kit Python environment. Please see the Omniverse Warp Documentation for more details on how to use Warp in Omniverse.
Learn More
Please see the following resources for additional background on Warp:
- GTC 2022 Presentation
- GTC 2021 Presentation
- SIGGRAPH Asia 2021 Differentiable Simulation Course
- GTC 2024 Presentation
The underlying technology in Warp has been used in a number of research projects at NVIDIA including the following publications:
- Accelerated Policy Learning with Parallel Differentiable Simulation - Xu, J., Makoviychuk, V., Narang, Y., Ramos, F., Matusik, W., Garg, A., & Macklin, M. (2022)
- DiSECt: Differentiable Simulator for Robotic Cutting - Heiden, E., Macklin, M., Narang, Y., Fox, D., Garg, A., & Ramos, F (2021)
- gradSim: Differentiable Simulation for System Identification and Visuomotor Control - Murthy, J. Krishna, Miles Macklin, Florian Golemo, Vikram Voleti, Linda Petrini, Martin Weiss, Breandan Considine et al. (2021)
Citing
If you use Warp in your research please use the following citation:
@misc{warp2022,
title= {Warp: A High-performance Python Framework for GPU Simulation and Graphics},
author = {Miles Macklin},
month = {March},
year = {2022},
note= {NVIDIA GPU Technology Conference (GTC)},
howpublished = {\url{https://github.com/nvidia/warp}}
}
Frequently Asked Questions
See the FAQ in the Warp documentation.
Support
Problems, questions, and feature requests can be opened on GitHub Issues.
The Warp team also monitors the #warp channel on the public Omniverse Discord server, come chat to us!
License
Warp is provided under the NVIDIA Software License, please see LICENSE.md for full license text.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for warp_lang-1.1.0-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00ddfed57f62046eea50b2123f87bd8b327a7468bc1d8d9cbddb518cdf5810cb |
|
MD5 | f3aa8bf9d6e85e3ed222f3ed22456611 |
|
BLAKE2b-256 | 960f06c400d6fb43724dd669458807f2df656848820f8438ef4bbe3eab393e4d |
Hashes for warp_lang-1.1.0-py3-none-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d47c9a3afbc7833e7bc6bb1121f0afd10f2e3df3c0eb7ac8d614a12ed288b2ec |
|
MD5 | c367e484f2ff3119aeee26aa0ab917ed |
|
BLAKE2b-256 | 43851f2f350c8796240cc95a6cf190b31273faa1912af0d12f435a12a6f7ed84 |
Hashes for warp_lang-1.1.0-py3-none-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d587eccd411ca9374485b1f5f17884b3677d675234427a182298affdbcf2213 |
|
MD5 | fb9e0077698b679f2584d47d2791b1b0 |
|
BLAKE2b-256 | 6e467f41a71f6f03b5560adad6223faef96591f9c1cad306490638d9299ae87b |
Hashes for warp_lang-1.1.0-py3-none-macosx_10_13_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7329e15ada0ffeb508b352002601022e8a8c7e6a29b3e7b0ef2ba5c1c0b38ec4 |
|
MD5 | cd90be5fa78831facd3682654fb3c7b3 |
|
BLAKE2b-256 | 48200e5bcfaf88c09f8bafe141eb2459a272f4a78abc91b16f1a846011264ebd |