Guest User

Untitled

a guest
Jun 21st, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.59 KB | None | 0 0
  1. @echo off
  2. @setlocal EnableDelayedExpansion
  3.  
  4. :: Default values
  5. if DEFINED APPVEYOR (
  6. echo Setting Appveyor defaults
  7. if NOT DEFINED MSVC_VERSION set MSVC_VERSION=14
  8. if NOT DEFINED WITH_NINJA set WITH_NINJA=0
  9. if NOT DEFINED CPU_ONLY set CPU_ONLY=0
  10. if NOT DEFINED CUDA_ARCH_NAME set CUDA_ARCH_NAME=Auto
  11. if NOT DEFINED CMAKE_CONFIG set CMAKE_CONFIG=Release
  12. if NOT DEFINED USE_NCCL set USE_NCCL=0
  13. if NOT DEFINED CMAKE_BUILD_SHARED_LIBS set CMAKE_BUILD_SHARED_LIBS=0
  14. if NOT DEFINED PYTHON_VERSION set PYTHON_VERSION=2
  15. if NOT DEFINED BUILD_PYTHON set BUILD_PYTHON=1
  16. if NOT DEFINED BUILD_PYTHON_LAYER set BUILD_PYTHON_LAYER=1
  17. if NOT DEFINED BUILD_MATLAB set BUILD_MATLAB=0
  18. if NOT DEFINED PYTHON_EXE set PYTHON_EXE=python
  19. if NOT DEFINED RUN_TESTS set RUN_TESTS=1
  20. if NOT DEFINED RUN_LINT set RUN_LINT=1
  21. if NOT DEFINED RUN_INSTALL set RUN_INSTALL=1
  22.  
  23. :: Set python 2.7 with conda as the default python
  24. if !PYTHON_VERSION! EQU 2 (
  25. set CONDA_ROOT=C:ProgramDataAnamshconda
  26. )
  27. :: Set python 3.5 with conda as the default python
  28. if !PYTHON_VERSION! EQU 3 (
  29. set CONDA_ROOT=C:ProgramDataAnamshconda
  30. )
  31. set PATH=!CONDA_ROOT!;!CONDA_ROOT!Scripts;!CONDA_ROOT!Librarybin;!PATH!
  32.  
  33. :: Check that we have the right python version
  34. !PYTHON_EXE! --version
  35. :: Add the required channels
  36. conda config --add channels conda-forge
  37. conda config --add channels willyd
  38. :: Update conda
  39. conda update conda -y
  40. :: Download other required packages
  41. conda install --yes cmake ninja numpy scipy protobuf==3.1.0 six scikit-image pyyaml pydotplus graphviz
  42.  
  43. if ERRORLEVEL 1 (
  44. echo ERROR: Conda update or install failed
  45. exit /b 1
  46. )
  47.  
  48. :: Install cuda and disable tests if needed
  49. if !WITH_CUDA! == 1 (
  50. call %~dp0appveyorappveyor_install_cuda.cmd
  51. set CPU_ONLY=0
  52. set RUN_TESTS=0
  53. set USE_NCCL=1
  54. ) else (
  55. set CPU_ONLY=1
  56. )
  57.  
  58. :: Disable the tests in debug config
  59. if "%CMAKE_CONFIG%" == "Debug" (
  60. echo Disabling tests on appveyor with config == %CMAKE_CONFIG%
  61. set RUN_TESTS=0
  62. )
  63.  
  64. :: Disable linting with python 3 until we find why the script fails
  65. if !PYTHON_VERSION! EQU 3 (
  66. set RUN_LINT=0
  67. )
  68.  
  69. ) else (
  70. :: Change the settings here to match your setup
  71. :: Change MSVC_VERSION to 12 to use VS 2013
  72. if NOT DEFINED MSVC_VERSION set MSVC_VERSION=14
  73. :: Change to 1 to use Ninja generator (builds much faster)
  74. if NOT DEFINED WITH_NINJA set WITH_NINJA=0
  75. :: Change to 1 to build caffe without CUDA support
  76. if NOT DEFINED CPU_ONLY set CPU_ONLY=0
  77. :: Change to generate CUDA code for one of the following GPU architectures
  78. :: [Fermi Kepler Maxwell Pascal All]
  79. if NOT DEFINED CUDA_ARCH_NAME set CUDA_ARCH_NAME=Auto
  80. :: 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
  81. if NOT DEFINED CMAKE_CONFIG set CMAKE_CONFIG=Release
  82. :: Set to 1 to use NCCL
  83. if NOT DEFINED USE_NCCL set USE_NCCL=0
  84. :: Change to 1 to build a caffe.dll
  85. if NOT DEFINED CMAKE_BUILD_SHARED_LIBS set CMAKE_BUILD_SHARED_LIBS=0
  86. :: Change to 3 if using python 3.5 (only 2.7 and 3.5 are supported)
  87. if NOT DEFINED PYTHON_VERSION set PYTHON_VERSION=2
  88. :: Change these options for your needs.
  89. if NOT DEFINED BUILD_PYTHON set BUILD_PYTHON=1
  90. if NOT DEFINED BUILD_PYTHON_LAYER set BUILD_PYTHON_LAYER=1
  91. if NOT DEFINED BUILD_MATLAB set BUILD_MATLAB=0
  92. :: If python is on your path leave this alone
  93. if NOT DEFINED PYTHON_EXE set PYTHON_EXE=python
  94. :: Run the tests
  95. if NOT DEFINED RUN_TESTS set RUN_TESTS=0
  96. :: Run lint
  97. if NOT DEFINED RUN_LINT set RUN_LINT=0
  98. :: Build the install target
  99. if NOT DEFINED RUN_INSTALL set RUN_INSTALL=0
  100. )
  101.  
  102. :: Set the appropriate CMake generator
  103. :: Use the exclamation mark ! below to delay the
  104. :: expansion of CMAKE_GENERATOR
  105. if %WITH_NINJA% EQU 0 (
  106. if "%MSVC_VERSION%"=="14" (
  107. set CMAKE_GENERATOR=Visual Studio 14 2015 Win64
  108. )
  109. if "%MSVC_VERSION%"=="12" (
  110. set CMAKE_GENERATOR=Visual Studio 12 2013 Win64
  111. )
  112. if "!CMAKE_GENERATOR!"=="" (
  113. echo ERROR: Unsupported MSVC version
  114. exit /B 1
  115. )
  116. ) else (
  117. set CMAKE_GENERATOR=Ninja
  118. )
  119.  
  120. echo INFO: ============================================================
  121. echo INFO: Summary:
  122. echo INFO: ============================================================
  123. echo INFO: MSVC_VERSION = !MSVC_VERSION!
  124. echo INFO: WITH_NINJA = !WITH_NINJA!
  125. echo INFO: CMAKE_GENERATOR = "!CMAKE_GENERATOR!"
  126. echo INFO: CPU_ONLY = !CPU_ONLY!
  127. echo INFO: CUDA_ARCH_NAME = !CUDA_ARCH_NAME!
  128. echo INFO: CMAKE_CONFIG = !CMAKE_CONFIG!
  129. echo INFO: USE_NCCL = !USE_NCCL!
  130. echo INFO: CMAKE_BUILD_SHARED_LIBS = !CMAKE_BUILD_SHARED_LIBS!
  131. echo INFO: PYTHON_VERSION = !PYTHON_VERSION!
  132. echo INFO: BUILD_PYTHON = !BUILD_PYTHON!
  133. echo INFO: BUILD_PYTHON_LAYER = !BUILD_PYTHON_LAYER!
  134. echo INFO: BUILD_MATLAB = !BUILD_MATLAB!
  135. echo INFO: PYTHON_EXE = "!PYTHON_EXE!"
  136. echo INFO: RUN_TESTS = !RUN_TESTS!
  137. echo INFO: RUN_LINT = !RUN_LINT!
  138. echo INFO: RUN_INSTALL = !RUN_INSTALL!
  139. echo INFO: ============================================================
  140.  
  141. :: Build and exectute the tests
  142. :: Do not run the tests with shared library
  143. if !RUN_TESTS! EQU 1 (
  144. if %CMAKE_BUILD_SHARED_LIBS% EQU 1 (
  145. echo WARNING: Disabling tests with shared library build
  146. set RUN_TESTS=0
  147. )
  148. )
  149.  
  150. if NOT EXIST build mkdir build
  151. pushd build
  152.  
  153. :: Setup the environement for VS x64
  154. set batch_file=!VS%MSVC_VERSION%0COMNTOOLS!....VCvcvarsall.bat
  155. call "%batch_file%" amd64
  156.  
  157. :: Configure using cmake and using the caffe-builder dependencies
  158. :: Add -DCUDNN_ROOT=C:Program FilesNVIDIA GPU Computing Toolkit ^
  159. :: below to use cuDNN
  160. cmake -G"!CMAKE_GENERATOR!" ^
  161. -DBLAS=Open ^
  162. -DCMAKE_BUILD_TYPE:STRING=%CMAKE_CONFIG% ^
  163. -DBUILD_SHARED_LIBS:BOOL=%CMAKE_BUILD_SHARED_LIBS% ^
  164. -DBUILD_python:BOOL=%BUILD_PYTHON% ^
  165. -DBUILD_python_layer:BOOL=%BUILD_PYTHON_LAYER% ^
  166. -DBUILD_matlab:BOOL=%BUILD_MATLAB% ^
  167. -DCPU_ONLY:BOOL=%CPU_ONLY% ^
  168. -DCOPY_PREREQUISITES:BOOL=1 ^
  169. -DINSTALL_PREREQUISITES:BOOL=1 ^
  170. -DUSE_NCCL:BOOL=!USE_NCCL! ^
  171. -DCUDA_ARCH_NAME:STRING=%CUDA_ARCH_NAME% ^
  172. -DCUDNN_ROOT=C:Program FilesNVIDIA GPU Computing ToolkitCUDAv8.0 ^
  173. "%~dp0.."
  174.  
  175. if ERRORLEVEL 1 (
  176. echo ERROR: Configure failed
  177. exit /b 1
  178. )
  179.  
  180. :: Lint
  181. if %RUN_LINT% EQU 1 (
  182. cmake --build . --target lint --config %CMAKE_CONFIG%
  183. )
  184.  
  185. if ERRORLEVEL 1 (
  186. echo ERROR: Lint failed
  187. exit /b 1
  188. )
  189.  
  190. :: Build the library and tools
  191. cmake --build . --config %CMAKE_CONFIG%
  192.  
  193. if ERRORLEVEL 1 (
  194. echo ERROR: Build failed
  195. exit /b 1
  196. )
  197.  
  198. :: Build and exectute the tests
  199. if !RUN_TESTS! EQU 1 (
  200. cmake --build . --target runtest --config %CMAKE_CONFIG%
  201.  
  202. if ERRORLEVEL 1 (
  203. echo ERROR: Tests failed
  204. exit /b 1
  205. )
  206.  
  207. if %BUILD_PYTHON% EQU 1 (
  208. if %BUILD_PYTHON_LAYER% EQU 1 (
  209. :: Run python tests only in Release build since
  210. :: the _caffe module is _caffe-d is debug
  211. if "%CMAKE_CONFIG%"=="Release" (
  212. :: Run the python tests
  213. cmake --build . --target pytest
  214.  
  215. if ERRORLEVEL 1 (
  216. echo ERROR: Python tests failed
  217. exit /b 1
  218. )
  219. )
  220. )
  221. )
  222. )
  223.  
  224. if %RUN_INSTALL% EQU 1 (
  225. cmake --build . --target install --config %CMAKE_CONFIG%
  226. )
  227.  
  228. popd
  229. @endlocal
Add Comment
Please, Sign In to add comment