compile dlib with cuda

ぃ、小莉子 提交于 2020-12-06 23:18:12

问题


I am trying to compile dlib with cuda. I clone the repository from this GitHub link https://github.com/davisking/dlib and then tried to run

python setup.py install --yes USE_AVX_INSTRUCTIONS

But I receive an error. Can anyone help me to solve it?


回答1:


Create a folder for host the source

mkdir -p /opt/SP/packages/
cd $_

Clone the repository

git clone https://github.com/davisking/dlib.git
cd dlib
git submodule init
git submodule update

Create a folder for build the software (cmake have to be installed)

mkdir build
cd $_

Now run cmake with the following options:

cmake  -D DLIB_USE_CUDA=1 -D USE_AVX_INSTRUCTIONS=1 ../

If everything is fine, you can see a similar output

NOTE: Install cuDNN, openblas and Intel MKL/BLAS/LAPACK if your system is compliant with them.

Link to Intel Performance Library: https://software.seek.intel.com/performance-libraries

Link to cuDNN: https://developer.nvidia.com/cudnn

Now you can compile the source with

cmake --build . --config Release

After these step, the source is compiled.

Now you can install the python API.

cd ../
python setup.py install

NOTE: The compilation this time will use all the available CPU, be sure that you have enough memory for compile.

Once completed, you can query your python packages for be sure that dlib is now installed:

pip freeze | grep dlib

For check if the installation was succesfully:

Open a terminal and run the following

>>> import dlib.cuda as cuda;
>>> print(cuda.get_num_devices());
1
>>> import dlib
>>> dlib.DLIB_USE_BLAS
True
>>> dlib.DLIB_USE_CUDA
True
>>> dlib.DLIB_USE_LAPACK
True



回答2:


Steps which you should take care, note that the solution I am giving here is general. It will work with all the users. Download latest version of dlib from official site (current is dlib 19.15).

  1. Check your Ubuntu/Mint version. If you are using bionic then you should download cuda10 and cudnn for cuda 10. Artful and Xenial can go with cuda 9.
  2. Install the latest version of CMake i.e. 3.12.x (current). Otherwise you may get some errors like

    CUDA_cublas_device_LIBRARY (ADVANCED) " etc.

  3. If you want to install dlib with cuda support in python2 then the command is:

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

    and for python3 the command is:

    sudo python3 setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA 
    
  4. You may get an error like python.h not found. So for that you can use the following commands :

    sudo apt-get install python3-dev or sudo apt-get install python2-dev  
    
    sudo apt-get install libpython2.7-dev python-numpy
    
  5. Success!!!

If you are working on Anaconda then just copy the content of

/usr/local/lib/python3.6/dist-packages

and paste it in

/home/Your_computer's_name/anaconda3/lib/python3.6/site-packages

BOOM! You are good to go!



来源:https://stackoverflow.com/questions/49731346/compile-dlib-with-cuda

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