zoukankan      html  css  js  c++  java
  • Caffe windows编译

    一、编译环境

    1.下载caffe windows版源码

    https://github.com/BVLC/caffe/tree/windows

    2.CUDA

      CUDA 7.5 or 8.0 (use CUDA 8 if using Visual Studio 2015)

    3.cuDNN v4

      将下载的bin,include及lib拷贝到CUDA对应的目录(我的为:C:Program FilesNVIDIA GPU Computing ToolkitCUDAv7.5)。

    4.Matlab

      R2016b(我的版本)

    5.Anaconda Python 2.7

      https://conda.io/miniconda.html

      下载后双击可执行程序安装到C:Miniconda2。

      安装完毕后启动cmd.exe,输入conda list可以看到一些安装包;

      更新conda包

    conda update conda

       安装numpy

    conda install numpy

    二、编译

      进入caffewindows目录,复制CommonSettings.props.example文件为CommonSettings.props(粗体字部分为修改处),其内容如下

    <?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>
            <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>
    
            <!-- 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.lib;cudart.lib</CudaDependencies>
        </PropertyGroup>
    
        <PropertyGroup Condition="'$(UseCuDNN)'=='true'">
            <CudaDependencies>cudnn.lib;$(CudaDependencies)</CudaDependencies>
        </PropertyGroup>
        <PropertyGroup Condition="'$(UseCuDNN)'=='true' And $(CuDnnPath)!=''">
            <LibraryPath>$(CuDnnPath)libx64;$(LibraryPath)</LibraryPath>
            <IncludePath>$(CuDnnPath)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)..includecaffeproto;$(CUDA_PATH)include;$(IncludePath)</IncludePath>
        </PropertyGroup>
        <PropertyGroup Condition="'$(PythonSupport)'=='true'">
            <PythonDir>C:Miniconda2</PythonDir>
            <LibraryPath>$(PythonDir)libs;$(LibraryPath)</LibraryPath>
            <IncludePath>$(PythonDir)include;$(PythonDir)Libsite-packages
    umpycore;$(IncludePath)</IncludePath>
        </PropertyGroup>
        <PropertyGroup Condition="'$(MatlabSupport)'=='true'">
            <MatlabDir>C:Program FilesMATLABR2016b</MatlabDir>
            <LibraryPath>$(MatlabDir)externlibwin64microsoft;$(LibraryPath)</LibraryPath>
            <IncludePath>$(MatlabDir)externinclude;$(MatlabDir)	oolboxdistcompgpuexterninclude;$(IncludePath)</IncludePath>
        </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>

     注意:<CuDnnPath></CuDnnPath>之间不要输入任何路径,否则编译libcaffe时会报如下错误:

    错误 1 error MSB3073: 命令“"D:caffe-windowswindows\scriptsBinplaceCudaDependencies.cmd" "C:Program FilesNVIDIA GPU Computing ToolkitCUDAv7.5in" "" false true "D:caffe-windowswindows..Buildx64Debug"
    :VCEnd”已退出,代码为 1。 C:Program Files (x86)MSBuildMicrosoft.Cppv4.0V120Microsoft.CppCommon.targets 132 5 libcaffe

      

  • 相关阅读:
    mysql 执行计划 explain
    深度学习论文翻译解析(二十):YOLOv4: Optimal Speed and Accuracy of Object Detection
    卷积神经网络学习笔记——轻量化网络MobileNet系列(V1,V2,V3)
    OpenCV计算机视觉学习(13)——图像特征点检测(Harris角点检测,sift算法)
    人工智能必备数学基础:概率论与数理统计(2)
    人工智能必备数学基础:概率论与数理统计(1)
    深度学习论文翻译解析(十九):Searching for MobileNetV3
    深度学习论文翻译解析(十八):MobileNetV2: Inverted Residuals and Linear Bottlenecks
    深度学习论文翻译解析(十七):MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications
    卷积神经网络学*笔记——SENet
  • 原文地址:https://www.cnblogs.com/ziyu-trip/p/6918527.html
Copyright © 2011-2022 走看看