Dlib 19.7 + VS2017
http://dlib.net/faq.html#Whyisdlibslow
Why can't I use the DNN module with Visual Studio?
You can, but you need to use Visual Studio 2015 Update 3 or newer since prior versions had bad C++11 support. To make this as confusing as possible, Microsoft has released multiple different versions of "Visual Studio 2015 Update 3". As of October 2016, the version available from the Microsoft web page has good enough C++11 support to compile the DNN tools in dlib. So make sure you have a version no older than October 2016.
However, as of this writing, the newest version of Visual Studio is Visual Studio 2017, which has WORSE C++11 support that Visual Studio 2015. In particular, if you try to use the DNN tooling in Visual Studio 2017 the compiler will just hang. So use Visual Studio 2015.
It should also be noted that not even Visual Studio 2015 has perfect C++11 support. Specifically, the larger and more complex imagenet and metric learning training examples don't compile in Visual Studio 2015.
編譯結果
PS D:\work\book\new Book\MachineLearn(DeepLearn)\OpenSourceFramework\dlib\dlib-master\examples\build> cmake -G "Visual Studio 14 2015 Win64" ..
-- The C compiler identification is MSVC 19.0.24215.1
-- The CXX compiler identification is MSVC 19.0.24215.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of void*
-- Check size of void* - done
-- Enabling SSE2 instructions
-- Searching for BLAS and LAPACK
-- Searching for BLAS and LAPACK
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- A library with BLAS API not found. Please specify library location.
-- LAPACK requires BLAS
-- Found CUDA: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.0 (found suitable version "9.0", minimum required is "7.5")
-- Looking for cuDNN install...
-- Found cuDNN: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.0/lib/x64/cudnn.lib
-- Building a CUDA test project to see if your compiler is compatible with CUDA...
-- Checking if you have the right version of cuDNN installed.
-- Enabling CUDA support for dlib. DLIB WILL USE CUDA
-- C++11 activated.
OpenCV not found, so we won't build the webcam_face_pose_ex example.
-- Configuring done
-- Generating done
-- Build files have been written to: D:/work/book/new Book/MachineLearn(DeepLearn)/OpenSourceFramework/dlib/dlib-master/examples/build
VS2015對C++11 的SFINAE 支持比較好。其他版本暫時沒有支持
https://github.com/davisking/dlib/issues/946
最新版本 把遞歸函數改成inline 放入頭文件,能節省 很多 RAM 占用率。
[20171201 UTC]
davisking commented 5 days ago
Someone discovered that disabling inlining of recursive functions in visual studio 2015 significantly improves the RAM usage and build times of the DNN examples. I pushed this change to github last night. So at least you can compile all the DNN examples with visual studio 2015 in reasonable time. VC2017 still has additional C++11 bugs that prevent it from working though.
在VS 2015 Update 3 中對SFINAE表達式的改進
https://blogs.msdn.microsoft.com/c/2016/06/16/在vs-2015-update-3-中對sfinae表達式的改進/
什么是SFINAE?
提醒一下,SFINAE是‘Substitution Failure Is Not An Error’的縮寫。其理念是當編譯器嘗試在重載解析時去特化一個函數模板,即使特化失敗,只要還有其他的有效對象就可以。C++11介紹了諸如像decltype和constexpr的功能,並且在模板參數推導和替換過程中有表達式更為普遍。C++標准委員會闡明了C++11中SFINAE表達式的規則。
=============20171204
https://github.com/davisking/dlib/issues/946
davisking commented 3 days ago
Sweet. I just tried it with the newest version of VS2017 and they all work now. Also, if you give -T host=x64 to cmake when generating the project it will use the 64bit toolchain. That allowed me to compile the examples that would otherwise cause VS to run out of RAM and crash.
So at this point it looks like the newest VS2017 works correctly for everything!
嗯,趕緊刪了VS2015