Tutorial: CUDA, cuDNN, Anaconda, Jupyter, PyTorch Installation in Windows 10
In this story, the procedures of CUDA, cuDNN, Anaconda, Jupyter, PyTorch Installation in Windows 10, is described. Indeed, the procedures are straightforward. No tricks involved. Let’s get started! (Sik-Ho Tsang @ Medium)
0. GPU & NVIDIA Driver Installation
- Before all, the computer should‘ve have got a GPU/Display card.
- Also, normally, NVIDIA driver is installed by NVIDIA experience console.
1. CUDA Installation
- First, go to https://developer.nvidia.com/cuda-downloads
- Select the following settings to download the CUDA:
- After downloading, click the exe file to install CUDA:
- Mine is CUDA version 11.4.
- You may check the CUDA version that just installed.
- Open Windows PowerShell and type:
- which is the same command as in Ubuntu. CUDA version 11.4 is shown.
2. cuDNN Installation
- Go to https://developer.nvidia.com/cudnn.
- You need to have an account in order to download cuDNN. If no, register one, and go to the above link again.
- Finally, you got something like this:
- Click to download the zip file. (Mine is v8.2.4.)
- Unzip it.
- My CUDA installed path is:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\vx.x\
- where vx.x is v11.4.
- Go to this path. You should see there are 3 directories called “bin”, “include”, and “lib”, which are the same as the unzipped one.
- Copy the unzipped folders to this path. Then cuDNN is installed.
2.3. Setting Environmental Variables (Optional in my case)
- In the guideline of NVIDIA, it needs to set the environmental variables, but I do not need to, these are already done. Maybe the guideline is not up-to-date.
- Below are the steps from the guideline of NVIDIA:
- Open a command prompt from the Start menu.
Type Run and hit Enter.
Issue the control sysdm.cpl command.
Select the Advanced tab at the top of the window.
Click Environment Variables at the bottom of the window.
Ensure the following values are set:
Variable Name: CUDA_PATH
Variable Value: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\vx.x
- Open the Visual Studio project and right-click on the project name.
- Click Linker > Input > Additional Dependencies. Add cudnn.lib and click OK.
3. Anaconda & Jupyter Installation
3.1. Download & Install
- Go to https://www.anaconda.com/products/individual
- Download the Windows version and install should be okay.
3.2. Create & Activate Environment
- Open “Ananconda Powershell Prompt”
- Update the conda
conda update conda
- Create a new environment. (I normally like to create a new one for a new task.)
- conda env list can check the list of environments.
conda create — name pytorch_trial_0
conda env list
- Activate it.
conda activate pytorch_trial_0
3.3. Jupyter Notebook
- First, Install it:
conda install jupyter
- jupyter notebook list can check the list of notebook:
jupyter notebook list
- Create a notebook for development:
- My Google Chrome automatically open the jupyter notebook page for me.
- If not, just copy the link at the bottom of the PowerShell console.
4. PyTorch Installation
4.1. Download & Install
- Go to https://pytorch.org/:
- Copy the above command to Ananconda Powershell Prompt and run it, to download & install PyTorch GPU version.
- (If you only got CPU, choose CPU version at the Computer Platform.)
- (If you have launched the notebook, you may need to open a new PowerShell to activate the same environment again.)
- I just directly copy the above command to install:
conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c conda-forge
- To test, you may try some Python command to test:
- The library should be properly imported.
- CUDA should also be checked as available using torch function.
I write this story so that I can repeat it next time easily if needed. :)