问题
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).
- 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.
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.
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
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
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