Advertisement
Guest User

build.cmd

a guest
Apr 8th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. شبتون بخیر
  2. Skip to content
  3. Features Business Explore Pricing
  4. This repository
  5. Search
  6. Sign in or Sign up
  7.  Watch 1,857  Star 17,025  Fork 10,520 BVLC/caffe
  8.  Code  Issues 697  Pull requests 287  Projects 0  Wiki  Pulse  Graphs
  9. Branch: windows Find file Copy pathcaffe/scripts/build_win.cmd
  10. 2106a62  on Feb 16
  11. @willyd willyd Added nccl ExternalProject to build nccl on Windows
  12. 2 contributors @willyd @forderud
  13. RawBlameHistory    
  14. 222 lines (197 sloc)  7.17 KB
  15. @echo off
  16. @setlocal EnableDelayedExpansion
  17.  
  18. :: Default values
  19. if DEFINED APPVEYOR (
  20.     echo Setting Appveyor defaults
  21.     if NOT DEFINED MSVC_VERSION set MSVC_VERSION=14
  22.     if NOT DEFINED WITH_NINJA set WITH_NINJA=0
  23.     if NOT DEFINED CPU_ONLY set CPU_ONLY=1
  24.     if NOT DEFINED CMAKE_CONFIG set CMAKE_CONFIG=Release
  25.     if NOT DEFINED USE_NCCL set USE_NCCL=0
  26.     if NOT DEFINED CMAKE_BUILD_SHARED_LIBS set CMAKE_BUILD_SHARED_LIBS=0
  27.     if NOT DEFINED PYTHON_VERSION set PYTHON_VERSION=2
  28.     if NOT DEFINED BUILD_PYTHON set BUILD_PYTHON=1
  29.     if NOT DEFINED BUILD_PYTHON_LAYER set BUILD_PYTHON_LAYER=1
  30.     if NOT DEFINED BUILD_MATLAB set BUILD_MATLAB=0
  31.     if NOT DEFINED PYTHON_EXE set PYTHON_EXE=python
  32.     if NOT DEFINED RUN_TESTS set RUN_TESTS=1
  33.     if NOT DEFINED RUN_LINT set RUN_LINT=1
  34.     if NOT DEFINED RUN_INSTALL set RUN_INSTALL=1
  35.  
  36.     :: Set python 2.7 with conda as the default python
  37.     if !PYTHON_VERSION! EQU 2 (
  38.         set CONDA_ROOT=C:\Miniconda-x64
  39.     )
  40.     :: Set python 3.5 with conda as the default python
  41.     if !PYTHON_VERSION! EQU 3 (
  42.         set CONDA_ROOT=C:\Miniconda35-x64
  43.     )
  44.     set PATH=!CONDA_ROOT!;!CONDA_ROOT!\Scripts;!CONDA_ROOT!\Library\bin;!PATH!
  45.  
  46.     :: Check that we have the right python version
  47.     !PYTHON_EXE! --version
  48.     :: Add the required channels
  49.     conda config --add channels conda-forge
  50.     conda config --add channels willyd
  51.     :: Update conda
  52.     conda update conda -y
  53.     :: Download other required packages
  54.     conda install --yes cmake ninja numpy scipy protobuf==3.1.0 six scikit-image pyyaml
  55.  
  56.     if ERRORLEVEL 1  (
  57.       echo ERROR: Conda update or install failed
  58.       exit /b 1
  59.     )
  60.  
  61.     :: Install cuda and disable tests if needed
  62.     if !WITH_CUDA! == 1 (
  63.         call %~dp0\appveyor\appveyor_install_cuda.cmd
  64.         set CPU_ONLY=0
  65.         set RUN_TESTS=0
  66.         set USE_NCCL=1
  67.     ) else (
  68.         set CPU_ONLY=1
  69.     )
  70.  
  71.     :: Disable the tests in debug config
  72.     if "%CMAKE_CONFIG%" == "Debug" (
  73.         echo Disabling tests on appveyor with config == %CMAKE_CONFIG%
  74.         set RUN_TESTS=0
  75.     )
  76.  
  77.     :: Disable linting with python 3 until we find why the script fails
  78.     if !PYTHON_VERSION! EQU 3 (
  79.         set RUN_LINT=0
  80.     )
  81.  
  82. ) else (
  83.     :: Change the settings here to match your setup
  84.     :: Change MSVC_VERSION to 12 to use VS 2013
  85.     if NOT DEFINED MSVC_VERSION set MSVC_VERSION=14
  86.     :: Change to 1 to use Ninja generator (builds much faster)
  87.     if NOT DEFINED WITH_NINJA set WITH_NINJA=1
  88.     :: Change to 1 to build caffe without CUDA support
  89.     if NOT DEFINED CPU_ONLY set CPU_ONLY=0
  90.     :: 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
  91.     if NOT DEFINED CMAKE_CONFIG set CMAKE_CONFIG=Release
  92.     :: Set to 1 to use NCCL
  93.     if NOT DEFINED USE_NCCL set USE_NCCL=0
  94.     :: Change to 1 to build a caffe.dll
  95.     if NOT DEFINED CMAKE_BUILD_SHARED_LIBS set CMAKE_BUILD_SHARED_LIBS=0
  96.     :: Change to 3 if using python 3.5 (only 2.7 and 3.5 are supported)
  97.     if NOT DEFINED PYTHON_VERSION set PYTHON_VERSION=2
  98.     :: Change these options for your needs.
  99.     if NOT DEFINED BUILD_PYTHON set BUILD_PYTHON=1
  100.     if NOT DEFINED BUILD_PYTHON_LAYER set BUILD_PYTHON_LAYER=1
  101.     if NOT DEFINED BUILD_MATLAB set BUILD_MATLAB=0
  102.     :: If python is on your path leave this alone
  103.     if NOT DEFINED PYTHON_EXE set PYTHON_EXE=python
  104.     :: Run the tests
  105.     if NOT DEFINED RUN_TESTS set RUN_TESTS=0
  106.     :: Run lint
  107.     if NOT DEFINED RUN_LINT set RUN_LINT=0
  108.     :: Build the install target
  109.     if NOT DEFINED RUN_INSTALL set RUN_INSTALL=0
  110. )
  111.  
  112. :: Set the appropriate CMake generator
  113. :: Use the exclamation mark ! below to delay the
  114. :: expansion of CMAKE_GENERATOR
  115. if %WITH_NINJA% EQU 0 (
  116.     if "%MSVC_VERSION%"=="14" (
  117.         set CMAKE_GENERATOR=Visual Studio 14 2015 Win64
  118.     )
  119.     if "%MSVC_VERSION%"=="12" (
  120.         set CMAKE_GENERATOR=Visual Studio 12 2013 Win64
  121.     )
  122.     if "!CMAKE_GENERATOR!"=="" (
  123.         echo ERROR: Unsupported MSVC version
  124.         exit /B 1
  125.     )
  126. ) else (
  127.     set CMAKE_GENERATOR=Ninja
  128. )
  129.  
  130. echo INFO: ============================================================
  131. echo INFO: Summary:
  132. echo INFO: ============================================================
  133. echo INFO: MSVC_VERSION               = !MSVC_VERSION!
  134. echo INFO: WITH_NINJA                 = !WITH_NINJA!
  135. echo INFO: CMAKE_GENERATOR            = "!CMAKE_GENERATOR!"
  136. echo INFO: CPU_ONLY                   = !CPU_ONLY!
  137. echo INFO: CMAKE_CONFIG               = !CMAKE_CONFIG!
  138. echo INFO: USE_NCCL                   = !USE_NCCL!
  139. echo INFO: CMAKE_BUILD_SHARED_LIBS    = !CMAKE_BUILD_SHARED_LIBS!
  140. echo INFO: PYTHON_VERSION             = !PYTHON_VERSION!
  141. echo INFO: BUILD_PYTHON               = !BUILD_PYTHON!
  142. echo INFO: BUILD_PYTHON_LAYER         = !BUILD_PYTHON_LAYER!
  143. echo INFO: BUILD_MATLAB               = !BUILD_MATLAB!
  144. echo INFO: PYTHON_EXE                 = "!PYTHON_EXE!"
  145. echo INFO: RUN_TESTS                  = !RUN_TESTS!
  146. echo INFO: RUN_LINT                   = !RUN_LINT!
  147. echo INFO: RUN_INSTALL                = !RUN_INSTALL!
  148. echo INFO: ============================================================
  149.  
  150. :: Build and exectute the tests
  151. :: Do not run the tests with shared library
  152. if !RUN_TESTS! EQU 1 (
  153.     if %CMAKE_BUILD_SHARED_LIBS% EQU 1 (
  154.         echo WARNING: Disabling tests with shared library build
  155.         set RUN_TESTS=0
  156.     )
  157. )
  158.  
  159. if NOT EXIST build mkdir build
  160. pushd build
  161.  
  162. :: Setup the environement for VS x64
  163. set batch_file=!VS%MSVC_VERSION%0COMNTOOLS!..\..\VC\vcvarsall.bat
  164. call "%batch_file%" amd64
  165.  
  166. :: Configure using cmake and using the caffe-builder dependencies
  167. :: Add -DCUDNN_ROOT=C:/Projects/caffe/cudnn-8.0-windows10-x64-v5.1/cuda ^
  168. :: below to use cuDNN
  169. cmake -G"!CMAKE_GENERATOR!" ^
  170.       -DBLAS=Open ^
  171.       -DCMAKE_BUILD_TYPE:STRING=%CMAKE_CONFIG% ^
  172.       -DBUILD_SHARED_LIBS:BOOL=%CMAKE_BUILD_SHARED_LIBS% ^
  173.       -DBUILD_python:BOOL=%BUILD_PYTHON% ^
  174.       -DBUILD_python_layer:BOOL=%BUILD_PYTHON_LAYER% ^
  175.       -DBUILD_matlab:BOOL=%BUILD_MATLAB% ^
  176.       -DCPU_ONLY:BOOL=%CPU_ONLY% ^
  177.       -DCOPY_PREREQUISITES:BOOL=1 ^
  178.       -DINSTALL_PREREQUISITES:BOOL=1 ^
  179.       -DUSE_NCCL:BOOL=!USE_NCCL! ^
  180.       "%~dp0\.."
  181.  
  182. if ERRORLEVEL 1 (
  183.   echo ERROR: Configure failed
  184.   exit /b 1
  185. )
  186.  
  187. :: Lint
  188. if %RUN_LINT% EQU 1 (
  189.     cmake --build . --target lint  --config %CMAKE_CONFIG%
  190. )
  191.  
  192. if ERRORLEVEL 1 (
  193.   echo ERROR: Lint failed
  194.   exit /b 1
  195. )
  196.  
  197. :: Build the library and tools
  198. cmake --build . --config %CMAKE_CONFIG%
  199.  
  200. if ERRORLEVEL 1 (
  201.   echo ERROR: Build failed
  202.   exit /b 1
  203. )
  204.  
  205. :: Build and exectute the tests
  206. if !RUN_TESTS! EQU 1 (
  207.     cmake --build . --target runtest --config %CMAKE_CONFIG%
  208.  
  209.     if ERRORLEVEL 1 (
  210.         echo ERROR: Tests failed
  211.         exit /b 1
  212.     )
  213.  
  214.     if %BUILD_PYTHON% EQU 1 (
  215.         if %BUILD_PYTHON_LAYER% EQU 1 (
  216.             :: Run python tests only in Release build since
  217.             :: the _caffe module is _caffe-d is debug
  218.             if "%CMAKE_CONFIG%"=="Release" (
  219.                 :: Run the python tests
  220.                 cmake --build . --target pytest
  221.  
  222.                 if ERRORLEVEL 1 (
  223.                     echo ERROR: Python tests failed
  224.                     exit /b 1
  225.                 )
  226.             )
  227.         )
  228.     )
  229. )
  230.  
  231. if %RUN_INSTALL% EQU 1 (
  232.     cmake --build . --target install --config %CMAKE_CONFIG%
  233. )
  234.  
  235. popd
  236. @endlocal
  237. Contact GitHub API Training Shop Blog About
  238. © 2017 GitHub, Inc. Terms Privacy Security Status Help
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement