Let’s understand the procedure to install Visual Studio, CUDA and CUDANN for Windows. This tutorial is a breif explanation and can be used to solve the Graphics Card usage in Windows.
Pre-requisites:
- Install python 3.9
- Install pip
- Install VSCode and install Virtual Environment venv
PART-1:
- Install Visual Studio (2019) for Windows 10/11 for CUDA and CUDANN.
- After Visual Studio installation install CUDA (11.2) for 2019.
- After CUDA installation install CUDANN (8.2.x) for CUDA.
Warning: Please make sure you are installing Visual Studio (2019) from older repos and installing them in ‘C:’
Note: Install CUDA (11.2) for 2019 and CUDANN (8.2.x) version.
PART-2:
Paste these folders under the NVIDIA GPU Toolkit -> CUDA 11.2 -> /bin, /lib, /include
- cudnn64_7.dll -> /bin
- cudnn.h -> /include
- cudnn.lib -> /lib/x64
PART-3:
We need to add these paths to the sys path folder. Usually you will find the two paths mentioned under the Environment path location.
- On the Windows taskbar, right-click the Windows icon and select System.
- In the Settings window, under Related Settings, click Advanced system settings.
Add the path ‘C:Users/Program Files/NVIDIA GPU Toolkit /CUDA.11/bin’
Add the path ‘C:Users/Program Files/NVIDIA GPU Toolkit /CUDA.11/libmnrv’
PART-4:
In this part, we will be focusing on enabling your GPU to be used in Visual Studio Code.
We need to add the following line to your code in the beginning on your code:
- import os
- os.add_dll_directory("C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.2/bin")
This will enable VS Code to access your CUDA if User do not have ‘sudo’ privilege to your system.
To run venv we need to initiate the following command
Set-ExecutionPolicy Unrestricted -Scope Process
Warning: Please ensure you are using the right path for the Testenv in place of ‘YourPath’
Initializing Virtual Environment Testenv:
You can initiate the Venv using your path to ‘Testenv’. Your ‘Testenv’ python executable with the concerned python file you want to use.
- & "YourPath/Testenv/Scripts/Activate.ps1"
- & "YourPath/Testenv/Scripts/python.exe" "YourPath/Time_Series_Analysis/Time_Series.py"