一、准备
系统:win10
显卡:gtx1050Ti
前期的一些必要软件安装,包括python3.5、vs2015、git,
可参考:win10+vs2015编译caffe的cpu debug版本、部署https://blog.csdn.net/chris_zhangrx/article/details/79096015
gpu版 https://blog.csdn.net/Chris_zhangrx/article/details/83339684
二、安装
1、安装显卡驱动388.13-desktop-win10-64bit-international-whql.exe
官网下载
2、安装cuda_8.0.61_win10.exe,注意安装的时候要自定义安装,只选上cuda就好了,其他的不要安装,否则会将之前的显卡驱动覆盖掉,导致电脑黑屏。
官网下载
3、下载cudnn-8.0-windows10-x64-v5.1-zip后解压到 CUDA目录下
官网下载
三、编译
1、进入文件夹 D:\caffe,下载源码
git clone:git clone https://github.com/BVLC/caffe.git
如git下载缓慢,直接下载压缩包
2、进入caffe文件夹
cd caffe
3、切换分支
git checkout windows(直接下载压缩包跳过这步)
4、修改scripts\build_win.cmd ,高亮为修改内容
@echo off
@setlocal EnableDelayedExpansion
:: Default values
if DEFINED APPVEYOR (
echo Setting Appveyor defaults
if NOT DEFINED MSVC_VERSION set MSVC_VERSION=14
if NOT DEFINED WITH_NINJA set WITH_NINJA=1
if NOT DEFINED CPU_ONLY set CPU_ONLY=1
if NOT DEFINED CUDA_ARCH_NAME set CUDA_ARCH_NAME=Auto
if NOT DEFINED CMAKE_CONFIG set CMAKE_CONFIG=Release
if NOT DEFINED USE_NCCL set USE_NCCL=0
if NOT DEFINED CMAKE_BUILD_SHARED_LIBS set CMAKE_BUILD_SHARED_LIBS=0
if NOT DEFINED PYTHON_VERSION set PYTHON_VERSION=2
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 NOT DEFINED PYTHON_EXE set PYTHON_EXE=python
if NOT DEFINED RUN_TESTS set RUN_TESTS=1
if NOT DEFINED RUN_LINT set RUN_LINT=1
if NOT DEFINED RUN_INSTALL set RUN_INSTALL=1
:: Set python 2.7 with conda as the default python
if !PYTHON_VERSION! EQU 2 (
set CONDA_ROOT=C:\Miniconda-x64
)
:: Set python 3.5 with conda as the default python
if !PYTHON_VERSION! EQU 3 (
set CONDA_ROOT=C:\Miniconda35-x64
)
set PATH=!CONDA_ROOT!;!CONDA_ROOT!\Scripts;!CONDA_ROOT!\Library\bin;!PATH!
:: Check that we have the right python version
!PYTHON_EXE! --version
:: Add the required channels
conda config --add channels conda-forge
conda config --add channels willyd
:: Update conda
conda update conda -y
:: Download other required packages
conda install --yes cmake ninja numpy scipy protobuf==3.1.0 six scikit-image pyyaml pydotplus graphviz
if ERRORLEVEL 1 (
echo ERROR: Conda update or install failed
exit /b 1
)
:: Install cuda and disable tests if needed
if !WITH_CUDA! == 1 (
call %~dp0\appveyor\appveyor_install_cuda.cmd
set CPU_ONLY=0
set RUN_TESTS=0
set USE_NCCL=1
) else (
set CPU_ONLY