RTX2080Ti Windows下 结合VS2013 利用build_cmd 编译Caffe带来的问题与解决策略
RTX2080Ti 具有计算能力7.5 ,需要CUDA10才能支持,官宣如下:
1.5.3. Applications Using CUDA Toolkit 10.0
With version 10.0 of the CUDA Toolkit, nvcc can generate cubin files native to the Turing architecture (compute capability 7.5). When using CUDA Toolkit 10.0, to ensure that nvcc will generate cubin files for all recent GPU architectures as well as a PTX version for forward compatibility with future GPU architectures, specify the appropriate -gencode= parameters on the nvcc command line as shown in the examples below.
下载并安装CUDA10
之前低版本的CUDA8.0卸载不干净,后来参考
https://blog.****.net/w670165403/article/details/81737139
https://blog.****.net/xgzxgzxgzxgzxgz/article/details/80634969 在安全模式下删除残余路径,彻底卸载了。
安装CUDA10,全盘失败,参考https://blog.****.net/hsqaihkl/article/details/80674912 安装成功
下载CUDA10对应的CUDNN
Download cuDNN v7.5.0 (Feb 21, 2019), for CUDA 10.0
https://developer.nvidia.com/rdp/cudnn-download
重新下载caffe
因为旧的编译无法检测到CUDA10,仍然说检测到CUDA8
建立路径D:\caffeWin,在cmd窗口下输入:
D:\caffeWin>git clone https://github.com/BVLC/caffe.git (如果没有安装git ,需要下载安装https://git-scm.com/download/win,设置环境变量,在path上增加 C:\Program Files\Git\bin)
Cloning into 'caffe'...
remote: Enumerating objects: 65066, done.
remote: Total 65066 (delta 0), reused 0 (delta 0), pack-reused 65066
Receiving objects: 100% (65066/65066), 72.61 MiB | 82.00 KiB/s, done.
Resolving deltas: 100% (41102/41102), done.
结束后目录下有文件夹caffe
输入命令
D:\caffeWin>cd caffe
D:\caffeWin\caffe>git checkout windows
编辑D:\caffeWin\caffe\scripts\build_win.cmd适应本机的编译环境
scripts/build_win.cmd 中相关参数的设定
:: Change the settings here to match your setup
:: Change MSVC_VERSION to 12 to use VS 2013
if NOT DEFINED MSVC_VERSION set MSVC_VERSION=12
:: Change to 1 to use Ninja generator (builds much faster)
if NOT DEFINED WITH_NINJA set WITH_NINJA=0
:: Change to 1 to build caffe without CUDA support
if NOT DEFINED CPU_ONLY set CPU_ONLY=0
:: Change to generate CUDA code for one of the following GPU architectures
:: [Fermi Kepler Maxwell Pascal All]
if NOT DEFINED CUDA_ARCH_NAME set CUDA_ARCH_NAME=All
:: Change to Debug to build Debug. This is only relevant for the Ninja generator the Visual Studio generator will generate both Debug and Release configs
if NOT DEFINED CMAKE_CONFIG set CMAKE_CONFIG=Release
:: Set to 1 to use NCCL
if NOT DEFINED USE_NCCL set USE_NCCL=0
:: Change to 1 to build a caffe.dll
if NOT DEFINED CMAKE_BUILD_SHARED_LIBS set CMAKE_BUILD_SHARED_LIBS=0
:: Change to 3 if using python 3.5 (only 2.7 and 3.5 are supported)
if NOT DEFINED PYTHON_VERSION set PYTHON_VERSION=2
:: Change these options for your needs.
if NOT DEFINED BUILD_PYTHON set BUILD_PYTHON=1
if NOT DEFINED BUILD_PYTHON_LAYER set BUILD_PYTHON_LAYER=1
if NOT DEFINED BUILD_MATLAB set BUILD_MATLAB=0
:: If python is on your path leave this alone
if NOT DEFINED PYTHON_EXE set PYTHON_EXE=python
:: Run the tests
if NOT DEFINED RUN_TESTS set RUN_TESTS=0
:: Run lint
if NOT DEFINED RUN_LINT set RUN_LINT=0
:: Build the install target
if NOT DEFINED RUN_INSTALL set RUN_INSTALL=1
build_win_debug.cmd 中相关参数的设定 与 build_win.cmd 中相关参数的设定基本一样,除了下面这一条
if NOT DEFINED CMAKE_CONFIG set CMAKE_CONFIG=Debug
设置RTX2080ti计算能力参数75
在D:\caffeWinNew\caffe\cmake目录下的Cuda.cmake中,增加RTX2080ti计算能力参数75,如下:
set(Caffe_known_gpu_archs "20 21(20) 30 35 50 60 61 75")
删除20 21(20) ,最终设置为:
set(Caffe_known_gpu_archs "30 35 50 60 61 75")
运行build_win、build_win_debug 分别编译 Release Debug版本,警告可忽略
编译caffe相关问题解决
fatal error C1017: invalid integer constant expression
C:\Users\chris\.caffe\dependencies\libraries_v140_x64_py27_1.1.0\libraries\include\boost-1_61\boost\config\compiler\nvcc.hpp's last three lines should be removed or commented:
#if !defined(__CUDACC_VER__) || (__CUDACC_VER__ < 70500) # define BOOST_NO_CXX11_VARIADIC_TEMPLATES #endif
设置环境变量,在path中增加D:\caffeWinNew\caffe\build\install\bin\
之后就可以利用编译好的Caffe 干活了。