Building dLib on Ubuntu 18.04 fails unless the compiler flag -DCUDA_HOST_COMPILER=/usr/bin/gcc-6 is used when compiling dLib and when creating the python bindings.
Possibly some documentation to let folks know that with Ubuntu 18.04, Cuda 9.0 and cuDNN 7.0 that this flag is necessary.
master@TheBeast:~/Downloads/dlib-19.15$ cd build
master@TheBeast:~/Downloads/dlib-19.15/build$ rm -rf *
master@TheBeast:~/Downloads/dlib-19.15/build$ cmake ..
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using CMake version: 3.10.2
-- Compiling dlib version: 19.15.0
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/lib/x86_64-linux-gnu/libX11.so
-- Looking for png_create_read_struct
-- Looking for png_create_read_struct - found
-- Looking for jpeg_read_header
-- Looking for jpeg_read_header - found
-- Searching for BLAS and LAPACK
-- Searching for BLAS and LAPACK
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1")
-- Checking for module 'cblas'
-- No package 'cblas' found
-- Checking for module 'lapack'
-- Found lapack, version 3.10.3
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of void*
-- Check size of void* - done
-- Found LAPACK library
-- Found ATLAS BLAS library
-- Looking for cblas_ddot
-- Looking for cblas_ddot - found
-- Looking for sgesv
-- Looking for sgesv - not found
-- Looking for sgesv_
-- Looking for sgesv_ - found
-- Found CUDA: /usr/local/cuda-9.0 (found suitable version "9.0", minimum required is "7.5")
-- Looking for cuDNN install...
-- Found cuDNN: /usr/local/cuda-9.0/lib64/libcudnn.so
-- Building a CUDA test project to see if your compiler is compatible with CUDA...
-- * CUDA was found but your compiler failed to compile a simple CUDA program so dlib isn't going to use CUDA.
-- The output of the failed CUDA test compile is shown below:
-- ** Change Dir: /home/master/Downloads/dlib-19.15/build/dlib/cuda_test_build
* Run Build Command:"/usr/bin/make"
[ 50%] Building NVCC (Device) object CMakeFiles/cuda_test.dir/cuda_test_generated_cuda_test.cu.o
In file included from /usr/local/cuda-9.0/include/host_config.h:50:0,
from /usr/local/cuda-9.0/include/cuda_runtime.h:78,
from
#error -- unsupported GNU version! gcc versions later than 6 are not supported!
^~~~~
CMake Error at cuda_test_generated_cuda_test.cu.o.cmake:215 (message):
Error generating
** /home/master/Downloads/dlib-19.15/build/dlib/cuda_test_build/CMakeFiles/cuda_test.dir//./cuda_test_generated_cuda_test.cu .o
* CMakeFiles/cuda_test.dir/build.make:63: recipe for target 'CMakeFiles/cuda_test.dir/cuda_test_generated_cuda_test.cu.o' fai led
make[2]: [CMakeFiles/cuda_test.dir/cuda_test_generated_cuda_test.cu.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/cuda_test.dir/all' failed
make[1]: [CMakeFiles/cuda_test.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: ** [all] Error 2
-- Found OpenMP_C: -fopenmp (found version "4.5")
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
-- Found OpenMP: TRUE (found version "4.5")
-- Disabling CUDA support for dlib. DLIB WILL NOT USE CUDA
-- C++11 activated.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/master/Downloads/dlib-19.15/build
cd Downloads/dlib-19.15/
cmake ..
And for the python bindings
cd ..
python setup.py install
The workaround for this is as follows:
How are you installing cuda? NVIDIA doesn't support ubuntu 18.04 officially yet. So any instructions like this would need to include documentation for how to install it as well.
Davis,
You are correct, it does not. But it seems people are succeeding using the 17.10 version. It really starts with installing 18.04 as that was tricky as my system needs to dual boot and I have 2-GPUs.
I used the alternative 18.04 server installer
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get install dkms build-essential
sudo apt-get update
sudo apt-get install nvidia-390
Pick a desktop manager and you are good to go
From the Nvidia web site:
a. Select Cuda toolkit
b. Legacy Releases
c. 9.0
d. Then select:
i. Linux
ii. x86_64
iii. Ubuntu
iv. 17.04
v. runfile (local)
vi. Download the base installer and patches
chmod +x cuda_9.0.176_384.81_linux-run
sudo ./cuda_9.0.176_384.81_linux-run –override
Answer the installation questions:
a. You are attempting to install on an unsupported configuration. Do you wish to continue? y
b. Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81? n
c. Install the CUDA 9.0 Toolkit? y
Do the same for the patch files
echo 'export PATH=/usr/local/cuda-9.0/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc
From the Nvidia website down load cnDNN 7.0.5 (https://developer.nvidia.com/rdp/cudnn-archive)
I pulled the cuDNN v7.0.5 Library for Linux, cuDNN v7.0.5 Runtime Library for Ubuntu16.04 (Deb) and cuDNN v7.0.5 Developer Library for Ubuntu16.04 (Deb)
untar the files
sudo cp -P cuda/include/cudnn.h /usr/local/cuda-9.0/include
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda-9.0/lib64/
sudo chmod a+r /usr/local/cuda-9.0/lib64/libcudnn*
Download and install OpenCV. Follow step #5 at https://www.pyimagesearch.com/2017/09/27/setting-up-ubuntu-16-04-cuda-gpu-for-deep-learning-with-python/#comment-473251
a. I added WITH_CUDA=ON
Download dLib 19.15
cd to the dLib build directory
python3 setup.py --compiler-flags “-DCUDA_HOST_COMPILER=usr/bin/gcc-6” install
And that is how I got to where I am today.
Best Regards / Mit freundlichen GrĂĽĂźen,
Doug
Cool, thanks for documenting the steps for using cuda in ubuntu 18.04.
Happy to help.
Best Regards / Mit freundlichen GrĂĽĂźen,
Doug
Most helpful comment
Davis,
You are correct, it does not. But it seems people are succeeding using the 17.10 version. It really starts with installing 18.04 as that was tricky as my system needs to dual boot and I have 2-GPUs.
I used the alternative 18.04 server installer
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get install dkms build-essential
sudo apt-get update
sudo apt-get install nvidia-390
Pick a desktop manager and you are good to go
From the Nvidia web site:
a. Select Cuda toolkit
b. Legacy Releases
c. 9.0
d. Then select:
chmod +x cuda_9.0.176_384.81_linux-run
sudo ./cuda_9.0.176_384.81_linux-run –override
Answer the installation questions:
a. You are attempting to install on an unsupported configuration. Do you wish to continue? y
b. Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81? n
c. Install the CUDA 9.0 Toolkit? y
Do the same for the patch files
echo 'export PATH=/usr/local/cuda-9.0/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc
From the Nvidia website down load cnDNN 7.0.5 (https://developer.nvidia.com/rdp/cudnn-archive)
I pulled the cuDNN v7.0.5 Library for Linux, cuDNN v7.0.5 Runtime Library for Ubuntu16.04 (Deb) and cuDNN v7.0.5 Developer Library for Ubuntu16.04 (Deb)
untar the files
sudo cp -P cuda/include/cudnn.h /usr/local/cuda-9.0/include
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda-9.0/lib64/
sudo chmod a+r /usr/local/cuda-9.0/lib64/libcudnn*
Download and install OpenCV. Follow step #5 at https://www.pyimagesearch.com/2017/09/27/setting-up-ubuntu-16-04-cuda-gpu-for-deep-learning-with-python/#comment-473251
a. I added WITH_CUDA=ON
Download dLib 19.15
cd to the dLib build directory
python3 setup.py --compiler-flags “-DCUDA_HOST_COMPILER=usr/bin/gcc-6” install
And that is how I got to where I am today.
Best Regards / Mit freundlichen GrĂĽĂźen,
Doug