build_compile_environment.bat 8.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
:: Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
::
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
::
::     http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.
::
:: ===============================
S
Shuangchi He 已提交
16
:: Build Paddle compile environment
17 18 19
:: ===============================
:: Description:
::   
S
Shuangchi He 已提交
20
::   Install compile environment for xly CI.
21 22 23 24
::
::   Include:
::     1. CMake 3.17.0
::     2. Git 2.28.0
25 26 27
::     3. Python 3.8.3
::     4. Visual Studio 2017 Community
::     5. CUDA 11.2
28
::     6. java jre
29 30
::     7. sccache
::     8. xly agent
31 32 33

:: Echo command is not required.
@echo off
34
cd /d %~dp0%
35 36 37

:: ===== start step 0: wget tool =====
:: Download wget for windows when there is not wget tool.
38
echo ">>>>>>>> step [0/8]: wget tool"
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
wget --help > nul 2> nul || call:install_wget
goto cmake

:install_wget
echo There is not wget in this PC, will download wget 1.20.
echo Download package from https://eternallybored.org/misc/wget/1.20/64/wget.exe ...
certutil -urlcache -split -f https://eternallybored.org/misc/wget/1.20/64/wget.exe > nul 2> nul
if %errorlevel% == 0 (
  echo Download wget tool into %cd% success.
) else (
  echo Error***** Download wget tool failed, please download it before rerun.
  exit /b 1
) 
goto :eof
:: ===== end step 0: wget tool =====

:: ===== start step 1: cmake =====
:: Download CMake-3.17.0 and add in PATH when it not installed.
:: TODO: limit version >= 3.17.0
:cmake
59
echo ">>>>>>>> step [1/8]: CMake 3.17.0"
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
cmake --help > nul 2> nul || call :install_cmake
goto git

:install_cmake
echo There is not cmake in this PC, will install cmake-3.17.0.
echo Download package from https://cmake.org/files/v3.17/cmake-3.17.0-win64-x64.msi ...
wget -O cmake-3.17.0-win64-x64.msi https://cmake.org/files/v3.17/cmake-3.17.0-win64-x64.msi
echo Install cmake-3.17.0 ...
:: /passive [silent installation]
:: /norestart [do not restart]
:: ADD_CMAKE_TO_PATH = System [add CMake to the system PATH for all users]
start /wait cmake-3.17.0-win64-x64.msi /passive /norestart ADD_CMAKE_TO_PATH=System
if %errorlevel% == 0 (
  echo Install CMake-3.17.0 success!
) else (
  echo Error***** Install Cmake-3.17.0 failed, please re-install it manually.
)
goto :eof
:: ===== end step 1: cmake =====

:: ===== start step 2: Git =====
:: Download Git-2.28.0 and add in PATH when it not installed.
:: TODO: limit version >= 2.28.0
:git
echo ">>>>>>>> step [2/8]: Git 2.28.0"
git --help > nul 2> nul || call :install_git
goto python

:install_git
echo There is not git in this PC, will install Git-2.28.0.
echo Download package from https://github.com/git-for-windows/git/releases/download/v2.28.0.windows.1/Git-2.28.0-64-bit.exe ...
wget -O Git-2.28.0-64-bit.exe https://github.com/git-for-windows/git/releases/download/v2.28.0.windows.1/Git-2.28.0-64-bit.exe
echo Install Git-2.28.0 ...
:: /SILENT [silent install]
:: /ALLUSERS [add path for all users]
:: /NORESTART [do not restart]
start /wait Git-2.28.0-64-bit.exe /SILENT /ALLUSERS /NORESTART
if %errorlevel% == 0 (
  echo Install Git-2.28.0 success!
) else (
  echo Error***** Install Git-2.28.0 failed, please re-install it manually.
)
goto :eof
:: ===== end step 2: Git =====

:: ===== start step 3: Python =====
106 107
:: Download Python-3.8.3 and add in PATH when it not installed.
:: TODO: limit version >= 3.8.3
108
:python
109
echo ">>>>>>>> step [3/8]: Python 3.8.3"
110 111
python -V 2>&1 | findstr /C:"Python 3.8.3" > nul 2> nul || call :install_python
goto vs
112 113

:install_python
114 115 116 117
echo There is not Python in this PC, will install Python-3.8.3
echo Download package from https://paddle-ci.gz.bcebos.com/window_requirement/python-3.8.3-amd64.exe ...
wget -O python-3.8.3-amd64.exe https://paddle-ci.gz.bcebos.com/window_requirement/python-3.8.3-amd64.exe
echo Install Python-3.8.3 ...
118 119 120 121
:: /passive [silent install]
:: InstallAllUsers [add path for all users]
:: PrependPath [add script/install into PATH]
:: TargetDir [install directory]
122
start /wait python-3.8.3-amd64.exe /passive InstallAllUsers=1 PrependPath=1 TargetDir=C:\Python38
123
if %errorlevel% == 0 (
124
  echo Install python-3.8.3 success!
125
) else (
126
  echo Error***** Install python-3.8.3 failed, please re-install it manually.
127 128 129 130
)
goto :eof
:: ===== end step 3: Python =====

