caffe学习笔记:windows环境下caffe-window安装(CPU版)
2018-04-02 16:27
501 查看
配置:win7_64bit+VS2013
准备工作:下载微软官方提供的caffe安装包,下载地址:https://github.com/Microsoft/caffe,下载完毕解压到目标文件夹即可,笔者放置在E盘根目录中。
一、修改配置文件
打开E:\caffe-master\caffe-master\windows,找到CommonSettings.props.example文件复制(原文件作为备份)更改文件名为CommonSettings.props,该文件为caffe的配置文件(GPU/CPU、Python接口、Matlab接口均在该文件中进行配置),用VS打开并更改该文件内容如下,相关内容见注释。<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<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> //true为CPU版,false为GPU版
<UseCuDNN>false</UseCuDNN> //是否使用Cudnn加速,当CPU版时设置为false
<CudaVersion>7.5</CudaVersion> //Cuda版本设置
<!-- 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>false</PythonSupport> //是否支持Python,设置为true后面需设置相应Python安装路径
<!-- NOTE: If Matlab support is enabled, MatlabDir (below) needs to be
set to the root of your Matlab installation. -->
<MatlabSupport>false</MatlabSupport> //是否支持Matlab,设置为true后面需设置相应Matlab安装路径
<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 4 and 5 are supported -->
<CuDnnPath></CuDnnPath>
<ScriptsDir>$(SolutionDir)\scripts</ScriptsDir>
</PropertyGroup>
<PropertyGroup Condition="'$(CpuOnlyBuild)'=='false'">
<CudaDependencies>cublas.lib;cuda.lib;curand.li
4000
b;cudart.lib</CudaDependencies>
</PropertyGroup>
<PropertyGroup Condition="'$(UseCuDNN)'=='true'">
<CudaDependencies>cudnn.lib;$(CudaDependencies)</CudaDependencies>
</PropertyGroup>
<PropertyGroup Condition="'$(UseCuDNN)'=='true' And $(CuDnnPath)!=''">
<LibraryPath>$(CuDnnPath)\cuda\lib\x64;$(LibraryPath)</LibraryPath>
<IncludePath>$(CuDnnPath)\cuda\include;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup>
<OutDir>$(BuildDir)\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(BuildDir)\Int\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup>
<LibraryPath>$(OutDir);$(CUDA_PATH)\lib\$(Platform);$(LibraryPath)</LibraryPath>
<IncludePath>$(SolutionDir)..\include;$(SolutionDir)..\include\caffe\proto;$(CUDA_PATH)\include;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(PythonSupport)'=='true'">
<PythonDir>C:\Miniconda2\</PythonDir> //设置相应Python安装路径,最后应该无\
<LibraryPath>$(PythonDir)\libs;$(LibraryPath)</LibraryPath> //设置相应Python库目录
<IncludePath>$(PythonDir)\include;$(IncludePath)</IncludePath> //设置相应Python库目录
</PropertyGroup>
<PropertyGroup Condition="'$(MatlabSupport)'=='true'">
<MatlabDir>C:\Program Files\MATLAB\R2014b</MatlabDir> //设置相应Matlab安装路径,最后无\
<LibraryPath>$(MatlabDir)\extern\lib\win64\microsoft;$(LibraryPath)</LibraryPath> //设置相应Matlab库目录
<IncludePath>$(MatlabDir)\extern\include;$(IncludePath)</IncludePath> //设置相应Matlab包含目录
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(CpuOnlyBuild)'=='true'">
<ClCompile>
<PreprocessorDefinitions>CPU_ONLY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(UseCuDNN)'=='true'">
<ClCompile>
<PreprocessorDefinitions>USE_CUDNN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<CudaCompile>
<Defines>USE_CUDNN</Defines>
</CudaCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(PythonSupport)'=='true'">
<ClCompile>
<PreprocessorDefinitions>WITH_PYTHON_LAYER;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(MatlabSupport)'=='true'">
<ClCompile>
<PreprocessorDefinitions>MATLAB_MEX_FILE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup>
<ClCompile>
<MinimalRebuild>false</MinimalRebuild>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;USE_OPENCV;USE_LEVELDB;USE_LMDB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>Full</Optimization>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<GenerateDebugInformation>true</GenerateDebugInformation>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
</Project>注意:Matlab2014版本包含路径应设置为: <MatlabDir>F:\Program Files\MATLAB\R2014b</MatlabDir>
<LibraryPath>$(MatlabDir)\extern\lib\win64\microsoft;$(LibraryPath)</LibraryPath>
<IncludePath>$(MatlabDir)\extern\include;$(MatlabDir)\toolbox\distcomp\gpu\extern\include;$(IncludePath)</IncludePath> //增加$(MatlabDir)\toolbox\distcomp\gpu\extern\include;二、编译工程
1. VS打开Caffe.sln,默认启动项目为libcaffe,不是请将libcaffe设为启动项目,将解决方案配置为Release x64,单击调试选项下的开始执行(不调试),开始自动下载所需的程序包(需要一段时间)。
2. 下载完毕项目开始编译,中间会报错(提示编码错误),单击确定,双击错文跳转到错文文件,根据提示保存下文件即可,再次单击调试选项下的开始执行(不调试),执行完毕弹出caffe.exe窗口,提示没有相关连接,确定关闭提示即可。
3. 右击解决方案,单击选项生成解决方案,开始生成解决方案,需要耗费一定时间。
4. 运行完毕提示生成成功15个,则caffe配置完成。
准备工作:下载微软官方提供的caffe安装包,下载地址:https://github.com/Microsoft/caffe,下载完毕解压到目标文件夹即可,笔者放置在E盘根目录中。
一、修改配置文件
打开E:\caffe-master\caffe-master\windows,找到CommonSettings.props.example文件复制(原文件作为备份)更改文件名为CommonSettings.props,该文件为caffe的配置文件(GPU/CPU、Python接口、Matlab接口均在该文件中进行配置),用VS打开并更改该文件内容如下,相关内容见注释。<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<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> //true为CPU版,false为GPU版
<UseCuDNN>false</UseCuDNN> //是否使用Cudnn加速,当CPU版时设置为false
<CudaVersion>7.5</CudaVersion> //Cuda版本设置
<!-- 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>false</PythonSupport> //是否支持Python,设置为true后面需设置相应Python安装路径
<!-- NOTE: If Matlab support is enabled, MatlabDir (below) needs to be
set to the root of your Matlab installation. -->
<MatlabSupport>false</MatlabSupport> //是否支持Matlab,设置为true后面需设置相应Matlab安装路径
<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 4 and 5 are supported -->
<CuDnnPath></CuDnnPath>
<ScriptsDir>$(SolutionDir)\scripts</ScriptsDir>
</PropertyGroup>
<PropertyGroup Condition="'$(CpuOnlyBuild)'=='false'">
<CudaDependencies>cublas.lib;cuda.lib;curand.li
4000
b;cudart.lib</CudaDependencies>
</PropertyGroup>
<PropertyGroup Condition="'$(UseCuDNN)'=='true'">
<CudaDependencies>cudnn.lib;$(CudaDependencies)</CudaDependencies>
</PropertyGroup>
<PropertyGroup Condition="'$(UseCuDNN)'=='true' And $(CuDnnPath)!=''">
<LibraryPath>$(CuDnnPath)\cuda\lib\x64;$(LibraryPath)</LibraryPath>
<IncludePath>$(CuDnnPath)\cuda\include;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup>
<OutDir>$(BuildDir)\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(BuildDir)\Int\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup>
<LibraryPath>$(OutDir);$(CUDA_PATH)\lib\$(Platform);$(LibraryPath)</LibraryPath>
<IncludePath>$(SolutionDir)..\include;$(SolutionDir)..\include\caffe\proto;$(CUDA_PATH)\include;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(PythonSupport)'=='true'">
<PythonDir>C:\Miniconda2\</PythonDir> //设置相应Python安装路径,最后应该无\
<LibraryPath>$(PythonDir)\libs;$(LibraryPath)</LibraryPath> //设置相应Python库目录
<IncludePath>$(PythonDir)\include;$(IncludePath)</IncludePath> //设置相应Python库目录
</PropertyGroup>
<PropertyGroup Condition="'$(MatlabSupport)'=='true'">
<MatlabDir>C:\Program Files\MATLAB\R2014b</MatlabDir> //设置相应Matlab安装路径,最后无\
<LibraryPath>$(MatlabDir)\extern\lib\win64\microsoft;$(LibraryPath)</LibraryPath> //设置相应Matlab库目录
<IncludePath>$(MatlabDir)\extern\include;$(IncludePath)</IncludePath> //设置相应Matlab包含目录
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(CpuOnlyBuild)'=='true'">
<ClCompile>
<PreprocessorDefinitions>CPU_ONLY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(UseCuDNN)'=='true'">
<ClCompile>
<PreprocessorDefinitions>USE_CUDNN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<CudaCompile>
<Defines>USE_CUDNN</Defines>
</CudaCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(PythonSupport)'=='true'">
<ClCompile>
<PreprocessorDefinitions>WITH_PYTHON_LAYER;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(MatlabSupport)'=='true'">
<ClCompile>
<PreprocessorDefinitions>MATLAB_MEX_FILE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup>
<ClCompile>
<MinimalRebuild>false</MinimalRebuild>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;USE_OPENCV;USE_LEVELDB;USE_LMDB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>Full</Optimization>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<GenerateDebugInformation>true</GenerateDebugInformation>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
</Project>注意:Matlab2014版本包含路径应设置为: <MatlabDir>F:\Program Files\MATLAB\R2014b</MatlabDir>
<LibraryPath>$(MatlabDir)\extern\lib\win64\microsoft;$(LibraryPath)</LibraryPath>
<IncludePath>$(MatlabDir)\extern\include;$(MatlabDir)\toolbox\distcomp\gpu\extern\include;$(IncludePath)</IncludePath> //增加$(MatlabDir)\toolbox\distcomp\gpu\extern\include;二、编译工程
1. VS打开Caffe.sln,默认启动项目为libcaffe,不是请将libcaffe设为启动项目,将解决方案配置为Release x64,单击调试选项下的开始执行(不调试),开始自动下载所需的程序包(需要一段时间)。
2. 下载完毕项目开始编译,中间会报错(提示编码错误),单击确定,双击错文跳转到错文文件,根据提示保存下文件即可,再次单击调试选项下的开始执行(不调试),执行完毕弹出caffe.exe窗口,提示没有相关连接,确定关闭提示即可。
3. 右击解决方案,单击选项生成解决方案,开始生成解决方案,需要耗费一定时间。
4. 运行完毕提示生成成功15个,则caffe配置完成。
相关文章推荐
- 深度学习笔记1 ——Ubuntu16.04下caffe环境的配置(仅CPU)
- MySQL学习笔记之一:安装与配置(Windows 7环境)
- ElasticSearch学习笔记-windows环境安装
- Caffe学习笔记(一)——Windows 下caffe安装与配置
- Windows Caffe 学习笔记 caffe-windows(CPU)配置与利用mnist数据集训练第一个caffemodel
- memcached学习笔记1(windows 7 64bit 环境下安装memcached)
- (转)memcached学习笔记1(windows 7 64bit 环境下安装memcached)
- Redis学习笔记~Redis在windows环境下的安装
- ElasicSearch 学习笔记(一) windows环境下的安装与启动
- Windows环境下QT学习笔记01:QT及QT Creator的下载及安装
- Caffe_Windows学习笔记(一)基于Win10 x64+VS2013+GPU加速+Python2.7+Matlab2016b环境下的Caffe配置
- 【学习笔记】caffe for windows 安装配置
- Caffe_Windows学习笔记(六)图形化操作工具digits的安装与运行
- 【深度学习】笔记16 windows下SSD网络在caffe中的配置(CPU版本)【笔记2】
- react-native学习笔记--史上最详细Windows版本搭建安装React Native环境配置
- Thrift 学习笔记2——Windows环境下Thrift的安装、编译以及测试
- Thrift 学习笔记2——Windows环境下Thrift的安装、编译以及测试
- TQ2440 学习笔记—— 1、Windows平台下开发工具安装与环境建立
- Cordova in action学习笔记一:windows以及mac安装环境配置
- [100_Python学习笔记]001_Python环境安装配置(Windows 7)