Microsoft版的caffe在windows10下编译

1.微软caffe

https://github.com/Microsoft/caffe
下载地址,下载之后解压的文件名叫\caffe-master,记得这个路径之后常用~

2.Cuda

7.5版,但是最终没能成功安装图形驱动,但似乎并不妨碍编译

3.Cudnn

版本是4,这个解压就行诶,或者在我的上传文件中能找到

4.Vs2013

下载Vs2013并破解,这个相关教程自己查一下哈

5.CommonSettings.props

找到\caffe-master\windows\CommonSettings.props.example
复制修改CommonSettings.props.example改成CommonSettings.props
下面这个XXXX的地方都记得填上和自己的对应的路径

<?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>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>false</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>XXXXX\cudnn-7.0-win-x64-v4.0-prod</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)!=''">
        <CuDnnPath>XXXXXXX\cudnn-7.0-win-x64-v4.0-prod</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>XXXXXX\conda\</PythonDir>
        <LibraryPath>$(PythonDir)\libs;$(LibraryPath)</LibraryPath>
        <IncludePath>$(PythonDir)\include;$(IncludePath)</IncludePath>
    </PropertyGroup>
    <PropertyGroup Condition="'$(MatlabSupport)'=='true'">
        <MatlabDir>C:\Program Files\MATLAB\R2014b</MatlabDir>
        <LibraryPath>$(MatlabDir)\extern\lib\win64\microsoft;$(LibraryPath)</LibraryPath>
        <IncludePath>$(MatlabDir)\extern\include;$(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>

6.Python

由于不喜欢anaconda才试试miniconda+notepad,我更渴望pycharm但是不会哈哈哈哈哈
Miniconda website (http://conda.pydata.org/miniconda.html)
Miniconda的根环境叫base
方便使用配置可在notepad
Run:
cmd /k activate & python26 $(FULL_CURRENT_PATH) & echo= & pause & exit

Python26 为方便使用的名字,将Miniconda下的python.exe复制更名为python26.exe即可在cmd中直接调用,警告大部分时候可以无视,pip也一样,Scripts目录下复制pip.exe更名为pip26.exe,这么做主要是因为我电脑中还有两个其他的python环境,并且我习惯使用notepad,必须杜绝一下名字重复带来的麻烦,ε=(´ο`*)))唉

7.编译caffe

点击(自行选择的目录)\caffe-master\windows文件夹里的Caffe.sln,这时你发现vs解决方案中有libcaffe等项目。把编译器切换到Release x64.然后点击本地windows调试器,nuget会先下载安装需要的一些库文件,在这之前可以先更换nuget的镜像源,会快一些,下载完后后继续编译操作
更换源的教程如下,哈哈自己瞅瞅这会懒得开vs了
https://jingyan.baidu.com/article/29697b9163197dab20de3c0c.html

8.设置

打开,项目→属性→C/C++→常规→将警告视为错误 设置为否

9.编译libcaffe

选择编译环境为Release,x64。首先编译libcaffe,在libcaffe上右键生成就可以了,失败的话,等生成停下再重新生成,我没有遇见什么问题比较幸运吧。。
强制停止:Ctrl+break

10.编译caffe

libcaffe编译成功后再编译caffe,所有编译成功和运行需要的dll文件都会存储在caffe-master \Build\x64\Release 下
到此基本的算成功了

11.miniconda配置

我们打开cmd或miniconda,输入

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

我在这个过程中遇到了第二个命令时,pip无法使用的问题
于是打开cmd,重装呗(艰难呀。。)

wget https://bootstrap.pypa.io/get-pip.py  --no-check-certificate
python26 get-pip.py --force-reinstall

这里用上了我的26,别的名字可以用别的。。希望有人用pycharm搭一下让我借鉴一下
当然重装后记得改名。。。。

12.编译pycaffe

然后然后,回到vs,编译pycaffe,就是生成啦
如果不好好装上上面的包就会出问题,所以要乖一点

13.最后啦!!!!

最后啦!!!!累死我了
将caffe-master\python\caffe添加进path
或者,将这个caffe文件夹复制粘贴到conda目录\Lib\site-packages\下

14.测试

打开cmd,输入activate,或者Anaconda Prompt,进入base环境
或者notepad新建文件
import caffe
没错就好啦,玩去吧~

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值