【caffe源码研究】第一章:安装篇(中): Windows版

来源:互联网 发布:安卓微信语音导出软件 编辑:程序博客网 时间:2024/06/05 10:53

一、安装环境:

  1. Windows 64位
  2. Visual Studio 2013

下载微软编辑的caffe版本。

git clone https://github.com/Microsoft/caffe.git

照着README.txt安装就可以了。

二、配置

caffe\windows\CommonSettings.props.example复制一份叫做 caffe\windows\CommonSettings.props,也就是我们需要的配置文件,进行编辑配置。
主要配置的地方就两个,是使用 CPUOnly 模式还是使用GPU,是否编译python和matlab接口。基本都可以猜出来。

<ImportGroup Label="PropertySheets" />    <PropertyGroup Label="UserMacros">        <BuildDir>$(SolutionDir)..\Build</BuildDir>        <!--NOTE: CpuOnlyBuild and UseCuDNN flags can't be set at the same time.-->        <CpuOnlyBuild>true</CpuOnlyBuild>        <UseCuDNN>false</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>

如果启用了python和matlab接口,配置他们的路径。这里python建议使用Miniconda,一种比较容易管理包的python环境,使用64位。

<PropertyGroup Condition="'$(PythonSupport)'=='true'">        <PythonDir>D:\Miniconda2\</PythonDir>        <LibraryPath>$(PythonDir)\libs;$(LibraryPath)</LibraryPath>        <IncludePath>$(PythonDir)\include;$(IncludePath)</IncludePath>    </PropertyGroup>    <PropertyGroup Condition="'$(MatlabSupport)'=='true'">        <MatlabDir>D:\Program Files\MATLAB\R2013a</MatlabDir>        <LibraryPath>$(MatlabDir)\extern\lib\win64\microsoft;$(LibraryPath)</LibraryPath>        <IncludePath>$(MatlabDir)\extern\include;$(IncludePath)</IncludePath>    </PropertyGroup>

三、安装python库

cmd下运行

conda install --yes numpy scipy matplotlib scikit-image pippip install protobuf

在安装过程中可能经常卡住不动,强行关掉后提示已经有进程在运行。
最简单的方法是,写一个脚本 01_install.bat

D:\Miniconda2\Scripts\conda.exe clean --lockD:\Miniconda2\Scripts\conda.exe install --yes numpy scipy matplotlib scikit-image pipD:\Miniconda2\Scripts\pip install protobufpause

每次卡住不动了,就关掉cmd,再运行一次,直到全部安装好。

四、安装windows-caffe

打开caffe\windows下的Visual studio工程。项目调到released模式,生成解决方案。
可以看到出现
这里写图片描述

的提示窗口。这是这个项目在自动还原它所需要的各种依赖包。在caffe-microsoft的父目录里,会生成一个NugetPackages目录,装的就是各种依赖库。一切完成后,依赖库就准备好了。
然后程序会编译,进入漫长的等待,之后提示生成成功,就安装好了。

五、可能出现的错误

1. python位数不对

如果你遇到了下图的情况,或者在别的地方遇到了,说明你python位数不对,应该安装64位。
这里写图片描述

2. 警告被视为错误

警告被视为错误。Windows的这个项目很严格,凡是出现警告就会当成错误停止。
这里写图片描述
解决方法:选中将划线处改为否就好了。最好一口气把所有的项目全改过来。
这里写图片描述

3. 错误 68error MSB3030

错误 68error MSB3030: 无法复制文件“C:\Program Files (x86)\Microsoft VisualStudio12.0\VC\redist\Debug_NonRedist\x64\Microsoft.VC120.DebugCRT\msvcr120d.dll”,原因是找不到该文件。

这里写图片描述
我的Visual Studio装在D盘,在C盘里自然找不到。暂时没找到C:\Program Files (x86)\Microsoft Visual Studio 12.0\这个路径是在哪里配置的,找到的人改一下配置就好了。最简单粗暴的方式就是将
D:\Program Files (x86)\Microsoft Visual Studio12.0\VC\redist\x64\Microsoft.VC120.CRT
目录,在C盘下建立相同的路径,然后内容拷过去。
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\redist\x64\Microsoft.VC120.CRT\msvcr120.dll

0 0
原创粉丝点击