linux安装dlib-gpu版本 实录及大坑

默认安装好:

gcc   g++编译器 # cmake/gcc/g++ --version 查看版本

cuda

cudnn

cmake  # cmake --version

python

 

过程:

git clone https://github.com/davisking/dlib.gitcd dlib  #下载代码
mkdir build
cd build

#(注:-DDLIB_USE_CUDA=0不使用cuda,-DUSE_AVX_INSTRUCTIONS=1使用cpu的AVX加速)
cmake ..             或者cmake .. -DDLIB_USE_CUDA=1 -DUSE_AVX_INSTRUCTIONS=1
cmake --build .
cd ..
python setup.py install

# (网上版本更新后不用python setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA)

测试运行:

输出值为True表示安装成功。

python

import dlib
print(dlib.DLIB_USE_CUDA)
print(dlib.cuda.get_num_devices())a

bug大坑:

bug1:unsupported GNU version! gcc versions later than 6 are not supported!

原因:gcc g++     一般ubantu18.04系统自带版本为7,提示版本太高,降低版本。

解决方法:

sudo rm /usr/gcc     或者sudo rm /usr/local/cuda/bin/gcc      删除gcc
sudo rm /usr/g++    或者sudo rm /usr/local/cuda/bin/g++     删除g++
sudo apt install gcc-5 g++-5     重新安装
sudo ln -s /usr/bin/gcc-5 /usr/local/cuda/bin/gcc     或者sudo ln -s /usr/bin/gcc-5 /usr/bin/gcc
sudo ln -s /usr/bin/g++-5 /usr/local/cuda/bin/g++    或者sudo ln -s /usr/bin/g++-5 /usr/bin/g++

结果显示:Enabling CUDA support for dlib.  DLIB WILL USE CUDA

bug2:安装后找不到路径问题:

export CC=/user/gcc-5.exe
export CXX=/user/g++-5.exe

bug3:DLIB GUI SUPPORT DISABLED BECAUSE X11 DEVELOPMENT LIBRARIES NOT FOUND ***
 *** Make sure libx11-dev is installed if you want GUI support.            ***
 *** On Ubuntu run: sudo apt-get install libx11-dev    

解决方法:sudo apt-get install libx11-dev

bug4:-- *** CUDA was found but your compiler failed to compile a simple CUDA program so dlib isn't going to use CUDA.

原因:编译器问题,同bug1

bug5:Disabling CUDA support for dlib.  DLIB WILL NOT USE CUDA

原因:编译器问题,同bug1

bug6:*** No BLAS library found so using dlib's built in BLAS.  However, if you ***
 *** install an optimized BLAS such as OpenBLAS or the Intel MKL your code ***
 *** will run faster.  On Ubuntu you can install OpenBLAS by executing:    ***
 ***    sudo apt-get install libopenblas-dev liblapack-dev                 ***
 *** Or you can easily install OpenBLAS from source by downloading the     ***
 *** source tar file from http://www.openblas.net, extracting it, and      ***
 *** running:                                                              ***
 ***    make; sudo make install 

原因:不用管

bug7: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.
原因:他的意思是不用加这些参数了,都是默认开启滴,直接python setup.py install

bug8:<module 'dlib' from '/home/chezhilong/anaconda3/lib/python3.6/site-packages/dlib-19.19.99-py3.6-linux-x86_64.egg/dlib.cpython-36m-x86_64-linux-gnu.so'>

原因:定位到出现错的代码行:cuda_dlib.cu(1762),即cuda_dlib.cu中的第1762行
1762行的内容如下:

解决方法:将std::log1p()函数替换为std::log1pf()函数后,问题解决了,之后一路绿灯。

bug8:安装完后,执行cmake --version会报如下错误

CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
/Applications/CMake 2.8-11.app/Contents/bin
CMake Error: Error executing cmake::LoadCache(). Aborting.

【解决方法】

先执行:hash -r

然后再执行:cmake --version

完美解决

 

 

 

 

  • 5
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值