aoti-debug
aoti-debug — a Claude Code skill from pytorch/pytorch
Features
- ✓GPU-accelerated tensor computation
- ✓Tape-based autograd for dynamic neural networks
- ✓Extends Python packages like NumPy and SciPy
- ✓Integrated neural networks library
- ✓Find individual tools in the GitHub repo
Installation Guide
Binaries
Commands to install binaries via Conda or pip wheels are on our website: https://pytorch.org/get-started/locally/
#### NVIDIA Jetson Platforms
Python wheels for NVIDIA's Jetson Nano, Jetson TX1/TX2, Jetson Xavier NX/AGX, and Jetson AGX Orin are provided here and the L4T container is published here
They require JetPack 4.2 and above, and @dusty-nv and @ptrblck are maintaining them.
From Source
#### Prerequisites
If you are installing from source, you will need:
\* PyTorch CI uses Visual C++ BuildTools, which come with Visual Studio Enterprise,
Professional, or Community Editions. You can also install the build tools from
https://visualstudio.microsoft.com/visual-cpp-build-tools/. The build tools *do not*
come with Visual Studio Code by default.
An example of environment setup is shown below:
* Linux:
$ source <CONDA_INSTALL_DIR>/bin/activate
$ conda create -y -n <CONDA_NAME>
$ conda activate <CONDA_NAME>* Windows:
$ source <CONDA_INSTALL_DIR>\Scripts\activate.bat
$ conda create -y -n <CONDA_NAME>
$ conda activate <CONDA_NAME>
$ call "C:\Program Files\Microsoft Visual Studio\<VERSION>\Community\VC\Auxiliary\Build\vcvarsall.bat" x64A conda environment is not required. You can also do a PyTorch build in a
standard virtual environment, e.g., created with tools like uv, provided
your system has installed all the necessary dependencies unavailable as pip
packages (e.g., CUDA, MKL.)
##### NVIDIA CUDA Support
If you want to compile with CUDA support, select a supported version of CUDA from our support matrix, then install the following:
Note: You could refer to the cuDNN Support Matrix for cuDNN versions with the various supported CUDA, CUDA driver, and NVIDIA hardware.
If you want to disable CUDA support, export the environment variable USE_CUDA=0.
Other potentially useful environment variables may be found in setup.py. If
CUDA is installed in a non-standard location, set PATH so that the nvcc you
want to use can be found (e.g., export PATH=/usr/local/cuda-12.8/bin:$PATH).
If you are building for NVIDIA's Jetson platforms (Jetson Nano, TX1, TX2, AGX Xavier), Instructions to install PyTorch for Jetson Nano are available here
##### AMD ROCm Support
If you want to compile with ROCm support, install
By default the build system expects ROCm to be installed in /opt/rocm. If ROCm is installed in a different directory, the ROCM_PATH environment variable must be set to the ROCm installation directory. The build system automatically detects the AMD GPU architecture. Optionally, the AMD GPU architecture can be explicitly set with the PYTORCH_ROCM_ARCH environment variable AMD GPU architecture
If you want to disable ROCm support, export the environment variable USE_ROCM=0.
Other potentially useful environment variables may be found in setup.py.
##### Intel GPU Support
If you want to compile with Intel GPU support, follow these
If you want to disable Intel GPU support, export the environment variable USE_XPU=0.
Other potentially useful environment variables may be found in setup.py.
#### Get the PyTorch Source
git clone https://github.com/pytorch/pytorch
cd pytorch
# if you are updating an existing checkout
git submodule sync
git submodule update --init --recursive#### Install Dependencies
Common
# Run this command from the PyTorch directory after cloning the source code using the “Get the PyTorch Source“ section above
pip install --group devOn Linux
pip install mkl-static mkl-include
# CUDA only: Add LAPACK support for the GPU if needed
# magma installation: run with active conda environment. specify CUDA version to install
.ci/docker/common/install_magma_conda.sh 12.4
# (optional) If using torch.compile with inductor/triton, install the matching version of triton
# Run from the pytorch directory after cloning
# For Intel GPU support, please explicitly `export USE_XPU=1` before running command.
make tritonOn Windows
pip install mkl-static mkl-include
# Add these packages if torch.distributed is needed.
# Distributed package support on Windows is a prototype feature and is subject to changes.
conda install -c conda-forge libuv=1.51#### Install PyTorch
On Linux
If you're compiling for AMD ROCm then first run this command:
# Only run this if you're compiling for ROCm
python tools/amd_build/build_amd.pyInstall PyTorch
# the CMake prefix for conda environment
export CMAKE_PREFIX_PATH="${CONDA_PREFIX:-'$(dirname $(which conda))/../'}:${CMAKE_PREFIX_PATH}"
python -m pip install --no-build-isolation -v -e .
# the CMake prefix for non-conda environment, e.g. Python venv
# call following after activating the venv
export CMAKE_PREFIX_PATH="${VIRTUAL_ENV}:${CMAKE_PREFIX_PATH}"On macOS
python -m pip install --no-build-isolation -v -e .On Windows
If you want to build legacy python code, please refer to Building on legacy code and CUDA
CPU-only builds
In this mode PyTorch computations will run on your CPU, not your GPU.
python -m pip install --no-build-isolation -v -e .Note on OpenMP: The desired OpenMP implementation is Intel OpenMP (iomp). In order to link against iomp, you'll need to manually download the library and set up the building environment by tweaking CMAKE_INCLUDE_PATH and LIB. The instruction here is an example for setting up both MKL and Intel OpenMP. Without these configurations for CMake, Microsoft Visual C OpenMP runtime (vcomp) will be used.
CUDA based build
In this mode PyTorch computations will leverage your GPU via CUDA for faster number crunching
NVTX is needed to build PyTorch with CUDA.
NVTX is a part of CUDA distributive, where it is called "Nsight Compute". To install it onto an already installed CUDA run CUDA installation once again and check the corresponding checkbox.
Make sure that CUDA with Nsight Compute is installed after Visual Studio.
Currently, VS 2017 / 2019, and Ninja are supported as the generator of CMake. If ninja.exe is detected in PATH, then Ninja will be used as the default generator, otherwise, it will use VS 2017 / 2019.
<br/> If Ninja is selected as the generator, the latest MSVC will get selected as the underlying toolchain.
Additional libraries such as
Magma, oneDNN, a.k.a. MKLDNN or DNNL, and Sccache are often needed. Please refer to the installation-helper to install them.
You can refer to the build_pytorch.bat script for some other environment variables configurations
cmd
:: Set the environment variables after you have downloaded and unzipped the mkl package,
:: else CMake would throw an error as `Could NOT find OpenMP`.
set CMAKE_INCLUDE_PATH={Your directory}\mkl\include
set LIB={Your directory}\mkl\lib;%LIB%
:: Read the content in the previous section carefully before you proceed.
:: [Optional] If you want to override the underlying toolset used by Ninja and Visual Studio with CUDA, please run the following script block.
:: "Visual Studio 2019 Developer Command Prompt" will be run automatically.
:: Make sure you have CMake >= 3.12 before you do this when you use the Visual Studio generator.
set CMAKE_GENERATOR_TOOLSET_VERSION=14.27
set DISTUTILS_USE_SDK=1
for /f "usebackq tokens=*" %i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -version [15^,17^) -products * -latest -property installationPath`) do call "%i\VC\Auxiliary\Build\vcvarsall.bat" x64 -vcvars_ver=%CMAKE_GENERATOR_TOOLSET_VERSION%
:: [Optional] If you want to override the CUDA host compiler
set CUDAHOSTCXX=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\HostX64\x64\cl.exe
python -m pip install --no-build-isolation -v -e .Intel GPU builds
In this mode PyTorch with Intel GPU support will be built.
Please make sure [the common prerequisites](#prerequisites) as well as [the prerequisites for Intel GPU](#intel-gpu-support) are properly installed and the environment variables are configured prior to starting the build. For build tool support, Visual Studio 2022 is required.
Then PyTorch can be built with the command:
:: CMD Commands:
:: Set the CMAKE_PREFIX_PATH to help find corresponding packages
:: %CONDA_PREFIX% only works after `conda activate custom_env`
if defined CMAKE_PREFIX_PATH (
set "CMAKE_PREFIX_PATH=%CONDA_PREFIX%\Library;%CMAKE_PREFIX_PATH%"
) else (
set "CMAKE_PREFIX_PATH=%CONDA_PREFIX%\Library"
)
python -m pip install --no-build-isolation -v -e .##### Adjust Build Options (Optional)
You can adjust the configuration of cmake variables optionally (without building first), by doing
the following. For example, adjusting the pre-detected directories for CuDNN or BLAS can be done
with such a step.
On Linux
export CMAKE_PREFIX_PATH="${CONDA_PREFIX:-'$(dirname $(which conda))/../'}:${CMAKE_PREFIX_PATH}"
CMAKE_ONLY=1 python setup.py build
ccmake build # or cmake-gui buildOn macOS
export CMAKE_PREFIX_PATH="${CONDA_PREFIX:-'$(dirname $(which conda))/../'}:${CMAKE_PREFIX_PATH}"
MACOSX_DEPLOYMENT_TARGET=11.0 CMAKE_ONLY=1 python setup.py build
ccmake build # or cmake-gui buildDocker Image
#### Using pre-built images
You can also pull a pre-built docker image from Docker Hub and run with docker v23.0+
docker run --gpus all --rm -ti --ipc=host pytorch/pytorch:latestPlease note that PyTorch uses shared memory to share data between processes, so if torch multiprocessing is used (e.g.
for multithreaded data loaders) the default shared memory segment size that container runs with is not enough, and you
should increase shared memory size either with --ipc=host or --shm-size command line options to nvidia-docker run.
#### Building the image yourself
NOTE: Must be built with a Docker version >= 23.0
The Dockerfile is supplied to build images with CUDA 12.1 support and cuDNN v9.
You can pass PYTHON_VERSION=x.y make variable to specify which Python version is to be used by Miniconda, or leave it
unset to use the default, as the Dockerfile uses system Python.
make -f docker.Makefile
# images are tagged as docker.io/${your_docker_username}/pytorchYou can also pass the CMAKE_VARS="..." environment variable to specify additional CMake variables to be passed to CMake during the build.
See [setup.py](./setup.py) for the list of available variables.
make -f docker.MakefileBuilding the Documentation
To build documentation in various formats, you will need Sphinx
and the pytorch_sphinx_theme2.
Before you build the documentation locally, ensure torch is
installed in your environment. For small fixes, you can install the
nightly version as described in Getting Started.
For more complex fixes, such as adding a new module and docstrings for
the new module, you might need to install torch [from source](#from-source).
See Docstring Guidelines
for docstring conventions.
cd docs/
pip install -r requirements.txt
make html
make serveRun make to get a list of all available output formats.
If you get a katex error run npm install katex. If it persists, trynpm install -g katex
[!NOTE]
If you see a numpy incompatibility error, run:
>
> pip install 'numpy<2'
>#### Troubleshooting CI Errors
Your build may show errors you didn't have locally - here's how to find the errors relevant to the docs.
If the build has any errors, you will see something like this on the PR:
<img width="781" height="400" alt="Monosnap Update installation instructions for doc build · Pull Request #169534 · pytorch:pytorch 2025-12-18 18-22-53" src="https://github.com/user-attachments/assets/49a3dfe7-81c2-4246-852b-bc3f807e95af" />
Any doc-related errors will occur in jobs that include "doc" somewhere in the title. It doesn't look like any of these jobs are relevant to our docs.
Let's take a look anyway. Click on the job to see the logs:
<img width="1187" height="668" alt="Monosnap Update installation instructions for doc build · pytorch:pytorch@7380336 2025-12-18 18-24-15" src="https://github.com/user-attachments/assets/117df543-8356-4323-8e1c-ef02a95554ba" />
And we can be sure that this job does not involve docs.
Looking at this build, we can see these jobs are relevant to our docs - and they didn't have any errors:
<img width="777" height="395" alt="Check the docs jobs" src="https://github.com/user-attachments/assets/5d7c196b-2d40-49ad-87e3-f57de6e14a5b" />
You might also see a comment on the PR like this:
<img width="651" height="246" alt="PR Comment" src="https://github.com/user-attachments/assets/27e0120a-ba33-4b1c-b4a5-bf3064520586" />
We can see that some of these issues are relevant to our docs.
Open the logs by clicking on the gh link:
<img width="873" height="360" alt="View Logs" src="https://github.com/user-attachments/assets/ab5b862f-8026-489c-b95e-a6cd4257e4b7" />
And here we can see there is a doc-related error:
<img width="1117" height="433" alt="Doc Error" src="https://github.com/user-attachments/assets/0a275921-736d-43a7-ab0f-3e8854d43280" />
You can always find the relevant doc builds by going to the Checks tab on your PR, and scrolling down to pull.
<img width="481" height="561" alt="checks" src="https://github.com/user-attachments/assets/eef18f2b-7134-4e2e-bd90-bcdc12800132" />
You can either click through or toggle the accordion to see all of the jobs here, where you can see the docs jobs highlighted:
<img width="570" height="611" alt="jobs" src="https://github.com/user-attachments/assets/f62812ca-caee-421b-863c-54f38fd28d46" />
If you click through, you'll see the doc jobs at the bottom, like this:
<img width="354" height="312" alt="View Docs jobs" src="https://github.com/user-attachments/assets/8fadb935-5314-4c4b-a1b5-133781754f03" />
#### Building a PDF
To compile a PDF of all PyTorch documentation, ensure you havetexlive and LaTeX installed. On macOS, you can install them using:
brew install --cask mactexTo create the PDF:
make latexpdf This will generate the necessary files in the build/latex directory.
make LATEXOPTS="-interaction=nonstopmode" This will produce a pytorch.pdf with the desired content. Run this
command one more time so that it generates the correct table
of contents and index.
[!NOTE]
To view the Table of Contents, switch to the Table of Contents
view in your PDF viewer.
Previous Versions
Installation instructions and binaries for previous PyTorch versions may be found
on our website.