3
3
set -ex
4
4
5
5
if [[ -z " $PYTORCH_BUILD_VERSION " ]]; then
6
- export PYTORCH_BUILD_VERSION=0.4.1
6
+ export PYTORCH_BUILD_VERSION=0.4.1
7
7
fi
8
8
if [[ -z " $PYTORCH_BUILD_NUMBER " ]]; then
9
- export PYTORCH_BUILD_NUMBER=2
9
+ export PYTORCH_BUILD_NUMBER=2
10
10
fi
11
11
export CMAKE_LIBRARY_PATH=" /opt/intel/lib:/lib:$CMAKE_LIBRARY_PATH "
12
12
export CMAKE_INCLUDE_PATH=" /opt/intel:$CMAKE_INCLUDE_PATH "
46
46
47
47
# Build for given Python versions, or for all in /opt/python if none given
48
48
if [[ -z " $DESIRED_PYTHON " ]]; then
49
- DESIRED_PYTHON=($( ls -d /opt/python/* /) )
49
+ pushd /opt/python
50
+ DESIRED_PYTHON=(* /)
51
+ popd
50
52
fi
51
- for (( i= 0 ; i< "${# DESIRED_PYTHON[@]} "; i++ )) ; do
52
- # Convert eg. cp27-cp27m to /opt/python/cp27-cp27m
53
- if [[ ! -d " ${DESIRED_PYTHON[$i]} " ]]; then
54
- if [[ -d " /opt/python/${DESIRED_PYTHON[$i]} " ]]; then
55
- DESIRED_PYTHON[$i ]=" /opt/python/${DESIRED_PYTHON[$i]} "
56
- else
57
- echo " Error: Given Python ${DESIRED_PYTHON[$i]} is not in /opt/python"
58
- echo " All array elements of env variable DESIRED_PYTHON must be"
59
- echo " valid Python installations under /opt/python"
60
- exit 1
53
+ python_installations=()
54
+ for desired_py in " ${DESIRED_PYTHON[@]} " ; do
55
+ python_installations+=(" /opt/python/$desired_py " )
56
+ if [[ ! -d " /opt/python/$desired_py " ]]; then
57
+ echo " Error: Given Python $desired_py is not in /opt/python"
58
+ echo " All array elements of env variable DESIRED_PYTHON must be"
59
+ echo " valid Python installations under /opt/python"
60
+ exit 1
61
61
fi
62
- fi
63
62
done
64
- echo " Will build for all Pythons: ${DESIRED_PYTHON[@]} "
63
+ echo " Will build for all Pythons versions : ${DESIRED_PYTHON[@]} "
65
64
66
65
67
66
# ########################################################
@@ -70,26 +69,26 @@ echo "Will build for all Pythons: ${DESIRED_PYTHON[@]}"
70
69
# clone pytorch source code
71
70
PYTORCH_DIR=" /pytorch"
72
71
if [[ ! -d " $PYTORCH_DIR " ]]; then
73
- git clone https://github.com/pytorch/pytorch $PYTORCH_DIR
74
- pushd $PYTORCH_DIR
75
- if ! git checkout v${PYTORCH_BUILD_VERSION} ; then
76
- git checkout tags/v${PYTORCH_BUILD_VERSION}
77
- fi
72
+ git clone https://github.com/pytorch/pytorch $PYTORCH_DIR
73
+ pushd $PYTORCH_DIR
74
+ if ! git checkout v${PYTORCH_BUILD_VERSION} ; then
75
+ git checkout tags/v${PYTORCH_BUILD_VERSION}
76
+ fi
78
77
else
79
- # the pytorch dir will already be cloned and checked-out on jenkins jobs
80
- pushd $PYTORCH_DIR
78
+ # the pytorch dir will already be cloned and checked-out on jenkins jobs
79
+ pushd $PYTORCH_DIR
81
80
fi
82
81
git submodule update --init --recursive
83
82
84
83
OLD_PATH=$PATH
85
- for PYDIR in " ${DESIRED_PYTHON [@]} " ; do
84
+ for PYDIR in " ${python_installations [@]} " ; do
86
85
export PATH=$PYDIR /bin:$OLD_PATH
87
86
python setup.py clean
88
87
pip install -r requirements.txt
89
88
if [[ $PYDIR == " /opt/python/cp37-cp37m" ]]; then
90
- pip install numpy==1.15
89
+ pip install numpy==1.15
91
90
else
92
- pip install numpy==1.11
91
+ pip install numpy==1.11
93
92
fi
94
93
time python setup.py bdist_wheel -d $WHEELHOUSE_DIR
95
94
done
@@ -110,11 +109,11 @@ fname_with_sha256() {
110
109
DIRNAME=$( dirname $1 )
111
110
BASENAME=$( basename $1 )
112
111
if [[ $BASENAME == " libnvrtc-builtins.so" ]]; then
113
- echo $1
112
+ echo $1
114
113
else
115
- INITNAME=$( echo $BASENAME | cut -f1 -d" ." )
116
- ENDNAME=$( echo $BASENAME | cut -f 2- -d" ." )
117
- echo " $DIRNAME /$INITNAME -$HASH .$ENDNAME "
114
+ INITNAME=$( echo $BASENAME | cut -f1 -d" ." )
115
+ ENDNAME=$( echo $BASENAME | cut -f 2- -d" ." )
116
+ echo " $DIRNAME /$INITNAME -$HASH .$ENDNAME "
118
117
fi
119
118
}
120
119
@@ -274,9 +273,13 @@ for whl in /$WHEELHOUSE_DIR/torch*linux*.whl; do
274
273
rm -rf tmp
275
274
done
276
275
277
- # Print out sizes of all wheels created
278
- echo " Succesfulle made wheels of size:"
279
- du -h /$WHEELHOUSE_DIR /torch* .whl
276
+ # Take the actual package name. Note how this always works because pip converts
277
+ # - to _ in names.
278
+ pushd /$WHEELHOUSE_DIR
279
+ built_wheels=(torch* .whl)
280
+ IFS=' -' read -r package_name some_unused_variable <<< " ${built_wheels[0]}"
281
+ echo " Expecting the built wheels to all be called '$package_name '"
282
+ popd
280
283
281
284
# Copy wheels to host machine for persistence after the docker
282
285
mkdir -p /remote/$WHEELHOUSE_DIR
@@ -286,22 +289,31 @@ cp /$WHEELHOUSE_DIR/torch*.whl /remote/$WHEELHOUSE_DIR/
286
289
rm -rf /usr/local/cuda*
287
290
rm -rf /opt/rh
288
291
289
- # The package's name that we made could be torch-nightly
290
- if [[ -n " $TORCH_PACKAGE_NAME " ]]; then
291
- package_name=" $TORCH_PACKAGE_NAME "
292
- else
293
- package_name=' torch'
294
- fi
295
- echo " Expecting the built wheels to be packages for '$package_name '"
296
-
297
292
298
293
# Test that all the wheels work
299
294
export OMP_NUM_THREADS=4 # on NUMA machines this takes too long
300
295
pushd $PYTORCH_DIR /test
301
- for PYDIR in " ${DESIRED_PYTHON[@]} " ; do
302
- " ${PYDIR} /bin/pip" uninstall -y " $package_name "
303
- " ${PYDIR} /bin/pip" install " $package_name " --no-index -f /$WHEELHOUSE_DIR
304
- LD_LIBRARY_PATH=" /usr/local/nvidia/lib64" PYCMD=$PYDIR /bin/python $PYDIR /bin/python run_test.py --exclude distributed
296
+ for (( i= 0 ; i< "${# DESIRED_PYTHON[@]} "; i++ )) ; do
297
+ # This assumes that there is a 1:1 correspondence between python versions
298
+ # and wheels, and that the python version is in the name of the wheel,
299
+ # and that the python version matches the regex "cp\d\d-cp\d\dmu?"
300
+ pydir=" ${python_installations[i]} "
301
+ pyver=" ${DESIRED_PYTHON[i]} "
302
+ pyver_short=" ${pyver: 2: 1} .${pyver: 3: 1} "
303
+
304
+ # Install the wheel for this Python version
305
+ " ${pydir} /bin/pip" uninstall -y " $package_name "
306
+ " ${pydir} /bin/pip" install " $package_name " --no-index -f /$WHEELHOUSE_DIR --no-dependencies
307
+
308
+ # Print info on the libraries installed in this wheel
309
+ installed_libraries=($( find " $pydir /lib/python$pyver_short /site-packages/torch/" -name ' *.so*' ) )
310
+ echo " The wheel installed all of the libraries: ${installed_libraries[@]} "
311
+ for installed_lib in " ${installed_libraries[@]} " ; do
312
+ ldd " $installed_lib "
313
+ done
314
+
315
+ # Test that the wheel works
316
+ LD_LIBRARY_PATH=" /usr/local/nvidia/lib64" PYCMD=$pydir /bin/python $pydir /bin/python run_test.py --exclude distributed
305
317
306
318
# Distributed tests are not expected to work on shared GPU machines (as of
307
319
# 8/06/2018) so the errors from test_distributed are ignored. Expected
0 commit comments