Skip to content

Commit e93ece9

Browse files
authored
Add Linux Jenkins scripts to PyTorch repo. (#4910)
Putting these scripts here has a few benefits: 1. PyTorch developers can easily update the scripts without having to ask for permissions to ossci-job-dsl 2. You can test changes in the scripts by opening a PR to PyTorch (functionality is ossci-job-dsl is not easily testable.) 3. If you get one of our stock Docker images, you can run these scripts to trigger a build identical to what would occur in Jenkins (not entirely true yet, but we can make it so.) Signed-off-by: Edward Z. Yang <ezyang@fb.com>
1 parent f0acd68 commit e93ece9

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed

.jenkins/build.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
3+
# Required environment variables:
4+
# $JOB_NAME
5+
# $PYTHON_VERSION
6+
# $GCC_VERSION
7+
#
8+
# TODO: change this script to make use of $BUILD_ENVIRONMENT,
9+
# which we can hard code into Docker images and then these scripts
10+
# will work out of the box without having to set any env vars.
11+
12+
set -ex
13+
14+
export PATH=/opt/conda/bin:$PATH
15+
16+
if [[ "$JOB_NAME" != *cuda* ]]; then
17+
export PATH=/opt/python/${PYTHON_VERSION}/bin:$PATH
18+
export LD_LIBRARY_PATH=/opt/python/${PYTHON_VERSION}/lib:$LD_LIBRARY_PATH
19+
export CC="ccache /usr/bin/gcc-${GCC_VERSION}"
20+
export CXX="ccache /usr/bin/g++-${GCC_VERSION}"
21+
else
22+
# CMake should use ccache symlink for nvcc
23+
export CUDA_NVCC_EXECUTABLE=/usr/local/bin/nvcc
24+
# The ccache wrapper should be able to find the real nvcc
25+
export PATH=/usr/local/cuda/bin:$PATH
26+
27+
# Add CUDA stub/real path to loader path
28+
export LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:$LD_LIBRARY_PATH
29+
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
30+
31+
# Build for Maxwell
32+
export TORCH_CUDA_ARCH_LIST="Maxwell"
33+
export TORCH_NVCC_FLAGS="-Xfatbin -compress-all"
34+
fi
35+
36+
echo "Python Version:"
37+
which python
38+
python --version
39+
40+
pip install -r requirements.txt || true
41+
42+
# This token is used by a parser on Jenkins logs for determining
43+
# if a failure is a legitimate problem, or a problem with the build
44+
# system; to find out more, grep for this string in ossci-job-dsl.
45+
echo "ENTERED_USER_LAND"
46+
47+
time python setup.py install
48+
49+
if [[ "$JOB_NAME" != *cuda* ]]; then
50+
echo "Testing ATen"
51+
time tools/run_aten_tests.sh
52+
fi
53+
54+
echo "EXITED_USER_LAND"

.jenkins/test.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
# Required environment variables:
4+
# $JOB_NAME
5+
# $PYTHON_VERSION
6+
# $GCC_VERSION
7+
8+
export PATH=/opt/conda/bin:$PATH
9+
10+
if [[ "$JOB_NAME" == *cuda* ]]; then
11+
export LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:$LD_LIBRARY_PATH
12+
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
13+
else
14+
export PATH=/opt/python/${PYTHON_VERSION}/bin:$PATH
15+
export LD_LIBRARY_PATH=/opt/python/${PYTHON_VERSION}/lib:$LD_LIBRARY_PATH
16+
17+
# NB: setup.py chokes on a setting of CC='ccache gcc' (two words),
18+
# so we created a symlinked binary that we can pass as CC in one word
19+
mkdir ./ccache
20+
ln -sf "$(which ccache)" ./ccache/gcc-${GCC_VERSION}
21+
ln -sf "$(which ccache)" ./ccache/g++-${GCC_VERSION}
22+
export CC="$PWD/ccache/gcc-${GCC_VERSION}"
23+
export CXX="$PWD/ccache/g++-${GCC_VERSION}"
24+
fi
25+
26+
echo "Installing torchvision at branch master"
27+
rm -rf vision
28+
git clone https://github.com/pytorch/vision --quiet
29+
if [[ "$JOB_NAME" == *cuda* ]]; then
30+
conda install -y pillow
31+
else
32+
pip install pillow
33+
fi
34+
35+
echo "ENTERED_USER_LAND"
36+
37+
echo "Testing pytorch"
38+
export OMP_NUM_THREADS=4
39+
export MKL_NUM_THREADS=4
40+
time test/run_test.sh
41+
42+
pushd vision
43+
time python setup.py install
44+
popd
45+
46+
echo "EXITED_USER_LAND"

0 commit comments

Comments
 (0)