- 1 year ago
CUDA issue - how to clean install CUDA in Win 10 to resolve cudaGetDevice() failed
To perform a clean installation of CUDA on Windows 10 and resolve issues with cudaGetDevice() failed
, you can follow these steps:
Uninstall existing CUDA installation:
- Go to "Control Panel" > "Programs" > "Uninstall a program".
- Uninstall any existing CUDA-related programs, such as CUDA Toolkit and CUDA drivers.
Remove CUDA-related environment variables:
- Open the "System Properties" dialog by right-clicking "This PC" and selecting "Properties".
- Click on "Advanced system settings" on the left-hand side.
- In the "System Properties" window, click on the "Environment Variables" button.
- Under "System variables", remove any variables related to CUDA, such as
CUDA_HOME
orCUDA_PATH
.
Remove CUDA-related files and folders:
- Navigate to the CUDA installation directory (usually
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA
) and delete the entire CUDA folder. - Remove any other CUDA-related files or folders that may be present on your system.
- Navigate to the CUDA installation directory (usually
Download the latest CUDA Toolkit:
- Go to the NVIDIA CUDA Toolkit downloads page: https://developer.nvidia.com/cuda-toolkit-archive
- Select the desired CUDA version and download the installer for your Windows version.
Install CUDA Toolkit:
- Run the downloaded CUDA Toolkit installer.
- Follow the installation wizard instructions and choose the desired installation options.
- Make sure to select the appropriate CUDA components, such as CUDA Toolkit, CUDA drivers, and CUDA samples.
Set CUDA-related environment variables:
- Open the "System Properties" dialog as explained in step 2.
- Click on the "Environment Variables" button.
- Under "System variables", click on "New" to add a new variable.
- Set the variable name as
CUDA_HOME
and the variable value as the CUDA installation path (e.g.,C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\version
).
Update system PATH variable:
- In the "Environment Variables" window, under "System variables", find the
Path
variable and click on "Edit". - Add the CUDA binary directory to the PATH. Append
%CUDA_HOME%\bin
to the existing PATH value, separating it with a semicolon.
- In the "Environment Variables" window, under "System variables", find the
Restart your computer to apply the changes.
After completing these steps, you should have a clean installation of CUDA on your Windows 10 system. Make sure to update your CUDA code and recompile it to ensure compatibility with the new CUDA installation.
Note: It's recommended to consult the official NVIDIA CUDA documentation and release notes for detailed instructions and specific requirements related to your CUDA version and hardware configuration.