1. 程式人生 > >win10 + cuda8.0 + caffe SSD + vs2015 + python3

win10 + cuda8.0 + caffe SSD + vs2015 + python3

targe find tps 分享圖片 n! ner caffe 速度 https

一、下載

git clone https://github.com/runhang/caffe-ssd.git
cd caffe-ssd

1. 修改 build_win.cmd

    if !PYTHON_VERSION! EQU 2 (
        set CONDA_ROOT=C:\Anaconda2
    )
    :: Set python 3.5 with conda as the default python
    if !PYTHON_VERSION! EQU 3 (
        set CONDA_ROOT=C:\Anaconda2\envs\py3
    )

:: Configure using cmake and using the caffe-builder dependencies
:: Add -DCUDNN_ROOT=C:/Projects/caffe/cudnn-8.0-windows10-x64-v5.1/cuda ^
:: below to use cuDNN
cmake -G"!CMAKE_GENERATOR!" ^
      -DBLAS=Open ^
      -DCMAKE_BUILD_TYPE:STRING=%CMAKE_CONFIG% ^
      -DBUILD_SHARED_LIBS:BOOL=%CMAKE_BUILD_SHARED_LIBS% ^
      -DBUILD_python:BOOL=%BUILD_PYTHON% ^
      -DBUILD_python_layer:BOOL=%BUILD_PYTHON_LAYER% ^
      -DBUILD_matlab:BOOL=%BUILD_MATLAB% ^
      -DCPU_ONLY:BOOL=%CPU_ONLY% ^
      -DCOPY_PREREQUISITES:BOOL=1 ^
      -DINSTALL_PREREQUISITES:BOOL=1 ^
      -DUSE_NCCL:BOOL=!USE_NCCL! ^
      -DCUDA_ARCH_NAME:STRING=%CUDA_ARCH_NAME% ^
      -DCUDNN_ROOT=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\cuda ^
-C "D:\tyang\caffe-builder\build_v140_x64\libraries\caffe-builder-config.cmake" ^ "%~dp0\.."

(上面粉紅色部分就是第三方庫的文件位置,根據自己的位置改下,不加上這句的話默認在user/.caffe下)

2. 修改 download_prebuilt_dependencies.py

(v140, 3.6)

3. 修改 WindowsDownloadPrebuiltDependencies.cmake

set(DEPENDENCIES_VERSION 1.1.0)
set(DEPENDENCIES_NAME_1800_27 libraries_v120_x64_py27_${DEPENDENCIES_VERSION})
set(DEPENDENCIES_NAME_1900_27 libraries_v140_x64_py27_${DEPENDENCIES_VERSION})
set(DEPENDENCIES_NAME_1900_36 libraries_v140_x64_py35_${DEPENDENCIES_VERSION})

set(DEPENDENCIES_URL_BASE https:
//github.com/willyd/caffe-builder/releases/download) set(DEPENDENCIES_FILE_EXT .tar.bz2) set(DEPENDENCIES_URL_1800_27 "${DEPENDENCIES_URL_BASE}/v${DEPENDENCIES_VERSION}/${DEPENDENCIES_NAME_1800_27}${DEPENDENCIES_FILE_EXT}") set(DEPENDENCIES_SHA_1800_27 "ba833d86d19b162a04d68b09b06df5e0dad947d4") set(DEPENDENCIES_URL_1900_27 "${DEPENDENCIES_URL_BASE}/v${DEPENDENCIES_VERSION}/${DEPENDENCIES_NAME_1900_27}${DEPENDENCIES_FILE_EXT}") set(DEPENDENCIES_SHA_1900_27 "17eecb095bd3b0774a87a38624a77ce35e497cd2") set(DEPENDENCIES_URL_1900_36 "${DEPENDENCIES_URL_BASE}/v${DEPENDENCIES_VERSION}/${DEPENDENCIES_NAME_1900_35}${DEPENDENCIES_FILE_EXT}") set(DEPENDENCIES_SHA_1900_36 "f060403fd1a7448d866d27c0e5b7dced39c0a607")

                find_package(PythonInterp 3.6)

二、編譯第三方庫

(就是上面粉紅色部分得第三方庫)

git clone https://github.com/willyd/caffe-builder.git
cd caffe-builder
build_v140_x64.cmd

速度可能有點慢,而且要下載。。。技術分享圖片

三、Cmake 編譯

確保cmake在電腦環境目錄裏

scripts\build_win.cmd

過程中會報錯:libraries_v140_x64_py35_1.1.0.tar下載失敗

手動下載: 地址

然後重命名 .tar.bz2 放到 C:\Users\tyang\.caffe\dependencies\download

再試一次技術分享圖片

四、VS 編譯

上面編譯完會生成一個build文件夾,裏面就是VS工程了

用VS2015打開選擇Release生成ALL_BUILD

五、 Python接口

將 caffe-ssd\python\caffe 拷貝到 python所在\Lib\site-packages

win10 + cuda8.0 + caffe SSD + vs2015 + python3