Skip to content

Commit 6402a42

Browse files
yf225ezyang
authored andcommitted
Improve win-build.sh for local build (#8674)
1 parent be3e3f2 commit 6402a42

File tree

1 file changed

+32
-14
lines changed

1 file changed

+32
-14
lines changed

.jenkins/pytorch/win-build.sh

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
#!/bin/bash
22

33
# If you want to rebuild, run this with REBUILD=1
4+
# If you want to build with CUDA, run this with USE_CUDA=1
5+
# If you want to build without CUDA, run this with USE_CUDA=0
6+
7+
if [ ! -f setup.py ]; then
8+
echo "ERROR: Please run this build script from PyTorch root directory."
9+
exit 1
10+
fi
411

512
COMPACT_JOB_NAME=pytorch-win-ws2016-cuda9-cudnn7-py3-build
613
source "$(dirname "${BASH_SOURCE[0]}")/common.sh"
@@ -109,24 +116,35 @@ set DISTUTILS_USE_SDK=1
109116
110117
set CMAKE_GENERATOR=Ninja
111118
112-
if "%REBUILD%"=="" (
113-
set NO_CUDA=1
114-
python setup.py install
115-
)
116-
if errorlevel 1 exit /b 1
117-
if not errorlevel 0 exit /b 1
118-
if "%REBUILD%"=="" (
119-
sccache --show-stats
120-
sccache --zero-stats
121-
rd /s /q C:\\Jenkins\\Miniconda3\\Lib\\site-packages\\torch
122-
copy %CD%\\tmp_bin\\sccache.exe tmp_bin\\nvcc.exe
119+
if not "%USE_CUDA%"=="1" (
120+
if "%REBUILD%"=="" (
121+
set NO_CUDA=1
122+
python setup.py install
123+
)
124+
if errorlevel 1 exit /b 1
125+
if not errorlevel 0 exit /b 1
123126
)
124127
125-
set CUDA_NVCC_EXECUTABLE=%CD%\\tmp_bin\\nvcc
128+
if not "%USE_CUDA%"=="0" (
129+
if "%REBUILD%"=="" (
130+
sccache --show-stats
131+
sccache --zero-stats
132+
rd /s /q C:\\Jenkins\\Miniconda3\\Lib\\site-packages\\torch
133+
copy %CD%\\tmp_bin\\sccache.exe tmp_bin\\nvcc.exe
134+
)
126135
127-
if "%REBUILD%"=="" set NO_CUDA=
136+
set CUDA_NVCC_EXECUTABLE=%CD%\\tmp_bin\\nvcc
128137
129-
python setup.py install && sccache --show-stats && 7z a %IMAGE_COMMIT_TAG%.7z C:\\Jenkins\\Miniconda3\\Lib\\site-packages\\torch && python ci_scripts\\upload_image.py %IMAGE_COMMIT_TAG%.7z
138+
if "%REBUILD%"=="" set NO_CUDA=0
139+
140+
python setup.py install && sccache --show-stats && (
141+
if "%BUILD_ENVIRONMENT%"=="" (
142+
echo "NOTE: To run `import torch`, please make sure to activate the conda environment by running `call C:\\Jenkins\\Miniconda3\\Scripts\\activate.bat C:\\Jenkins\\Miniconda3` in Command Prompt before running Git Bash."
143+
) else (
144+
7z a %IMAGE_COMMIT_TAG%.7z C:\\Jenkins\\Miniconda3\\Lib\\site-packages\\torch && python ci_scripts\\upload_image.py %IMAGE_COMMIT_TAG%.7z
145+
)
146+
)
147+
)
130148
131149
EOL
132150

0 commit comments

Comments
 (0)