Last active
May 6, 2022 11:37
-
-
Save simo23/5325f53df8f20723d4d9039c26256655 to your computer and use it in GitHub Desktop.
How to download and setup Pytorch, CUDA 9.0, cuDNN 7.0, Anaconda2 with or without sudo rights
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### How to download and setup Pytorch, CUDA 9.0, cuDNN 7.0, Anaconda2 with or without sudo rights | |
# Tested on Ubuntu 16.04, GPU support, pytorch 0.4.1, cuda 9.0, cuDNN 7.0, Anaconda2 version 5.2.0. If you want other versions small changes must be made. | |
# Note: you can install everything with or without sudo rights ( if you do not have sudo rights we will install everything locally ) | |
### Download and install CUDA 9.0 Toolkit | |
# Note: NVIDIA drivers can be also installed during the process (if you have the rights) | |
# Check that the version of your NVIDIA drivers is compatible with CUDA 9.0. If not you should install the drivers or change CUDA version. | |
# The default installation path is "/usr/local/cuda". You can install here ONLY if you have the rights to do that, otherwise you must install them somewhere else. You can create a folder where you want and then you MUST say to the installation process the path to the folder you created. Example: I create a folder in ~/nvidia_libraries/cuda-9.0/ so when the process will ask where to install the toolkit just say: "/home/nvidia_libraries/cuda-9.0/". | |
# When asked if you want to create a symbolic link say YES if you have installed them in /usr/local/cuda, NO otherwise | |
cd | |
cd Downloads | |
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run | |
# Note: if you have the NVIDIA drivers already installed it will ask to install them again or update them. If you don't want to do it select NO. Then select YES to install the NVIDIA toolkit. Then select NO when asked to install NVIDIA samples.) | |
# If you can use sudo: | |
sudo sh cuda_9.0.176_384.81_linux.run | |
# If you cannot use sudo: | |
cd | |
cd ~/ | |
mkdir nvidia_libraries | |
mkdir nvidia_libraries/cuda-9.0 | |
chmod +x cuda_9.0.176_384.81_linux.run | |
./cuda_9.0.176_384.81_linux.run | |
### Download and install cuDNN 7.0 ( required to run CUDA 9.0 ) | |
# Note: you have to create a profile on the NVIDIA website and then navigate to the download page of cuDNN (https://developer.nvidia.com/rdp/cudnn-archive) | |
- Download cuDNN 7.0 for linux by clicking on the link | |
# Assuming that the file is in ~/Downloads | |
cd | |
cd Downloads | |
tar -xzvf cudnn-9.0-linux-x64-v7.tgz | |
# If you have installed CUDA 9.0 in /usr/local/cuda | |
sudo cp cuda/include/cudnn.h /usr/local/cuda/include | |
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64 | |
sudo chmod a+r /usr/local/cuda/include/cudnn.h | |
# If you have installed CUDA 9.0 somewhere else and you do not have sudo rights ( I have it in /home/nvidia_libraries/cuda-9.0/ for example ) | |
cp cuda/include/cudnn.h /home/nvidia_libraries/cuda-9.0/include | |
cp cuda/lib64/libcudnn* /home/nvidia_libraries/cuda-9.0/lib64 | |
chmod a+r /home/nvidia_libraries/cuda-9.0/include/cudnn.h | |
### Set enviroment variables for CUDA libraries | |
nano ~/.bashrc | |
# Copy and paste the following lines at the bottom ( assuming that your CUDA libraries are in "/home/nvidia_libraries/cuda-9.0/" ) | |
export LD_LIBRARY_PATH="/home/nvidia_libraries/cuda-9.0/lib64:$LD_LIBRARY_PATH" | |
export PATH="/home/nvidia_libraries/cuda-9.0/bin:$PATH" | |
### Download and install Anaconda ( Anaconda2, version 5.2 here ) | |
cd | |
cd Downloads | |
wget https://repo.anaconda.com/archive/Anaconda2-5.2.0-Linux-x86_64.sh | |
bash ~/Downloads/Anaconda2-5.2.0-Linux-x86_64.sh | |
# Say no to install Microsoft stuff | |
# Close the terminal and open it again in order to make anaconda work | |
### Create conda environment ( here I call the environment "pytorch") | |
# You can define the version of python to use. I set 3.6 here | |
conda create --name pytorch python=3.6 | |
source activate pytorch | |
### Install pytorch ( latest version, now 0.4.1) | |
conda install pytorch torchvision -c pytorch | |
### Done! | |
# Close every terminal in order to make everything effective |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment