Review of Instaling Pytorch-GPU Version
Introduction
In my final year project of the undergraduate study, I’m asked to use SNN for classification of event-camera data. After discussion with my leader and team members, we decided to use Norse as the python library for developing the SNN module. In this article, I will give a relatively detailed review of the installation of Pytorch and Norse.
1 Install Anaconda
1.1 Install from Origin Source
Anaconda can be downloaded from this website Anaconda Download. It is worth to notice that please change the location of the installation to other disks rather than in C.
1.2 Install by using the provided Link to BaiduNetworkDisk
You can also download all resources by using the BaiduNetworkDisk sharing as below: Link to BaiduNetworkDisk
password: kdlh
Unzip the .rar file and you will get three executable files and the one named after Anaconda is what you need here.
2 Download and Install Cuda 11.3 and Cudnn
2.1 Download from Origin Source
Download from the origin source: you can click here, choose the version of interest (we are using 11.3.1 here). After the downloading is finished, double click on the .exe file and install under the instruction.
2.2 Download from BaiduNetworkDisk
The Cuda 11.3 toolkits is in the same folder as you have installed in step 1.2, and is named by Cuda 11.3.1, double click on the file and just install the Cuda under the instructions.
3 Download the Cudnn
3.1 Download from Origin Source
You can visit the Official Website of Cudnn by this, don’t forget to choose the version for Cuda 11.x.
3.2 Download from BaiduNetworkDisk
Also in the same folder as before, which is a .zip file named by Cudnn 8.5.0.
3.3 Configure the Cudnn into Cuda
Switch to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.3, the content in that folder is supposed to be as shown below.
Open the Downloaded Cudnn file and directly copy the three folders as shown below and paste that to the folder you opened before.
So far, you have finished the preparation of downloading Pytorch and Norse.
4 Download Pytorch-gpu to a virtual environment in Anaconda
First, search Anaconda Prompt in start menu.
Then, in order to create a new environment in other Disks rather than C: disk, type the following codes into the Anaconda Prompt.
E: # change to other disks
cd E:/Anaconda_Virtual_Environment # switch to the destination folder
conda create -n NameOfVirtualEnvironment
conda activate NameOfVirtualEnvironment
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113 -i https://pypi.tuna.tsinghua.edu.cn/simple some-package # this three lines should be typed in one line
If this is done without any problem, Congratulations! You have sucessfully installed Pytorch with gpu acceleration! You can try the following codes out to verify if the installation is sucessful.
python
import pytorch
print(torch.__version__) # print the version of your pytorch
print(torch.cuda.is_available())
If your result is the same as mine, congratulations!
5 Install Norse and Verify
5.1 Install Norse
Use the following commands to install.
pip install norse
After that, open anaconda navigator and switch to the new virtual environment you have created as shown below,
and download the JupyterNotebook and Spyder. Then, open one of the two IDEs and verify if you have successfully installed Norse as below:
import torch
import norse.torch as norse
cell = norse.LIFCell()
data = torch.ones(1)
spikes, state = cell(data) # First run is done without any state
# ...
spikes, state = cell(data, state) # Now we pass in the previous state
And if no warning occurs, then the norse is installed successfully! Cheers!
Please hesitate to contact me by the email: sh201@hw.ac.uk if any problem occurred!