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 

https://developer.nvidia.com/cuda-10.0-download-archive?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exelocal

之前低版本的CUDA8.0卸載不乾淨,後來參考

https://blog.csdn.net/w670165403/article/details/81737139

https://blog.csdn.net/xgzxgzxgzxgzxgz/article/details/80634969 在安全模式下刪除殘餘路徑,徹底卸載了。

安裝CUDA10,全盤失敗,參考https://blog.csdn.net/hsqaihkl/article/details/80674912 安裝成功

下載CUDA10對應的CUDNN

Download cuDNN v7.5.0 (Feb 21, 2019), for CUDA 10.0

cuDNN Library for Windows 10

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 幹活了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章