Caffe中master与windows分支差异对比及通过命令提示符编译Caffe源码操作步骤
来源:互联网 发布:富人思维 知乎 编辑:程序博客网 时间:2024/06/06 03:19
目前GitHub https://github.com/fengbingchun/Caffe_Test 中的caffe还是依赖较老的版本,更新于2015.08.15,commit为09868ac,近期想更新到最新版本,在https://github.com/BVLC/caffe 中,有master分支和windows分支,为便于后面更新,这里先对比下master分支(2017.03.31, commit: c0597b1)和windows分支(2017.03.29,commit: 88ddc95)中include目录和src目录的主要差异:
一、include目录:
1. caffe/test/test_caffe_main.hpp:
(1)、在windows分支中多包含了一个头文件<caffe/util/io.hpp>;
(2)、在windows分支中类MultiDeviceTest的析构函数调用了RemoveCaffeTempDir()函数用于清除一些创建的临时目录。
2. caffe/util/cudnn.hpp:
(1)、在windows分支中取消对cudnnGetErrorString函数的定义;
(2)、在windows分支中对setConvolutionDesc函数,取消对宏CUDNN_VERSION_MIN的支持。
3. caffe/util/io.hpp:
(1)、在windows分支中,在MakeTempDir函数中调用了boost::filesystem::create_directory函数用于创建临时目录;
(2)、在windows分支中,增加了RemoveCaffeTempDir函数的实现。
4. caffe/common.hpp:
(1)、在windows分支中,如果定义了宏CMAKE_WINDOWS_BUILD,则包含”caffe/export.hpp”.
5. caffe/layer_factory.hpp:
(1)、在windows分支中,将类LayerRegistry和类LayerRegisterer的实现体挪到了src/caffe/layer_factory.cpp文件中。
6. caffe/solver_factory.hpp:
(1)、在windows分支中,将类SolverRegistry和类SolverRegisterer的实现体挪到了src/caffe/solver_factory.cpp文件中。
二、src目录:
1. caffe/layers/bnll_layer.cu:
(1)、在windows分支中,将常量kBNLL_THRESHOLD由const floatkBNLL_THRESHOLD = 50.; 调整为__constant__ float kBNLL_THRESHOLD = 50.;
2. caffe/test/test_benchmark.cpp:
(1)、在windows分支中,将常量kMillisecondsThreshold值由30调整为50。
3. caffe/test/test_blob.cpp:
(1)、在windows分支中,在GPU mode下,取消对TYPED_TEST(BlobSimpleTest,TestPointersCPUGPU)的调用。
4. caffe/test/test_gradient_based_solver.cpp:
(1)、在windows分支中,类GradientBasedSolverTest中RunLeastSquaresSolver函数增加std::replace函数将”\\”替换为”/”;
(2)、在windows分支中,类GradientBasedSolverTest中TestSnapshot函数内对调用caffe::Blob的CopyFrom函数的参数调整。
5. caffe/test_lrn_layer.cpp:
(1)、在windows分支中,将模板类CuDNNLRNLayerTest的类型名由TypeParam调整为Dtype。
6. caffe/util/db_lmdb.cpp:
(1)、在windows分支中,增加包含<direct.h>和#define mkdir(X,Y) _mkdir(X)
7. caffe/util/io.cpp:
(1)、在windows分支中,增加包含<io.h>;
(2)、在windows分支中,对ReadProtoFromBinaryFile函数中的open函数由open(filename,O_RDONLY)调整为open(filename, O_RDONLY | O_BINARY)。
8. caffe/util/signal_handler.cpp:
(1)、在windows分支中,将与SIGHUP相关的操作用SIGBREAK替换。
9. caffe/common.cpp:
(1)、在windows分支中,增加包括<process.h>和#define getpid()_getpid()
(2)、在window分支中,在GlobalInit函数中取消对::google::InstallFailureSignalHandler函数的调用。
10. caffe/layer_factory.cpp:
(1)、在windows分支中,增加包含<vector>;
(2)、在windows分支中,存放类LayerRegistry和类LayerRegisterer的实现体。
11. caffe/solver_factory.cpp:
(1)、仅在windows分支中有的文件,存放类SolverRegistry和类SolverRegisterer的实现体。
由上面include和src比对得知,两个分支在C++的实现上差异不大。
三、cmake文件的差异:
两个分支上cmake文件差异较大。
四、在windows10 vs2013通过命令提示符编译caffe windows分支操作步骤:
1. 从https://github.com/BVLC/caffe/tree/windows clone caffe源码,clone到D:/DownLoad/caffe并切换到windows分支;
2. 参考README.md中的说明;
3. 打开命令提示符,将其定位到D:/DownLoad/caffe/scripts;
4. 调整build_win.cmd文件,调整后的build_win.cmd文件内容如下(仅包含调整的部分):
@echo off@setlocal EnableDelayedExpansion:: Default valuesif DEFINED APPVEYOR ( echo Setting Appveyor defaults if NOT DEFINED MSVC_VERSION set MSVC_VERSION=12 if NOT DEFINED WITH_NINJA set WITH_NINJA=0 if NOT DEFINED CPU_ONLY set CPU_ONLY=1 if NOT DEFINED CMAKE_CONFIG set CMAKE_CONFIG=Release if NOT DEFINED USE_NCCL set USE_NCCL=0 if NOT DEFINED CMAKE_BUILD_SHARED_LIBS set CMAKE_BUILD_SHARED_LIBS=0 if NOT DEFINED PYTHON_VERSION set PYTHON_VERSION=0 if NOT DEFINED BUILD_PYTHON set BUILD_PYTHON=0 if NOT DEFINED BUILD_PYTHON_LAYER set BUILD_PYTHON_LAYER=0 if NOT DEFINED BUILD_MATLAB set BUILD_MATLAB=0 if NOT DEFINED PYTHON_EXE set PYTHON_EXE=python if NOT DEFINED RUN_TESTS set RUN_TESTS=0 if NOT DEFINED RUN_LINT set RUN_LINT=0 if NOT DEFINED RUN_INSTALL set RUN_INSTALL=0 :: Set python 2.7 with conda as the default python if !PYTHON_VERSION! EQU 2 ( set CONDA_ROOT=C:\Miniconda-x64 ) :: Set python 3.5 with conda as the default python if !PYTHON_VERSION! EQU 3 ( set CONDA_ROOT=C:\Miniconda35-x64 ) set PATH=!CONDA_ROOT!;!CONDA_ROOT!\Scripts;!CONDA_ROOT!\Library\bin;!PATH! :: Check that we have the right python version !PYTHON_EXE! --version :: Add the required channels conda config --add channels conda-forge conda config --add channels willyd :: Update conda conda update conda -y :: Download other required packages conda install --yes cmake ninja numpy scipy protobuf==3.1.0 six scikit-image pyyaml if ERRORLEVEL 1 ( echo ERROR: Conda update or install failed exit /b 1 ) :: Install cuda and disable tests if needed if !WITH_CUDA! == 1 ( call %~dp0\appveyor\appveyor_install_cuda.cmd set CPU_ONLY=0 set RUN_TESTS=0 set USE_NCCL=1 ) else ( set CPU_ONLY=1 ) :: Disable the tests in debug config if "%CMAKE_CONFIG%" == "Debug" ( echo Disabling tests on appveyor with config == %CMAKE_CONFIG% set RUN_TESTS=0 ) :: Disable linting with python 3 until we find why the script fails if !PYTHON_VERSION! EQU 3 ( set RUN_LINT=0 )) else ( :: Change the settings here to match your setup :: Change MSVC_VERSION to 12 to use VS 2013 if NOT DEFINED MSVC_VERSION set MSVC_VERSION=12 :: Change to 1 to use Ninja generator (builds much faster) if NOT DEFINED WITH_NINJA set WITH_NINJA=0 :: Change to 1 to build caffe without CUDA support if NOT DEFINED CPU_ONLY set CPU_ONLY=1 :: Change to Debug to build Debug. This is only relevant for the Ninja generator the Visual Studio generator will generate both Debug and Release configs if NOT DEFINED CMAKE_CONFIG set CMAKE_CONFIG=Release :: Set to 1 to use NCCL if NOT DEFINED USE_NCCL set USE_NCCL=0 :: Change to 1 to build a caffe.dll if NOT DEFINED CMAKE_BUILD_SHARED_LIBS set CMAKE_BUILD_SHARED_LIBS=0 :: Change to 3 if using python 3.5 (only 2.7 and 3.5 are supported) if NOT DEFINED PYTHON_VERSION set PYTHON_VERSION=2 :: Change these options for your needs. if NOT DEFINED BUILD_PYTHON set BUILD_PYTHON=0 if NOT DEFINED BUILD_PYTHON_LAYER set BUILD_PYTHON_LAYER=0 if NOT DEFINED BUILD_MATLAB set BUILD_MATLAB=0 :: If python is on your path leave this alone if NOT DEFINED PYTHON_EXE set PYTHON_EXE=python :: Run the tests if NOT DEFINED RUN_TESTS set RUN_TESTS=0 :: Run lint if NOT DEFINED RUN_LINT set RUN_LINT=0 :: Build the install target if NOT DEFINED RUN_INSTALL set RUN_INSTALL=0)(1)、调整包括仅编译CPU、vs12、不使用NinJa;
(2)、依赖库会默认下载到C:/Users/spring/.caffe目录下,大约1.07GB;
(3)、如有错误提示,修改cmake/WindowsDownloadPrebuiltDependencies.cmake中DEPENDENCIES_SHA_1800_27值;
执行完此命令后结果如下图所示:
5. 执行build_win.cmd会在caffe/scripts/build目录下生成Caffe工程Caffe.sln,结果如下图所示:
五、接下来仿照生成的Caffe.sln,将https://github.com/fengbingchun/Caffe_Test中的Caffe升级到最新。
Note:将build_win.cmd中的两处CPU_ONLY=1改为CPU_ONLY=0,就可以生成基于GPU的Caffe工程。
GitHub:https://github.com/fengbingchun/Caffe_Test
- Caffe中master与windows分支差异对比及通过命令提示符编译Caffe源码操作步骤
- Caffe-Windows编译与mnist示例编译完整版流程步骤
- caffe 12 caffe源码 windows分支目录结构
- caffe windows编译及配置
- caffe接口及命令操作
- caffe源码与linux命令学习笔记
- 使用VS2013编译Caffe源码(不带GPU支持)步骤
- Windows7_VS2013_Cmake编译Caffe源码(不带GPU支持)步骤
- Windows编译Caffe指南
- Windows下编译caffe
- caffe-windows下编译
- caffe-windows编译
- caffe windows 编译
- Windows下编译caffe
- 编译Caffe for Windows
- windows下编译caffe
- 【caffe-windows】 caffe-master 之Matlab中model的分类应用
- caffe Windows和caffe windows master遇到的问题
- Android Splash 的最佳实践
- 从源码的角度分析,getWidth() 与 getMeasuredWidth() 的不同之处
- 线程封装类(2)
- Linux文件管理
- FileI/O
- Caffe中master与windows分支差异对比及通过命令提示符编译Caffe源码操作步骤
- 接口
- 《Java高并发程序设计》学习 --7.2 Akka之有关消息投递的一些说明
- bzoj4147
- PDF merge
- java中的类的执行顺序问题
- 模型,视图,控制器(MVC)
- 《Java高并发程序设计》学习 --7.3 Akka之Actor的生命周期
- linux 常用指令