Skip to content

Commit c3807f9

Browse files
authored
fix Windows CI unstable (#33606)
修复Windows CI的一些突发新增的不稳定现象: 清理服务器后台未正常退出的进程 支持外部手动修改cache缓存目录
1 parent 7bbeeb5 commit c3807f9

File tree

1 file changed

+31
-25
lines changed

1 file changed

+31
-25
lines changed

paddle/scripts/paddle_build.bat

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,18 @@ rem Paddle CI Task On Windows Platform
1818
rem =================================================
1919

2020
@ECHO ON
21-
setlocal
21+
setlocal enabledelayedexpansion
2222

2323
rem -------clean up environment-----------
2424
set work_dir=%cd%
25-
set cache_dir=%work_dir:Paddle=cache%
25+
if not defined cache_dir set cache_dir=%work_dir:Paddle=cache%
2626
if not exist %cache_dir%\tools (
2727
git clone https://github.com/zhouwei25/tools.git %cache_dir%\tools
2828
)
29-
taskkill /f /im op_function_generator.exe 2>NUL
3029
taskkill /f /im cmake.exe 2>NUL
3130
taskkill /f /im MSBuild.exe 2>NUL
32-
taskkill /f /im CL.exe 2>NUL
33-
taskkill /f /im Lib.exe 2>NUL
31+
taskkill /f /im cl.exe 2>NUL
32+
taskkill /f /im lib.exe 2>NUL
3433
taskkill /f /im link.exe 2>NUL
3534
taskkill /f /im vctip.exe 2>NUL
3635
taskkill /f /im cvtres.exe 2>NUL
@@ -41,14 +40,12 @@ taskkill /f /im python.exe 2>NUL
4140
taskkill /f /im nvcc.exe 2>NUL
4241
taskkill /f /im cicc.exe 2>NUL
4342
taskkill /f /im ptxas.exe 2>NUL
44-
taskkill /f /im test_api_impl.exe 2>NUL
4543
taskkill /f /im op_function_generator.exe 2>NUL
4644
wmic process where name="op_function_generator.exe" call terminate 2>NUL
47-
wmic process where name="test_api_impl.exe" call terminate 2>NUL
4845
wmic process where name="cvtres.exe" call terminate 2>NUL
4946
wmic process where name="rc.exe" call terminate 2>NUL
50-
wmic process where name="CL.exe" call terminate 2>NUL
51-
wmic process where name="Lib.exe" call terminate 2>NUL
47+
wmic process where name="cl.exe" call terminate 2>NUL
48+
wmic process where name="lib.exe" call terminate 2>NUL
5249
wmic process where name="python.exe" call terminate 2>NUL
5350

5451
rem ------initialize common variable------
@@ -66,7 +63,7 @@ if not defined WITH_PYTHON set WITH_PYTHON=ON
6663
if not defined ON_INFER set ON_INFER=ON
6764
if not defined WITH_INFERENCE_API_TEST set WITH_INFERENCE_API_TEST=ON
6865
if not defined WITH_STATIC_LIB set WITH_STATIC_LIB=ON
69-
if not defined WITH_TPCACHE set WITH_TPCACHE=ON
66+
if not defined WITH_TPCACHE set WITH_TPCACHE=OFF
7067
if not defined WITH_CLCACHE set WITH_CLCACHE=OFF
7168
if not defined WITH_CACHE set WITH_CACHE=OFF
7269
if not defined WITH_UNITY_BUILD set WITH_UNITY_BUILD=OFF
@@ -79,6 +76,7 @@ if not defined PYTHON_ROOT set PYTHON_ROOT=C:\Python37
7976

8077
rem -------set cache build directory-----------
8178
rmdir build\python /s/q
79+
rem rmdir build\paddle\fluid\pybind /s/q
8280
rmdir build\paddle_install_dir /s/q
8381
rmdir build\paddle_inference_install_dir /s/q
8482
rmdir build\paddle_inference_c_install_dir /s/q
@@ -137,10 +135,11 @@ goto :CASE_%1
137135

138136
echo "Usage: paddle_build.bat [OPTION]"
139137
echo "OPTION:"
140-
echo "wincheck_mkl: run Windows MKL/GPU/UnitTest CI tasks on Windows"
141-
echo "wincheck_openbals: run Windows OPENBLAS/CPU CI tasks on Windows"
138+
echo "wincheck_mkl: run Windows MKL/GPU PR CI tasks on Windows"
139+
echo "wincheck_openbals: run Windows OPENBLAS/CPU PR CI tasks on Windows"
142140
echo "build_avx_whl: build Windows avx whl package on Windows"
143141
echo "build_no_avx_whl: build Windows no avx whl package on Windows"
142+
echo "build_inference_lib: build Windows inference library on Windows"
144143
exit /b 1
145144

146145
rem ------PR CI windows check for MKL/GPU----------
@@ -200,6 +199,7 @@ goto:success
200199

201200
rem ------Build windows inference library------
202201
:CASE_build_inference_lib
202+
set ON_INFER=ON
203203
set WITH_PYTHON=OFF
204204
set CUDA_ARCH_NAME=All
205205

@@ -226,6 +226,8 @@ call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary
226226
set DISTUTILS_USE_SDK=1
227227
rem Windows 10 Kit bin dir
228228
set PATH=C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64;%PATH%
229+
rem Use 64-bit ToolSet to compile
230+
set PreferredToolArchitecture=x64
229231

230232
for /F %%# in ('wmic os get localdatetime^|findstr 20') do set start=%%#
231233
set start=%start:~4,10%
@@ -250,14 +252,15 @@ if "%WITH_GPU%"=="ON" (
250252
)
251253

252254
rem ------initialize the python environment------
255+
@ECHO ON
253256
set PYTHON_EXECUTABLE=%PYTHON_ROOT%\python.exe
254257
set PATH=%PYTHON_ROOT%;%PYTHON_ROOT%\Scripts;%PATH%
255-
if %WITH_PYTHON% == "OFF" (
258+
if "%WITH_PYTHON%" == "ON" (
256259
where python
257260
where pip
258261
pip install wheel --user
259262
pip install -r %work_dir%\python\requirements.txt --user
260-
if %ERRORLEVEL% NEQ 0 (
263+
if !ERRORLEVEL! NEQ 0 (
261264
echo pip install requirements.txt failed!
262265
exit /b 7
263266
)
@@ -318,7 +321,7 @@ if "%WITH_GPU%"=="ON" (
318321
)
319322

320323
:cmake_impl
321-
echo cmake .. -G %GENERATOR% -T host=x64 -DCMAKE_BUILD_TYPE=Release -DWITH_AVX=%WITH_AVX% -DWITH_GPU=%WITH_GPU% -DWITH_MKL=%WITH_MKL% ^
324+
echo cmake .. -G %GENERATOR% -DCMAKE_BUILD_TYPE=Release -T host=x64 -DWITH_AVX=%WITH_AVX% -DWITH_GPU=%WITH_GPU% -DWITH_MKL=%WITH_MKL% ^
322325
-DWITH_TESTING=%WITH_TESTING% -DWITH_PYTHON=%WITH_PYTHON% -DPYTHON_EXECUTABLE=%PYTHON_EXECUTABLE% -DON_INFER=%ON_INFER% ^
323326
-DWITH_INFERENCE_API_TEST=%WITH_INFERENCE_API_TEST% -DTHIRD_PARTY_PATH=%THIRD_PARTY_PATH% ^
324327
-DINFERENCE_DEMO_INSTALL_DIR=%INFERENCE_DEMO_INSTALL_DIR% -DWITH_STATIC_LIB=%WITH_STATIC_LIB% ^
@@ -374,6 +377,7 @@ set build_times=1
374377
rem clcache.exe -z
375378

376379
rem -------clean up environment again-----------
380+
taskkill /f /im cmake.exe 2>NUL
377381
taskkill /f /im MSBuild.exe 2>NUL
378382
taskkill /f /im cl.exe 2>NUL
379383
taskkill /f /im lib.exe 2>NUL
@@ -386,18 +390,20 @@ taskkill /f /im csc.exe 2>NUL
386390
taskkill /f /im nvcc.exe 2>NUL
387391
taskkill /f /im cicc.exe 2>NUL
388392
taskkill /f /im ptxas.exe 2>NUL
389-
taskkill /f /im test_api_impl.exe 2>NUL
390393
taskkill /f /im op_function_generator.exe 2>NUL
391394
wmic process where name="op_function_generator.exe" call terminate 2>NUL
392-
wmic process where name="test_api_impl.exe" call terminate 2>NUL
393395
wmic process where name="cvtres.exe" call terminate 2>NUL
394396
wmic process where name="rc.exe" call terminate 2>NUL
395-
wmic process where name="CL.exe" call terminate 2>NUL
396-
wmic process where name="Lib.exe" call terminate 2>NUL
397+
wmic process where name="cl.exe" call terminate 2>NUL
398+
wmic process where name="lib.exe" call terminate 2>NUL
399+
400+
if "%WITH_TESTING%"=="ON" (
401+
for /F "tokens=1 delims= " %%# in ('tasklist ^| findstr /i test') do taskkill /f /im %%#
402+
)
397403

398404
echo Build Paddle the %build_times% time:
399405
if %GENERATOR% == "Ninja" (
400-
ninja -j %PARALLEL_PROJECT_COUNT%
406+
ninja all
401407
) else (
402408
if "%WITH_CLCACHE%"=="OFF" (
403409
MSBuild /m:%PARALLEL_PROJECT_COUNT% /p:PreferredToolArchitecture=x64 /p:TrackFileAccess=false /p:Configuration=Release /verbosity:%LOG_LEVEL% ALL_BUILD.vcxproj
@@ -489,7 +495,6 @@ echo ========================================
489495
echo Step 4. Running unit tests ...
490496
echo ========================================
491497

492-
493498
: set CI_SKIP_CPP_TEST if only *.py changed
494499
git diff --name-only %BRANCH% | findstr /V "\.py" || set CI_SKIP_CPP_TEST=ON
495500

@@ -778,15 +783,16 @@ taskkill /f /im python.exe 2>NUL
778783
taskkill /f /im nvcc.exe 2>NUL
779784
taskkill /f /im cicc.exe 2>NUL
780785
taskkill /f /im ptxas.exe 2>NUL
781-
taskkill /f /im test_api_impl.exe 2>NUL
782786
taskkill /f /im op_function_generator.exe 2>NUL
783787
wmic process where name="op_function_generator.exe" call terminate 2>NUL
784-
wmic process where name="test_api_impl.exe" call terminate 2>NUL
785788
wmic process where name="cvtres.exe" call terminate 2>NUL
786789
wmic process where name="rc.exe" call terminate 2>NUL
787-
wmic process where name="CL.exe" call terminate 2>NUL
788-
wmic process where name="Lib.exe" call terminate 2>NUL
790+
wmic process where name="cl.exe" call terminate 2>NUL
791+
wmic process where name="lib.exe" call terminate 2>NUL
789792
wmic process where name="python.exe" call terminate 2>NUL
793+
if "%WITH_TESTING%"=="ON" (
794+
for /F "tokens=1 delims= " %%# in ('tasklist ^| findstr /i test') do taskkill /f /im %%#
795+
)
790796
echo Windows CI run successfully!
791797
exit /b 0
792798

0 commit comments

Comments
 (0)