caffe-windows gpu安装

环境:win10, vs2015

准备:

首先呢准备cuda, cuDNN, caffe-windows源码,cmake, python等工具

事先声明下,请详细阅读gitbub的caffe-windows的Readme,别瞎搞。嗯。。。

安装他要求的cuda8.0和cuDNN v5谢谢。你就会少踩坑。

下载地址:

caffe_windows源码:https://github.com/BVLC/caffe/tree/windows

cuda8.0:https://developer.nvidia.com/cuda-80-ga2-download-archive

cuDNN v5:https://developer.nvidia.com/rdp/cudnn-archive 里面的 Download cuDNN v5 (May 27, 2016), for CUDA 8.0

cmake: https://cmake.org/download/ 找到.msi后缀的 cmake-3.15.2-win64-x64.msi

python: 3.5版本的或者2.7 我是装3.5的

caffe的依赖包:libraries_v140_x64_py35_1.1.0

自己去下放在C:\用户\.....\.caffe\dependencies

然后你就开始装。。。这是一个漫长的过程。

多补充一句:

安装cuda的时候默认路径是 什么Data/tmp下,你修改成NVIDIA GPU Computing Toolkit也比较好认。

检测匹配的时候会提示你跟显卡不匹配(一堆英文),无视他就行。

安装完cuda后 运行cmd,nvcc -V看下是否版本是8.0

 

配置:

caffe-windows\scripts 文件夹下有build_win.cmd 用编辑器打开,改一些东西。

MSVC_VERSION=14  (vs2015)

WITH_NINJA=0 (我们是用cmake)

PYTHON_VERSION=3

RUN_INSTALL=1

else (
    :: 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=14
    :: 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=Auto
    :: 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=3
    :: 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
)

添加一个-DCUDNN_ROOT=你cuDNN的路径

:: 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=D:\build_lib\cuda ^
      "%~dp0\.."

编译:

将build_win.cmd在cmd里打开,运行。

生成的vs工程就是当前cmd的路径。

生成:

分别生成ALL_BUILD的Debug和Release版本。

测试:

生成测试文件:

caffe-windows\data\mnist运行get_mnist.sh

wget报错:下载wget包,将路径添加到环境变量Path

运行成功后生成:

在caffe-windows\examples\mnist找到create_mnist.sh不能直接运行。

前面生成的convert_mnist_data.exe不是bin后缀

将4个数据复制到\build\examples\mnist\Release文件夹内

打开cmd切换成该路径:运行

convert_mnist_data.exe train-images-idx3-ubyte train-labels-idx1-ubyte mnist_train_lmdb --backend=lmdb
convert_mnist_data.exe t10k-images-idx3-ubyte t10k-labels-idx1-ubyte mnist_test_lmdb --backend=lmdb

生成两个文件。

修改配置参数:

修改caffe-windows\examples\mnist 里的lenet_train_test.prototxt

将2个source的路径改成据对路径

和lenet_solver.prototxt的2个source的路径改成据对路径

添加caffe.exe到环境变量。

执行

caffe.exe train --solver=caffe-windows\examples\mnist\lenet_solver.prototxt

训练结果:

大功告成。。。

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值