windows7 下编译 Microsoft的 caffe step by step

     一直以来想在windows下使用caffe,但是无果,虽然有牛志恒等有耐力有恒心的达人自己编译了caffe,可是在自己试验之后发现确实不适合我,只能默默的在自己并不是特别熟悉的ubuntu下边使用caffe做试验。可是有一天微软居然把自己编译的版本放到了github上,在存米买了块3t的硬盘后,我终于能够得偿所愿。我把自己的安装编译步骤分为以下几个简单的步骤,但是仍然是谢天谢地谢微软。

1 下载

无需多言,还是官方的git https://github.com/BVLC/caffe/tree/windows

2  装cuda 这个微软也给出了 地址

https://developer.nvidia.com/cuda-toolkit

3 下载cudnn

这个不用安装,直接解压缩到哪都行,后边配置下位置就好

https://developer.nvidia.com/cudnn

4 装python ,这里我装的是Anaconda 在d盘根目录

5 装matlab ,这里我装的是matlab 2015b

6 修改 caffe-master/windows下的CommonSettings.props 文件修改内容如下

修改点1:

<PropertyGroup Label="UserMacros">
        <BuildDir>$(SolutionDir)..\Build</BuildDir>
        <!--NOTE: CpuOnlyBuild and UseCuDNN flags can't be set at the same time.-->
        <CpuOnlyBuild>false</CpuOnlyBuild>
        <UseCuDNN>true</UseCuDNN>
        <CudaVersion>7.5</CudaVersion>
        <!-- NOTE: If Python support is enabled, PythonDir (below) needs to be
         set to the root of your Python installation. If your Python installation
         does not contain debug libraries, debug build will not work. -->
        <PythonSupport>true</PythonSupport>
        <!-- NOTE: If Matlab support is enabled, MatlabDir (below) needs to be
         set to the root of your Matlab installation. -->
        <MatlabSupport>true</MatlabSupport>
        <CudaDependencies></CudaDependencies>

        <!-- Set CUDA architecture suitable for your GPU.
         Setting proper architecture is important to mimize your run and compile time. -->
        <CudaArchitecture>compute_35,sm_35;compute_52,sm_52</CudaArchitecture>

        <!-- CuDNN 3 and 4 are supported -->
        <CuDnnPath>D:\cudnn-7.0-win-x64-v3.0-prod\</CuDnnPath>
        <ScriptsDir>$(SolutionDir)\scripts</ScriptsDir>
    </PropertyGroup>

修改点2:

 <PropertyGroup Condition="'$(PythonSupport)'=='true'">
        <PythonDir>D:\Anaconda2\</PythonDir>
        <LibraryPath>$(PythonDir)\libs;$(LibraryPath)</LibraryPath>
        <IncludePath>$(PythonDir)\include;$(IncludePath)</IncludePath>
    </PropertyGroup>

修改点3:

 <PropertyGroup Condition="'$(MatlabSupport)'=='true'">
        <MatlabDir>M:\Program Files\MATLAB\R2015b</MatlabDir>
        <LibraryPath>$(MatlabDir)\extern\lib\win64\microsoft;$(LibraryPath)</LibraryPath>
        <IncludePath>$(MatlabDir)\extern\include;$(IncludePath)</IncludePath>
    </PropertyGroup>

7 编译

OK ,剩下就是编译了。但是我发现NuGet在下载第一个boost时候就卡住了……速度超级慢,以至于我的vs2013显示无响应,但是没关系网上有牛人给出了类似办法,在这里http://blog.csdn.net/jq0123/article/details/50443237

我理解就是自己下载boost.1.59.0.nupkg,放到

你的目录的\NuGet\Cache下边


找不到的自己进vs2013这个位置,到

https://www.nuget.org/packages 自己搜你需要的包来解决问题,当然作为活雷锋我已经下载了给大家分享下


https://yunpan.cn/cBDrCtQ4nMH7v  访问密码 2881

非百度的云盘,抵制下百度,故意卡速度,除了直接挣钱,眼里就没别的。


编译等了1个小时后,发现报错了……眼前一片绿啊……发现是220错误,warning太严重了,于是搜了下,如下解决


注意把yes修改成no就行了,重新编译……又过了个把小时,

8 python和matlab的支持

O了 ,剩下要测试的就是python 和matlab的导入

主要看下两个remark,另外

Python

To build Caffe Python wrapper set PythonSupport to true in.\windows\CommonSettings.props.Download Miniconda 2.7 64-bit Windows installerfrom Miniconda website.Install for all users and add Python to PATH (through installer).

Run the following commands from elevated command prompt:

conda install --yes numpy scipy matplotlib scikit-image pip
pip install protobuf
Remark

After you have built solution with Python support, in order to use it you have to either:

  • set PythonPath environment variable to point to <caffe_root>\Build\x64\Release\pycaffe, or
  • copy folder <caffe_root>\Build\x64\Release\pycaffe\caffe under <python_root>\lib\site-packages.

Matlab

To build Caffe Matlab wrapper set MatlabSupport to true andMatlabDir to the root of your Matlab installation in .\windows\CommonSettings.props.

Remark

After you have built solution with Matlab support, in order to use it you have to:

  • add the generated matcaffe folder to Matlab search path, and
  • add <caffe_root>\Build\x64\Release to your system path.


官方写的很清楚了,先编译,而后设置路径就可以使用了,至此结束。

9 总结

真心觉得微软大法好,弄得这个nuget根本不需要配置,直接给你下好, 方便程度超过了ubuntu的 apt-get install,如果没有天朝的墙,你会更hi。









评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值