windows10 python 使用dlib cuda 编译和安装

1.如果之前安装了dlib,先卸载dlib, pip uninstall dlib
2.安装CUDA
3 安装CUDNN

2和3安装完之后,环境变量会自动生成

CUDA下载: https://developer.nvidia.com/cuda-downloads
CUDNN下载: https://developer.nvidia.com/rdp/cudnn-download
注意:后者下载要注册英伟达开发帐号才可下载
并用后者是一个lib包,下载后放相应的位置即可
参考: https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#install-windows

4.3. Installing cuDNN on Windows
The following steps describe how to build a cuDNN dependent program. 
In the following sections the CUDA v9.0 is used as example:
your CUDA directory path is referred to as C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0
your cuDNN directory path is referred to as <installpath>
Navigate to your <installpath> directory containing cuDNN.
Unzip the cuDNN package.
cudnn-9.0-windows7-x64-v7.zip
or
cudnn-9.0-windows10-x64-v7.zip
Copy the following files into the CUDA Toolkit directory.
Copy <installpath>\cuda\bin\cudnn64_7.dll 
	to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin.
Copy <installpath>\cuda\ include\cudnn.h 
	to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include.
Copy <installpath>\cuda\lib\x64\cudnn.lib 
	to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\lib\x64.
Set the following environment variables to point to where cuDNN is located. 
To access the value of the $(CUDA_PATH) environment variable, perform the following steps:
Open a command prompt from the Start menu.
Type Run and hit Enter.
Issue the control sysdm.cpl command.
Select the Advanced tab at the top of the window.
Click Environment Variables at the bottom of the window.
Ensure the following values are set:
Variable Name: CUDA_PATH 
Variable Value: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0
Include cudnn.lib in your Visual Studio project.
Open the Visual Studio project and right-click on the project name.
Click Linker > Input > Additional Dependencies.
Add cudnn.lib and click OK.

主要看这三句,官网上的为旧版本的v9.0,我们到自己相应的最新的版本目录即可:

Copy <installpath>\cuda\bin\cudnn64_7.dll 
	to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin.
Copy <installpath>\cuda\ include\cudnn.h 
	to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include.
Copy <installpath>\cuda\lib\x64\cudnn.lib 
	to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\lib\x64.

然后

cmd进入到C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\extras\demo_suite

运行:bandwidthTest.exe

Result=PASS

运行:deviceQuery.exe

Result=PASS

结果都显示pass,就是配置成功。

4.下载dlib:http://dlib.net/

解压后cmd进入到dlib安装文件夹,执行:

// 新版本的正确安装,其在安装时会自动检查你电脑有没有安装CUDA
python setup.py install 

好多的教程中是

// 错误安装会报错,带这种选项的做法已被取消
python setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA

python里重新调用dlib,即可实现GPU加速。

PS:python里测试dlib有没有使用GPU加速

E:\AI\dlib-19.17>python
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import dlib
>>> print(dlib.DLIB_USE_CUDA)
True
>>> print(dlib.cuda.get_num_devices())
1
>>>

参考:https://blog.csdn.net/luckyfairy17/article/details/83855739

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 9
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值