Installing PyTorch3D on Windows 11: An Exhaustive Step-by-Step Guide
PyTorch3D is a potent library for 3D deep learning tasks, including rendering, shape analysis, and point cloud processing. It is developed by Meta’s AI lab, Fundamental AI Research (FAIR).
However, one notable challenge is the absence of official Windows installation instructions on the official PyTorch3D documentation. While official support for Linux is provided, Windows users must rely on workarounds.
In this guide, I’ll walk you through the steps required to install PyTorch3D on Windows 11 based on personal troubleshooting and debugging from various sources across the internet.
Prerequisites
Ensure you have the following:
NVIDIA GPU: PyTorch3D leverages CUDA for GPU computations.
Windows 11 (64-bit): This guide is tailored for Windows 11, but similar steps apply to Windows 10.
Conda: You’ll need Conda for dependency management. You can download it via Anaconda or Miniconda.
Note: After extensive trial and error, I settled on this configuration and dependency version. Using different versions may result in build failure, such as with varying CUDA versions or C++ builds.
Let’s begin with the installation process!
Step 1: Install CUDA 11.8
PyTorch3D relies on CUDA for GPU acceleration, and I will be using CUDA 11.8. Download it from the NVIDIA archive:
- CUDA 11.8.0 Download Archive
Once downloaded, follow the installation instructions. After installation, check that your system paths are correctly set so the CUDA toolkit and runtime libraries are available.
Tip: Verifying CUDA Installation
Run the following command to verify that CUDA is properly installed:
nvcc - version
Step 2: Create a Conda Environment for PyTorch3D
Create a dedicated Conda environment to keep dependencies organized and avoid conflicts. Run the following command to create an environment with Python 3.10, PyTorch 2.2.1, and CUDA 11.8:
conda create - name pytorch_3d python=3.10 pytorch==2.2.1 torchvision==0.17.1 torchaudio==2.2.1 pytorch-cuda=11.8 -c pytorch -c nvidia
This installs PyTorch with CUDA support, ensuring compatibility with the 3D operations in PyTorch3D.
Step 3: Install Additional Dependencies
Next, you’ll need fvcore and iopath, which PyTorch3D requires. Install these via Conda:
conda install -c fvcore -c iopath -c conda-forge fvcore iopath
Step 4: Downgrade Numpy (Required as of October 2024)
Many of the dependencies for PyTorch3D are currently compiled with Numpy 1.x.x. Using Numpy 2.x.x will result in compatibility issues, causing builds or operations to fail. Therefore, it is mandatory to downgrade Numpy to a compatible 1.x.x version. You can downgrade to version 1.26.4 by running:
conda install numpy=1.26.4
This ensures compatibility with dependencies that require the 1.x.x version of Numpy.
Step 5: Download and Configure NVIDIA CUB
PyTorch3D requires NVIDIA’s CUB library for CUDA operations. CUB provides state-of-the-art, reusable software components for every layer of the CUDA programming model. Download it from the GitHub repository and configure the environment variable:
Unpack the library to a location of your choice and set the `CUB_HOME` environment variable to the folder containing `CMakeLists.txt`:
set CUB_HOME=path/to/cub
This step ensures that the build process can find the necessary files.
Step 6: Install C++ Build Tools
Since PyTorch3D requires C++ build tools for compiling on Windows, you’ll need to install them via Visual Studio. Initially, I tried Visual Studio 2022, but I encountered a CUDA error stating that only Visual Studio 2017–2022 is supported. Despite this, Visual Studio 2022 did not work for me. To resolve this, I used Visual Studio 2019, which worked without issues.
Here’s how to install the required build tools:
1. Download the build tools from:
- Visual Studio 2019 Build Tools
2. During installation, Select the Desktop Development with C++ workload is selected and ensure the following components are also selected under the C++ development options:
- C++ ATL for latest v142 build tools (x86 & x64)
- C++ MFC for latest v142 build tools (x86 & x64)
- C++/CLI support for v142 build tools (Latest)
- C++ Modules for v142 build tools (x64/x86)
Your installation window should look like this:
If you encounter errors using Visual Studio 2022, try switching to Visual Studio 2019 for CUDA compatibility.
Step 7: Clone and Build PyTorch3D
Important: To ensure CUDA has access to the correct build tools, you must run the following steps inside the 64 Native Tools Command Prompt for VS 2019. If you skip this and use a regular command prompt or PowerShell, the build may fail. You can find the x64 Native Tools Command Prompt for VS 2019 by searching for it in the Windows search bar after installing Visual Studio 2019 Build Tools.
Now, clone the PyTorch3D repository from GitHub:
git clone https://github.com/facebookresearch/pytorch3d
or clone from the commit point where I cloned at.
git clone https://github.com/facebookresearch/pytorch3d/tree/fca83e6369e62de2736763372a2de949d56d5a74
Navigate to the PyTorch3D directory:
cd path/to/pytorch3d
Activate your Conda environment:
conda activate pytorch_3d
Set the required environment variable for building:
set DISTUTILS_USE_SDK=1
Then, install the build tools and PyTorch3D itself:
pip install build pip
pip install .
Step 8: Verify Your Installation
Finally, to ensure everything was installed correctly, verify by running the following Python command:
python -c "import torch; import pytorch3d; print('PyTorch3D version:', pytorch3d.__version__)"
If everything went smoothly, you should see the installed version of PyTorch3D printed.
Conclusion
While installing PyTorch3D on Windows 11 isn’t as straightforward as on Linux, with the right steps and workarounds, it can be done successfully. Since no official Windows instructions are provided on the PyTorch3D documentation, I had to troubleshoot, research across various forums, and piece together the right steps.
With this guide, you should now be able to install PyTorch3D on your Windows machine and take advantage of its powerful 3D deep learning capabilities.
If you encounter any issues, feel free to leave a comment, and I’ll try to assist you.