131 132 133
:: ===== start step 4: Visual Studio 2017 Community =====
:: Download Visual Studio 2017 when it not installed.
:vs
134
echo ">>>>>>>> step [4/8]: Visual Studio 2017 "
135
cmd /C "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"  > nul 2> nul || call :install_visual_studio
136
goto :cuda
137 138

:install_visual_studio
139 140 141 142
echo There is not Visual Studio in this PC, will install VS2017.
echo Download package from "https://paddle-ci.gz.bcebos.com/window_requirement/VS2017/vs_Community.exe"
wget -O vs_Community.exe "https://paddle-ci.gz.bcebos.com/window_requirement/VS2017/vs_Community.exe"
echo Install Visual Studio 2017 ...
143 144 145 146
:: /passive [silent install]
:: /norestart [no restart]
:: /NoRefresh [no refresh]
:: /InstallSelectableItems NativeLanguageSupport_Group [select Visual C++ for installing]
147
start /wait vs_Community.exe --passive --add Microsoft.VisualStudio.Workload.NativeDesktop --add Microsoft.VisualStudio.Workload.Universal --includeRecommended
148
if %errorlevel% == 0 (
149
  echo Install Visual Studio 2017 success!
150
) else (
151
  echo Error***** Install Visual Studio 2017 failed, please re-install it manually.
152 153
)
goto :eof
154
:: ===== end step 4: Visual Studio 2017 =====
155

156
:: ===== start step 5: CUDA 11 =====
157
:cuda
158
echo ">>>>>>>> step [5/8]: CUDA 11.2"
159
cmd /C nvcc --version 2> nul | findstr /C:"11.2" > nul 2> nul || call :install_cuda
160 161 162
goto java-jre

:install_cuda
163 164 165 166
echo There is not CUDA in this PC, will install CUDA-11.2.
echo Download package from "https://paddle-ci.gz.bcebos.com/window_requirement/cuda_11.2.0_460.89_win10.exe"
wget -O cuda_installer.exe "https://paddle-ci.gz.bcebos.com/window_requirement/cuda_11.2.0_460.89_win10.exe"
echo Install CUDA-11.2 ...
167 168 169
:: -s [silent install]
start /wait cuda_installer.exe -s
if %errorlevel% == 0 (
170
  echo Install CUDA-11.2 success!
171
) else (
172
  echo Error***** Install CUDA-11.2 failed, please re-install it manually.
173
  goto :eof
174 175
)
del cuda_installer.exe
176

177 178 179 180 181 182
echo Download cudnn from "https://paddle-ci.gz.bcebos.com/window_requirement/cudnn-11.2-windows-x64-v8.1.0.77.zip"
wget -O cudnn-11.2-windows-x64-v8.1.0.77.zip "https://paddle-ci.gz.bcebos.com/window_requirement/cudnn-11.2-windows-x64-v8.1.0.77.zip"
tar xf cudnn-11.2-windows-x64-v8.1.0.77.zip
xcopy /E /Y /R "cuda\bin\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin"
xcopy /E /Y /R "cuda\include\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include"
xcopy /E /Y /R "cuda\lib\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\lib"
183
rd /s /q cuda
184 185 186 187 188
goto :eof
:: ===== end step 5: CUDA 10 =====

:: ===== start step 6: java jre =====
:java-jre
189
echo ">>>>>>>> step [6/8]: java jre"
190
cmd /C java -version > nul 2> nul || call :install_java
191
goto sccache
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206

:install_java
echo There is not java-jre in this PC, will install java-jre.
echo Download package from "https://paddle-ci.gz.bcebos.com/window_requirement/jre-8u261-windows-i586.exe"
wget -O jre-8u261-windows-x64.exe "https://paddle-ci.gz.bcebos.com/window_requirement/jre-8u261-windows-i586.exe"
echo Install java-jre ...
:: -s [silent install]
start /wait jre-8u261-windows-x64.exe /s
if %errorlevel% == 0 (
  echo Install java success!
) else (
  echo Error***** Install java failed, please re-install it manually.
)
del jre-8u261-windows-x64.exe
goto :eof
207 208
:: ===== end step 6: java jre =====

209 210 211 212 213 214 215 216 217 218 219 220 221 222
:: ===== start step 7: sccache on windowss =====
:sccache
echo ">>>>>>>> step [7/8]: sccache"
cmd /C sccache -V > nul 2> nul || call :download_sccache
goto xly-agent

:download_sccache
echo There is not sccache in this PC, will install sccache.
echo Download package from https://paddle-ci.gz.bcebos.com/window_requirement/sccache.exe
wget -O sccache.exe "https://paddle-ci.gz.bcebos.com/window_requirement/sccache.exe"
copy sccache.exe C:\Python38 /Y 
:: ===== end step 7: sccache on windows =====

:: ===== start step 8: xly agent =====
223
:xly-agent
224
echo ">>>>>>>> step [8/8]: xly agent"
225
wget -O agent.jar "https://xly.bce.baidu.com/sa_server/agent/v1/download?version=1.2.8"
226 227 228
:: ===== end step 8: xly agent =====

pause