GPU + windows 10 + vs2013 + caffe configuration framework environment cuda7.5

        Caffe recent study framework, read a few blog to learn and simple application environment to build, encountered some pit period, then write it down, then later, it is hoped that we learn together. Man of few words said, the whole beginning.

 

       1, first of all, we need to install VS2013 (if equipped with cuda7.5, I suggest vs2013. VS2015 also saw a big brother to say OK, but not pro-test, may themselves too slag). Official Download attach: http://download.microsoft.com/download/9/3/E/93EA27FF-DB02-4822-8771-DCA0238957E9/vs2013.5_ult_chs.iso?type=ISO           image file has 5.1G, suggestions Do not put the c drive. Also attach VS2015 (and 2013) https://pan.baidu.com/s/1YrMG-7I3maljvDr4mEmsgw   Password: kkxs
 
      2, then, we need to download cuda7.5. Attach the official Download: https://developer.nvidia.com/cuda-75-downloads-archive

 

Nvida suggest that right-click to select Control Panel -> System Information -> Components, find NVACUDA.DLL view the highest version of CUDA own graphics support.

 As long as higher than CUDA version 7.5, you can schedule on.

Mounting the CUDA basically fool-operation. It recommended installation path directly into the C drive. When I install CUDA, suggesting no graphics driver, this time is recommended to download the driver wizard, check the computer-driven, mounted on the bin. Long installation process, recommends a cup of tea.

3、CUDA安排上以后,建议安装CUDNN(GPU加速)。cudaa下载地址附上:https://developer.nvidia.com/cudnn  下载需要注册账号,这个就不必多说,用别人的东西,总要遵循别人的规矩。下载时注意对应版本就行。

下载完成并解压,发现其下有三个文件夹:,将里面的内容分别复制到:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5(CUDA  安装路径)下面对应的bin、include、lib文件夹中去。

 

 

以上三个文件分别属于CUDNN的bin、include、lib。

 4、下载caffe源码并编译

caffe源码下载地址:https://pan.baidu.com/s/1NZikoUqXP7RhBe-oU8txcw 密码:0pr6

下载完成以后解压caffe-master。进入caffe-master-->windows-->  将该文件下的CommonSettings.props.example复制到当前目录,并修改名称及后缀(.props).如图所示:

用vs2013打开当前目录下的caffe。 

 打开默认在libcaffe下,进入libcaffe的属性(右键单击,选择属性)设置如图所示:

然后对libcaffe进行编译,此过程耗时巨长,它会下载一些依赖包,保存在caffe-master同级目录下。建议喝杯茶再回来看。

 

生成的文件名:NugetPackages。其子目录下有如下依赖包:

同时,编译成功以后有caffe-master\Build\x64\Debug 这样一个文件目录存在,内容如图所示:

接下来我们编译caffe。操作流程如libcaffe一样。成功以后,,在caffe-master\Build\x64\Debug 下会增加一下几项:

这个时候caffe的环境基本搭建好了。现在我们可以使用经典的mnist数据集来测试一下caffe框架。 

5、测试安排一下。

附上mnist数据集下载链接:https://pan.baidu.com/s/1BS8Ilp3o2q88nP0fYlfcBg  密码:vfdw

也可以直接去官网下载:http://yann.lecun.com/exdb/mnist/

其数据集有四个,两部分(train、test)。

将四个压缩包解压。最好新建两个文件夹test、train来分别存放数据集t10k和train。

首先我们需要将下载的数据集格式转化为lmdb,所以,此时我们需要编译一下刚刚用vs打开的caffe项目里面的convert_mnist_data。操作步骤跟前面两个一样。编译成功以后在 caffe-master\Build\x64\Debug 下生成

 接着,我们就开始写脚本文件,来进行数据格式转化了。新建一个文本文档。写入内容如下:

 

.\caffe-master\Build\x64\Debug\convert_mnist_data.exe .\caffe-master\data\mnist\mnist-train\train-images.idx3-ubyte .\caffe-master\data\mnist\mnist-train\train-labels.idx1-ubyte .\caffe-master\data\mnist\mnist-train-lmdb
echo.
.\caffe-master\Build\x64\Debug\convert_mnist_data.exe .\caffe-master\data\mnist\mnist-test\t10k-images.idx3-ubyte .\caffe-master\data\mnist\mnist-test\t10k-labels.idx1-ubyte .\caffe-master\data\mnist\mnist-test-lmdb
pause

第一行的意思是用convert_mnist_data.exe应用程序,将train-images.idx3-ubyte、train-images.idx3-ubyte数据集转换成lmdb格式。并存放在caffe-master\data\mnist\mnist-train-lmdb文件夹下。注意,这个mnist-train-lmdb文件夹是我们格式转换时,系统生成的,不是我们去创建的。第三行同理。echo.  与pause 一定要换行写。不然会出现闪退。以上路径是本人电脑上面的,每个人文件保存的路径肯定不一样。所以,要小心。哈哈哈哈。写好以后,点击另存为,修改后缀名为(.bat)如图所示:

运行成功以后,

接着我们打开 D:\Caffe\caffe-master\examples\mnist下的:

 修改以下三处:

solver_mode:GPU 、另外两个根据自己放置的路径来写。

然后,我们再修改lenet_train_test.prototxt:

 

 填入自己训练集及测试集的路径。

修改完毕以后。我们再写一个脚本文件train_mnist.bat  内容如下:

.\caffe-master\Build\x64\Debug\caffe.exe train --solver=.\caffe-master\examples\mnist\lenet_solver.prototxt
pause

前面是caffe这个应用程序的路径,后面是lenet_solver.prototxt文件的路径。写好以后,执行该脚本文件。

若不出意外,模型就训练起来了。这是我训练以后的效果图:

有的电脑配置太低,可能会出先显存不够的问题,这个时候需要去源码中设置,禁用gpu加速。好了,先写到这里。

 

发布了10 篇原创文章 · 获赞 21 · 访问量 2608

Guess you like

Origin blog.csdn.net/mr_qin_hh/article/details/84351548