-
Notifications
You must be signed in to change notification settings - Fork 1
Nvidia CUDA and CUDNN installation for Libtorch
The correct versions of Pytorch, torchvision and cuda are needed to get the object detection/segmentation working. Take a look at the latest Pytorch or the older versions and install accordingly. The easiest option would be to install using conda. The correct cuda version should be installed. This means if you used conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
, then the version of cuda installed should be 11.7
. Download the same from here
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/11.7.0/local_installers/cuda-repo-ubuntu1804-11-7-local_11.7.0-515.43.04-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1804-11-7-local_11.7.0-515.43.04-1_amd64.deb
sudo cp /var/cuda-repo-ubuntu1804-11-7-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cuda ## this could be sudo apt-get install cuda-11-7
CUDAVER=cuda-11.7
export PATH=/usr/local/$CUDAVER/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/$CUDAVER/lib64:$LD_LIBRARY_PATH
export CUDA_HOME=/usr/local/$CUDAVER
The above is required so that nvcc --version
shows the correct cuda installation
- Reboot the computer.
This .deb
file is installed and it should produce a /usr/local/cuda11.7/
folder. Then the CMakeLists.txt will be like
set(CMAKE_CUDA_COMPILER /usr/local/cuda-11.7/bin/nvcc)
project(object_detection LANGUAGES CXX CUDA)
enable_language(CUDA)
Download the cudnn
library,
more instructions
Follow the debian
installation from here or the tar
installation as below
The downloaded file will be like cudnn-linux-x86_64-8.x.x.x_cudaX.Y-archive.tar.xz
which can be used to identify x and y
Enable the local repository.
sudo dpkg -i cudnn-local-repo-${OS}-8.x.x.x_1.0-1_amd64.deb
Or
sudo dpkg -i cudnn-local-repo-${OS}-8.x.x.x_1.0-1_arm64.deb
Import the CUDA GPG key.
sudo cp /var/cudnn-local-repo-*/cudnn-local-*-keyring.gpg /usr/share/keyrings/
Refresh the repository metadata.
sudo apt-get update
Install the runtime library.
sudo apt-get install libcudnn8
Install the developer library.
sudo apt-get install libcudnn8-dev
Install the code samples and the cuDNN library documentation.
sudo apt-get install libcudnn8-samples
python3
>>> import tensorrt
>>>
Note: Might require sudo apt-get install nvidia-cuda-toolkit