-
Star
(231)
You must be signed in to star a gist -
Fork
(87)
You must be signed in to fork a gist
-
-
Save MihailCosmin/affa6b1b71b43787e9228c25fe15aeba to your computer and use it in GitHub Desktop.
| #!/bin/bash | |
| ### steps #### | |
| # verify the system has a cuda-capable gpu | |
| # download and install the nvidia cuda toolkit and cudnn | |
| # setup environmental variables | |
| # verify the installation | |
| ### | |
| ### to verify your gpu is cuda enable check | |
| lspci | grep -i nvidia | |
| ### If you have previous installation remove it first. | |
| sudo apt purge nvidia* -y | |
| sudo apt remove nvidia-* -y | |
| sudo rm /etc/apt/sources.list.d/cuda* | |
| sudo apt autoremove -y && sudo apt autoclean -y | |
| sudo rm -rf /usr/local/cuda* | |
| # system update | |
| sudo apt update && sudo apt upgrade -y | |
| # install other import packages | |
| sudo apt install g++ freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev | |
| # first get the PPA repository driver | |
| sudo add-apt-repository ppa:graphics-drivers/ppa | |
| sudo apt update | |
| # find recommended driver versions for you | |
| ubuntu-drivers devices | |
| # install nvidia driver with dependencies | |
| sudo apt install libnvidia-common-515 libnvidia-gl-515 nvidia-driver-515 -y | |
| # reboot | |
| sudo reboot now | |
| # verify that the following command works | |
| nvidia-smi | |
| sudo wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin | |
| sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600 | |
| sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub | |
| sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ /" | |
| # Update and upgrade | |
| sudo apt update && sudo apt upgrade -y | |
| # installing CUDA-11.8 | |
| sudo apt install cuda-11-8 -y | |
| # setup your paths | |
| echo 'export PATH=/usr/local/cuda-11.8/bin:$PATH' >> ~/.bashrc | |
| echo 'export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc | |
| source ~/.bashrc | |
| sudo ldconfig | |
| # install cuDNN v11.8 | |
| # First register here: https://developer.nvidia.com/developer-program/signup | |
| CUDNN_TAR_FILE="cudnn-linux-x86_64-8.7.0.84_cuda11-archive.tar.xz" | |
| sudo wget https://developer.download.nvidia.com/compute/redist/cudnn/v8.7.0/local_installers/11.8/cudnn-linux-x86_64-8.7.0.84_cuda11-archive.tar.xz | |
| sudo tar -xvf ${CUDNN_TAR_FILE} | |
| sudo mv cudnn-linux-x86_64-8.7.0.84_cuda11-archive cuda | |
| # copy the following files into the cuda toolkit directory. | |
| sudo cp -P cuda/include/cudnn.h /usr/local/cuda-11.8/include | |
| sudo cp -P cuda/lib/libcudnn* /usr/local/cuda-11.8/lib64/ | |
| sudo chmod a+r /usr/local/cuda-11.8/lib64/libcudnn* | |
| # Finally, to verify the installation, check | |
| nvidia-smi | |
| nvcc -V | |
| # install Pytorch (an open source machine learning framework) | |
| pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 |
@MihailCosmin This is absolutely amazing! You saved my day! I don't understand why Nvidia can't make the installation of their products simple and straightforward. All their instructions on the site led me to a bunch of errors and incompatibilities.
Thanks for your work. Really helpful
Thank you, you saved my as!
For NVIDIA 50 Series 5060 - 5060 Ti - 5070 - 5070 Ti only the open versions of the drivers are supported.
When you install CUDA Toolkit via sudo apt install cuda-11-8 -y, it will also install the latest non-open driver which will conflict your driver installation. I edited the suggestion to be compatible with RTX 50 series:
GPU Driver - CUDA - cuDNN
Install the GPU Drivers
sudo apt purge nvidia* -y
sudo apt remove nvidia-* -y
sudo rm /etc/apt/sources.list.d/cuda*
sudo apt autoremove -y && sudo apt autoclean -y
sudo rm -rf /usr/local/cuda*
sudo apt update && sudo apt upgrade -y
sudo apt install g++ freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
ubuntu-drivers devices
sudo apt install libnvidia-common-@@@ libnvidia-gl-@@@ nvidia-driver-@@@-open -y
I used 575 for my GPU.
sudo reboot now
Verify Driver Installation
nvidia-smi
Install CUDA Toolkit
wget https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run
sudo sh cuda_11.8.0_520.61.05_linux.run --toolkit --silent --override
Add CUDA Environment Variables
echo 'export PATH=/usr/local/cuda-11.8/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc
Download cuDNN
wget https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-x86_64/cudnn-linux-x86_64-8.8.1.3_cuda11-archive.tar.xz
sudo tar -xvf cudnn-linux-x86_64-8.8.1.3_cuda11-archive.tar.xz
sudo mv cudnn-linux-x86_64-8.8.1.3_cuda11-archive cuda
Put cuDNN into CUDA files
sudo cp -P cuda/include/cudnn.h /usr/local/cuda-11.8/include
sudo cp -P cuda/lib/libcudnn* /usr/local/cuda-11.8/lib64/
sudo chmod a+r /usr/local/cuda-11.8/lib64/libcudnn*
I hope this helps let me know if you are having any troubles.
For NVIDIA 50 Series 5060 - 5060 Ti - 5070 - 5070 Ti only the open versions of the drivers are supported.
When you install CUDA Toolkit via
sudo apt install cuda-11-8 -y, it will also install the latest non-open driver which will conflict your driver installation. I edited the suggestion to be compatible with RTX 50 series:GPU Driver - CUDA - cuDNN
Install the GPU Drivers
sudo apt purge nvidia* -y
sudo apt remove nvidia-* -y
sudo rm /etc/apt/sources.list.d/cuda*
sudo apt autoremove -y && sudo apt autoclean -y
sudo rm -rf /usr/local/cuda*
sudo apt update && sudo apt upgrade -y
sudo apt install g++ freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
ubuntu-drivers devices
sudo apt install libnvidia-common-@@@ libnvidia-gl-@@@ nvidia-driver-@@@-open -yI used 575 for my GPU.
sudo reboot nowVerify Driver Installation
nvidia-smiInstall CUDA Toolkit
wget https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run
sudo sh cuda_11.8.0_520.61.05_linux.run --toolkit --silent --overrideAdd CUDA Environment Variables
echo 'export PATH=/usr/local/cuda-11.8/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrcDownload cuDNN
wget https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-x86_64/cudnn-linux-x86_64-8.8.1.3_cuda11-archive.tar.xz
sudo tar -xvf cudnn-linux-x86_64-8.8.1.3_cuda11-archive.tar.xz
sudo mv cudnn-linux-x86_64-8.8.1.3_cuda11-archive cudaPut cuDNN into CUDA files
sudo cp -P cuda/include/cudnn.h /usr/local/cuda-11.8/include
sudo cp -P cuda/lib/libcudnn* /usr/local/cuda-11.8/lib64/
sudo chmod a+r /usr/local/cuda-11.8/lib64/libcudnn*I hope this helps let me know if you are having any troubles.
It worked with RTX 3090 on Ubuntu 22.04. Thanks, bro!
@MihailCosmin Thank you ! I have successfully installed Cudatoolkit11.8 by following these steps. This was really very helpful