How to Install PyTorch for CUDA 12 on Windows 10 64-Bit – Pytorch

Photo of author
Written By M Ibrahim
compatibility python3.x pytorch

The Problem:
Installing PyTorch on a Windows 10 64-bit machine with CUDA 12.0 can be challenging since the official PyTorch documentation does not explicitly provide an option for this CUDA version.

The Solution:
Fortunately, there are a few alternative solutions that you can try to install PyTorch with CUDA 12.0 on your Windows 10 machine.

Solution 1: Using the Nightly Build

One option is to install the nightly build of PyTorch, which supports Python 3.11 and CUDA 12.1. You can use the following command to install the nightly build:

pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu121 

This command will download and install the latest nightly build of PyTorch with CUDA 12.1 support. Keep in mind that this is a nightly build, so there might be some bugs or issues that you might encounter.

Solution 2: Building PyTorch from Source

Another option is to build PyTorch from source with CUDA 12.0 support. This method requires more technical expertise and can be time-consuming, but it gives you full control over the installation process. You can follow the official PyTorch guide on building from source to get started.

The process involves cloning the PyTorch repository, configuring the build settings, and compiling the source code. This method allows you to customize the build according to your specific requirements.

Solution 3: Using an NGC Container

If you prefer a more preconfigured and hassle-free approach, you can use an NGC (NVIDIA GPU Cloud) container. NGC provides a range of containers that include pre-built deep learning frameworks, including PyTorch, with different CUDA versions.

To use an NGC container, you need to have Docker installed on your machine. You can then pull the desired PyTorch container image with CUDA 12.0 support from the NGC container registry. The official PyTorch documentation provides instructions on how to pull and run PyTorch containers using Docker.

Conclusion:
Installing PyTorch on Windows 10 with CUDA 12.0 can be a bit tricky since it is not officially listed as a supported CUDA version. However, you have a few alternative solutions to choose from. You can either try the nightly build, build PyTorch from source, or use an NGC container. Each solution has its own advantages and considerations, so choose the one that suits your needs the best.

Remember that using the nightly build or building from source might involve some technical challenges, and it’s recommended to have some knowledge of Python and CUDA. Conversely, using an NGC container offers a more streamlined and user-friendly experience but requires Docker to be installed.

By following one of these solutions, you can successfully install PyTorch on your Windows 10 machine with CUDA 12.0 and begin your deep learning journey.

Happy coding!