软件及环境:win10(64bit), vs2017, cuda9.1+cudnn7.0, cmake3.10.0, dlib19.13
安装步骤:
1. 到dlib的"example"目录下打开CMD命令
2. 依照官网次输入命令:
VS2017版本
cd examples
mkdir build
cd build
cmake -G "Visual Studio 15 2017 Win64" -T host=x64 ..
cmake --build . --config Release(可以不用这一步,这个只是帮你全编译,可以选择用vs编译一样的)
VS2015版本:
cd examples
mkdir build
cd build
cmake -G "Visual Studio 14 2015 Win64" -T host=x64 ..
cmake --build . --config Release(可以不用这一步,这个只是帮你全编译,可以选择用vs编译一样的)
3. 打开"build"文件夹下面的"example.sln"或"dlib.sln",编译并测试
遇到的问题:
官方说的是支持vs2015以及更新版本的VS
但是:在VS2015版本可以成功把cuda cmake进入dlib并能使用dnn功能,而vs2017则不会,cmake的提示信息:
-- ******************************************************************************************
-- Your version of Visual Studio has incomplete C++11 support and is unable to compile the
-- DNN examples. So we are disabling the deep learning tools. If you want to use the DNN
-- tools in dlib then update your copy of Visual Studio.
-- ******************************************************************************************
以及:
-- Found CUDA: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.2 (found suitable version "9.2", minimum required is "7.5")
-- *** Dlib CUDA support requires C++11 but your compiler doesn't support it. ***
-- Disabling CUDA support for dlib. DLIB WILL NOT USE CUDA
-- C++11 activated.
提示VS2017不支持C++11并且cdnn不会被使用。
通过各种途径,最终找到关键点:关键点
根据提示,只把set_compiler_specific_options.cmake的第34行里的1910版本改成其它的数字或是去掉就可以不执行这里的
操作(PS: 这里太简单粗暴了哈,不过也只有死马当活马医,最终刚好可以解决我们的问题,虽然并不能完全配置好dlib)
结果: 终于可以编译并运行dnn的大部分样例,不过也有少数比如dnn_metric_learning_on_images_ex项目编译就会一直
处于“卡死”的编译状态
现在就这样,如果以后需要再花时间继续解决吧
作者的回答:
Visual Studio 2017 seems to be buggier than Visual Studio 2015. Other people have reported problems. I haven't even successfully installed it. I tried half a dozen times to install VC2017 but the installer crashed every time at some random point. One of the times it took part of windows with it and I needed to restore some files before my desktop functioned correctly.
In any case, this isn't a dlib bug. You should report this to the visual studio dev team and maybe they will fix it. As of right now my recommendation is to avoid visual studio 2017.
2018.07.20更新:
据说最近的VS2017 15.5可以编译,但是不太支持CUDA, 早一点的版本又在C++11方面不太支持。
看来还需要进一步的协调吧