dlib not using CUDA

房东的猫 提交于 2019-12-24 00:23:36

问题


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. ?


回答1:


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.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/51943050/dlib-not-using-cuda

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!