This guide provides two methods for swapping CUDA versions on Windows:
- Manual method using System Environment Variables (forked from bycloud)
- Automated method using a PowerShell script (added by me)
For ease, I will be demonstrating switching from CUDA 11.6 to CUDA 11.3, but the same methods apply to other versions.
Check what version of CUDA you have. You can enter this in any command prompt (cmd, anaconda, etc):
nvcc --version
-
If you get something like this:
'nvcc' is not recognized as an internal or external command, operable program or batch file.This means you don't have any CUDA installed. You can download your desired CUDA Toolkit version here (everything default would be fine)
A quick rule of thumb:
- NVIDIA GPU >= 30 series --> CUDA 11.0+
- NVIDIA GPU < 30 series --> CUDA 10.2 (CUDA 10.0 & 10.1 kinda outdated, use 10.2 unless specified)
You can also check your GPU compatibility here for NVIDIA GPU < 30 series. If your GPU has CC >= 3.7, then it supports PyTorch.
If you just freshly downloaded CUDA, then you would not need to proceed in the following steps, because you would have the CUDA version you want. You can do another quick check with
nvcc --versionto check your version in any command prompt. -
If you get something like this:
Then it means you have CUDA installed. And in my case, it's CUDA 11.6. I will be swapping to CUDA 11.3 in the following steps.
Open up your environment variables. You can search "env" in the search tab, it should look something like this.
Then open it. Then click "Environment Variables" Then it should open up a window like thisDouble check on CUDA_PATH and this window should pop up
Press ok and proceed to the next step.
Scroll down and find Path, double click to open
Close the last command prompt, and open a new one. Enter the following command:
nvcc --version
If it outputs your desired version, then you have succeeded in swapping CUDA version.
For a more convenient and automated approach, you can use the provided PowerShell script to switch between CUDA versions.
- Save the script as
Switch-CUDAVersion.ps1in a known location on your computer. - Open PowerShell as an administrator.
- Navigate to the directory containing the script.
- Run the script using one of the following methods:
.\Switch-CUDAVersion.ps1This will list all available CUDA versions and prompt you to choose one.
.\Switch-CUDAVersion.ps1 -Version v12.4This will switch to CUDA version 12.4 if it's installed.
.\Switch-CUDAVersion.ps1 -ListVersionsThis will display a list of all installed CUDA versions.
.\Switch-CUDAVersion.ps1 -GetCurrentThis will show the currently active CUDA version.
- Automatically detects installed CUDA versions
- Allows switching to a specific version
- Updates both
CUDA_PATHandPathenvironment variables - Can be run interactively or with command-line parameters
- Suitable for inclusion in other scripts or automation workflows
After running the script, you may need to restart any open command prompts or applications for the changes to take effect.









