dlib not using CUDA
Asked Answered
I

3

5

I installed dlib using pip. my graphic card supports CUDA, but while running dlib, it is not using GPU.

Im working on ubuntu 18.04

Python 3.6.5 (default, Apr  1 2018, 05:46:30) 
[GCC 7.3.0] on linux
>>> import dlib
>>> dlib.DLIB_USE_CUDA
False

I have also installed the NVidia Cuda Compile driver but still it is not working.

nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Nov__3_21:07:56_CDT_2017
Cuda compilation tools, release 9.1, V9.1.85

Can anyone help me how to get it working. ?

Inflow answered 21/8, 2018 at 6:46 Comment(4)
I think that DLIB installed through pip does not use CUDA by default. You have to build DLIB from source to enable CUDA usage.Yellowhammer
That’s not right. Installing dlib via pip will use cuda if cuda is correctly installed.Jenine
You should reinstall with the command pip install -v dlib so you can see the messages it prints about what it’s doing and why. It will say why it’s not using cuda.Jenine
CUDA 9 does not support ubuntu 18, it only goes to 17.01 or below. I recommend a downgrade to 16.04. Or to wait for CUDA 10.Nest
M
8

I had similar issues, in my case I was missing the cuDNN library, which prevented dlib from compiling with CUDA instructions, although I had CUDA compiler and other drivers installed.

The next part is to download dlib from this repo.

Then run this command to install dlib with CUDA and AVX instructions, you do not need to manually compile it with CMake using make file:

python setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA

Important part now is to read the log, if the python can actually find CUDA, cuDNN and can use CUDA compiler to compile the test project. These are the important lines:

-- Found CUDA: /usr/local/cuda/bin/ (found suitable version "8.0", minimum required is "7.5")
-- Looking for cuDNN install...
-- Found cuDNN: /usr/local/cuda/lib64/libcudnn.so
-- Building a CUDA test project to see if your compiler is compatible with CUDA...

The second problem I was facing was related to CMake versions. The latest version had some known problems with cuda and dlib, so I had to install CMake 3.12.3 in order to make it work.

Marvelous answered 1/11, 2018 at 9:44 Comment(2)
Have you experienced any problems with Visual Studio? If not, what version it is yours and what version is you Cuda? For me it is failing to compile the Cuda tests so far, for me, hence the dlib cuda support and I need some help. For now I'm trying to do _cmake_extra_options = ["-G", "Visual Studio 15 2017", "-T", "host=x64"] on line 50 of setup.py.Geraldina
Running python setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA results in the following output message: The --yes options to dlib's setup.py don't do anything since all these options are on by default. So --yes has been removed. Do not give it to setup.py.Unique
S
2

There are 2 different problems leading to this as on Windows:

  1. You don't have a CUDA installation or cuDNN installation.

  2. You installed the above 2 libraries but didn't initialize environment variables. This is specially true for conda install of both libraries. Conda installs them but doesn't setup environment variables. Full point of conda is not to set them globally.

  3. This is something I'm unsure about but might fix. The name of environment variable is CUDA_PATH_xxxx and not CUDA_PATH as was given in installation instruction of Nvidia website.

Try the third one if first 2 corrections, didn't work. My CUDA version is 10.1 at the time.

Seline answered 18/6, 2019 at 16:52 Comment(0)
J
1

We had the exact same issue where the CUDA drivers were installed properly but the dlib.DLIB_USE_CUDA flag was 'False'.

Installing dlib via 'pip3 install -v dlib' shows that it was picking up a different version of the C++ compiler that is not compatible.

Installing Visual Studio 14 2015 solved this issue for us.

One thing to note is that we got the message that dlib WILL use cuda when we tried to install using the command 'python setup.py install' from the source code, but the dlib.DLIB_USE_CUDA flag was still set to False.

Joab answered 20/9, 2018 at 15:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.