I succeeded in installing dlib with CUDA and cuDNN enabled, so I recorded it as a memorandum. The installation method differs depending on the version of dlib, and CUDA may not be enabled even if you follow the article on the net. The installation method changes every time dlib is updated, so if it doesn't work, check dlib official How to compile. The following procedure is the installation method as of July 6, 2020
If you haven't installed both CUDA and cuDNN yet, install the two first.
##First install CUDA
$ sudo apt update -y
$ sudo apt upgrade -y
$ 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 http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb
$ sudo apt-key add /var/cuda-repo-10-2-local-10.2.89-440.33.01/7fa2af80.pub
$ sudo apt-get -y update
$ sudo apt-get -y install cuda
$ echo "export PATH=/usr/local/cuda-10.2/bin${PATH:+:${PATH}}" >> ~/.bashrc
$ echo "export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" >> ~/.bashrc
Reboot once here After starting, confirm that CUDA is installed with the following command
$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Wed_Oct_23_19:24:38_PDT_2019
Cuda compilation tools, release 10.2, V10.2.89
If you can confirm, CUDA installation is complete Then install cuDNN
#cuDNN installation
$ wget https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/libcudnn7_7.6.5.32-1+cuda10.2_amd64.deb
$ wget https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/libcudnn7-dev_7.6.5.32-1+cuda10.2_amd64.deb
$ sudo dpkg -i libcudnn7_7.6.5.32-1+cuda10.2_amd64.deb
$ sudo dpkg -i libcudnn7-dev_7.6.5.32-1+cuda10.2_amd64.deb
Reboot once here This completes the installation of CUDA and cuDNN.
$ sudo apt -y install cmake
Check dlib official and download the latest source code
$ wget http://dlib.net/files/dlib-19.20.tar.bz2
$ tar -jxvf dlib-19.20.tar.bz2
Install using setup.py in the dlib-19.20 folder dlib-19.20 does not need to be installed using the make command Also, there are many articles out there that you need to add the `` `-yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA``` option. In v.19.20, the yes option is obsolete and is enabled by default, so you no longer need to add the option.
$ cd dlib-19.20
$ python3 setup.py install
Make sure CUDA and cuDNN are enabled when setup.py is run. If the following message is not displayed, CUDA and cuDNN will be installed with disabled.
-- Found CUDA: /usr/local/cuda-10.2 (found suitable version "10.2", minimum required is "7.5")
-- Looking for cuDNN install...
-- Found cuDNN: /usr/lib/x86_64-linux-gnu/libcudnn.so
-- Building a CUDA test project to see if your compiler is compatible with CUDA...
-- Checking if you have the right version of cuDNN installed.
-- Enabling CUDA support for dlib. DLIB WILL USE CUDA
I also get a warning `` `No BLAS library found so using dlib's built in BLAS```, which can be ignored (maybe)
Start python in interactive mode, and if DLIB_USE_CUDA is True, it ends successfully If it is False here, CUDA and cuDNN are not applied and are installed.
$ python3
Python 3.7.6 (default, Jan 8 2020, 19:59:22)
Type "help", "copyright", "credits" or "license" for more information.
>>> import dlib
>>> dlib.DLIB_USE_CUDA
True
Recommended Posts