If you write a PyTorch extension utilarizing the GPU and you want to build a unit test using CMake for it you have to install several packages by yourself.
Test what CUDA is supported by your driver
nvidia-smi
Out output contains
Driver Version: 450.80.02 CUDA Version: 11.0
That's why we install all tools for CUDA 11 and try to match the driver version 450.
Go to https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=2004&target_type=runfilelocal and select your local settings.
Here we can download
wget https://developer.download.nvidia.com/compute/cuda/11.1.1/local_installers/cuda_11.1.1_455.32.00_linux.run
You need a Nvidia account to be download cudnn packages.
If so go to https://developer.nvidia.com/rdp/cudnn-download and download the cuDNN Runtime Library
as well as the cuDNN Developer Library
.
sudo ./cuda_11.0.3_450.51.06_linux.run
If they warn you that you have installed the driver already via your package mananger select continue
and unselect the driver on the next page.
Make sure you install the runtime before the developer package.
sudo dpkg -i libcudnn8_8.0.5.39-1+cuda11.0_amd64.deb
sudo dpkg -i libcudnn8-dev_8.0.5.39-1+cuda11.0_amd64.deb
pip3 install --user torch==1.7.0+cu110 torchvision==0.8.1+cu110 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
Add the symlink to your cuda installation.
sudo ln -s /usr/local/cuda-11.0/ /usr/local/cuda
Set the enviroment variables in you .zshrc
or .bashrc
:
PATH=$PATH:/usr/local/cuda/bin
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
CUDA_BIN_PATH=/usr/local/cuda/bin
export Torch_DIR=~/.local/lib/python3.8/site-packages/torch