This guide will walk you through the steps to set up CUDA on Windows for working with PyTorch and DropGrad.
- Windows operating system
- NVIDIA GPU with CUDA support
- Visit the NVIDIA CUDA Downloads page.
- Select your specific Windows version and architecture.
- Download the CUDA Toolkit installer.
- Run the installer and follow the installation instructions.
To install PyTorch with CUDA support, run the following command:
pip3 install numpy --pre torch torchvision torchaudio --force-reinstall --index-url https://download.pytorch.org/whl/nightly/cu118
This command will install the latest version of PyTorch with CUDA 11.8 support.
Note: If you are building DropGrad locally, ensure that the requirements.txt
file includes the appropriate PyTorch version with CUDA support. Update the file if necessary.
It is recommended to work within a virtual environment to manage dependencies and avoid conflicts. To create and activate a virtual environment, follow these steps:
python -m venv new_env
.\new_env\Scripts\activate
To deactivate the virtual environment when you're done, simply run:
deactivate
To verify that CUDA and the NVIDIA driver are properly installed, run the following commands:
nvidia-smi
nvcc --version
The nvidia-smi
command displays information about your NVIDIA GPU and the installed driver version. The nvcc --version
command shows the installed CUDA version.
If you have multiple GPUs and want to specify which one to use, set the CUDA_VISIBLE_DEVICES
environment variable:
set CUDA_VISIBLE_DEVICES=0
Replace 0
with the desired GPU index.
To verify that PyTorch is installed correctly with CUDA support, run the following command:
python -c "import torch; print(torch.__version__); print(torch.cuda.is_available())"
If the output shows the PyTorch version and True
for CUDA availability, then PyTorch with CUDA support is properly installed.
You have now successfully set up CUDA on Windows for working with PyTorch and DropGrad. Make sure to activate your virtual environment and ensure that the requirements.txt
file includes the appropriate PyTorch version with CUDA support when building DropGrad locally.
If you encounter any issues or have further questions, please refer to the official PyTorch and NVIDIA CUDA documentation or seek support from the community.