14
14
15
15
if [ " $# " -ne 3 ]; then
16
16
echo " Illegal number of parameters. Pass cuda version, pytorch version, build number"
17
+ echo " CUDA version should be Mm with no dot, e.g. '80'"
18
+ echo " DESIRED_PYTHON should be M.m, e.g. '2.7'"
17
19
exit 1
18
20
fi
19
21
35
37
PYTORCH_BRANCH=" v$build_version "
36
38
fi
37
39
40
+ # Don't upload the packages until we've verified that they're correct
41
+ conda config --set anaconda_upload no
42
+
38
43
# Fill in missing env variables
39
44
if [ -z " $ANACONDA_TOKEN " ]; then
40
45
# Token needed to upload to the conda channel above
47
52
if [[ -z " $GITHUB_ORG " ]]; then
48
53
GITHUB_ORG=' pytorch'
49
54
fi
50
-
51
- if [[ " $OSTYPE " == " darwin" * ]]; then
52
- DEVELOPER_DIR=/Applications/Xcode9.app/Contents/Developer
53
- fi
54
-
55
- # Don't upload the packages until we've verified that they're correct
56
- conda config --set anaconda_upload no
57
-
58
- # Keep an array of cmake variables to add to
59
55
if [[ -z " $CMAKE_ARGS " ]]; then
60
56
# These are passed to tools/build_pytorch_libs.sh::build()
61
57
CMAKE_ARGS=()
@@ -64,74 +60,77 @@ if [[ -z "$EXTRA_CAFFE2_CMAKE_FLAGS" ]]; then
64
60
# These are passed to tools/build_pytorch_libs.sh::build_caffe2()
65
61
EXTRA_CAFFE2_CMAKE_FLAGS=()
66
62
fi
67
-
68
- # Build for a specified Python, or if none were given then all of them
69
63
if [[ -z " $DESIRED_PYTHON " ]]; then
70
64
DESIRED_PYTHON=(' 2.7' ' 3.5' ' 3.6' ' 3.7' )
71
65
fi
66
+ if [[ " $OSTYPE " == " darwin" * ]]; then
67
+ DEVELOPER_DIR=/Applications/Xcode9.app/Contents/Developer
68
+ fi
69
+ if [[ " $desired_cuda " == ' cpu' ]]; then
70
+ cpu_only=1
71
+ else
72
+ # Switch desired_cuda to be M.m to be consistent with other scripts in
73
+ # pytorch/builder
74
+ cuda_nodot=" $desired_cuda "
75
+ desired_cuda=" ${desired_cuda: 0: 1} .${desired_cuda: 1: 1} "
76
+ fi
77
+
78
+
72
79
echo " Will build for all Pythons: ${DESIRED_PYTHON[@]} "
73
- echo " Will build for all CUDA versions : ${desired_cuda[@] } "
80
+ echo " Will build for CUDA version : ${desired_cuda} "
74
81
75
82
# Determine which build folder to use, if not given it directly
76
83
if [[ -n " $TORCH_CONDA_BUILD_FOLDER " ]]; then
77
84
build_folder=" $TORCH_CONDA_BUILD_FOLDER "
78
85
else
79
- if [[ " $OSTYPE " == ' darwin' * || " $desired_cuda " == ' 90 ' ]]; then
86
+ if [[ " $OSTYPE " == ' darwin' * || " $desired_cuda " == ' 9.0 ' ]]; then
80
87
build_folder=' pytorch'
81
- elif [[ " $desired_cuda " == ' cpu ' ]]; then
88
+ elif [[ -n " $cpu_only " ]]; then
82
89
build_folder=' pytorch-cpu'
83
90
else
84
- build_folder=" pytorch-$desired_cuda "
91
+ build_folder=" pytorch-$cuda_nodot "
85
92
fi
86
93
build_folder=" $build_folder -$build_version "
87
94
fi
88
95
meta_yaml=" $build_folder /meta.yaml"
89
96
echo " Using conda-build folder $build_folder "
90
97
91
98
# Clone the Pytorch repo, so that we can call run_test.py in it
92
- pytorch_rootdir=" root_${GITHUB_ORG} pytorch${PYTORCH_BRANCH} "
99
+ pytorch_rootdir=" $( pwd ) / root_${GITHUB_ORG} pytorch${PYTORCH_BRANCH} "
93
100
rm -rf " $pytorch_rootdir "
94
- git clone " https://github.com/$GITHUB_ORG /pytorch.git" " $pytorch_rootdir "
101
+ git clone --recursive " https://github.com/$GITHUB_ORG /pytorch.git" " $pytorch_rootdir "
95
102
pushd " $pytorch_rootdir "
96
103
git checkout " $PYTORCH_BRANCH "
97
104
popd
98
105
99
106
# Switch between CPU or CUDA configerations
100
- build_string =" $PYTORCH_BUILD_NUMBER "
101
- if [[ " $desired_cuda " == ' cpu ' ]]; then
107
+ build_string_suffix =" $PYTORCH_BUILD_NUMBER "
108
+ if [[ -n " $cpu_only " ]]; then
102
109
export NO_CUDA=1
103
110
export CUDA_VERSION=" 0.0"
104
111
export CUDNN_VERSION=" 0.0"
105
- $portable_sed ' /cudatoolkit/d' " $meta_yaml "
106
112
if [[ " $OSTYPE " != " darwin" * ]]; then
107
- build_string= " _cpu_ ${build_string }"
113
+ build_string_suffix= " cpu_ ${build_string_suffix }"
108
114
fi
115
+ $portable_sed " /magma-cuda.*/d" " $meta_yaml "
109
116
else
110
117
# Switch the CUDA version that /usr/local/cuda points to. This script also
111
118
# sets CUDA_VERSION and CUDNN_VERSION
112
- echo " Switching to CUDA version ${desired_cuda: 0: 1} .${desired_cuda: 1: 1} "
113
- . ./switch_cuda_version.sh " ${desired_cuda: 0: 1} .${desired_cuda: 1: 1} "
114
- $portable_sed " s/cudatoolkit =[0-9]/cudatoolkit =${desired_cuda: 0: 1} /g" " $meta_yaml "
115
- build_string=" _${CUDA_VERSION} _${CUDNN_VERSION} _${build_string} "
116
- if [[ " $desired_cuda " == 92 ]]; then
119
+ echo " Switching to CUDA version $desired_cuda "
120
+ . ./switch_cuda_version.sh " $desired_cuda "
121
+ build_string_suffix=" cuda${CUDA_VERSION} _cudnn${CUDNN_VERSION} _${build_string_suffix} "
122
+ if [[ " $desired_cuda " == ' 9.2' ]]; then
117
123
# ATen tests can't build with CUDA 9.2 and the old compiler used here
118
124
EXTRA_CAFFE2_CMAKE_FLAGS+=(" -DATEN_NO_TEST=ON" )
119
125
fi
120
126
ALLOW_DISTRIBUTED_TEST_ERRORS=1
121
127
fi
122
128
123
- # Alter the meta.yaml to use passed in Github repo/branch
124
- $portable_sed " s#git_url:.*#git_url: https://github.com/$GITHUB_ORG /pytorch#g" " $meta_yaml "
125
- $portable_sed " s#git_rev:.*#git_rev: $PYTORCH_BRANCH #g" " $meta_yaml "
126
-
127
129
# Loop through all Python versions to build a package for each
128
130
for py_ver in " ${DESIRED_PYTHON[@]} " ; do
129
- build_string=" py${py_ver: 0 : 1}${py_ver : 2 : 1} _${build_string } "
131
+ build_string=" py${py_ver} _${build_string_suffix } "
130
132
folder_tag=" ${build_string} _$( date +' %Y%m%d' ) "
131
133
132
- # Rewrite the build string in meta.yaml to handle cpu-only packages
133
- $portable_sed " s/string:.*/string: ${build_string} /g" " $meta_yaml "
134
-
135
134
# Create the conda package into this temporary folder. This is so we can find
136
135
# the package afterwards, as there's no easy way to extract the final filename
137
136
# from conda-build
@@ -143,6 +142,9 @@ for py_ver in "${DESIRED_PYTHON[@]}"; do
143
142
echo " Build $build_folder for Python version $py_ver "
144
143
time CMAKE_ARGS=${CMAKE_ARGS[@]} \
145
144
EXTRA_CAFFE2_CMAKE_FLAGS=${EXTRA_CAFFE2_CMAKE_FLAGS[@]} \
145
+ PYTORCH_GITHUB_ROOT_DIR=" $pytorch_rootdir " \
146
+ PYTORCH_BUILD_STRING=" $build_string " \
147
+ PYTORCH_MAGMA_CUDA_VERSION=" $cuda_nodot " \
146
148
conda build -c " $ANACONDA_USER " \
147
149
--no-anaconda-upload \
148
150
--python " $py_ver " \
@@ -156,9 +158,6 @@ for py_ver in "${DESIRED_PYTHON[@]}"; do
156
158
conda create -yn " $test_env " python=" $py_ver "
157
159
source activate " $test_env "
158
160
conda install -y numpy> =1.11 mkl> =2018 cffi ninja
159
- if [[ " $desired_cuda " == 80 || " $desired_cuda " == 90 ]]; then
160
- conda install -y cudatoolkit==" ${desired_cuda: 0: 1} "
161
- fi
162
161
163
162
# Extract the package for testing
164
163
ls -lah " $output_folder "
@@ -185,8 +184,9 @@ for py_ver in "${DESIRED_PYTHON[@]}"; do
185
184
# Clean up test folder
186
185
source deactivate
187
186
conda env remove -yn " $test_env "
188
- # rm -rf "$output_folder"
187
+ rm -rf " $output_folder "
189
188
done
189
+ rm -rf " $pytorch_rootdir "
190
190
191
191
unset PYTORCH_BUILD_VERSION
192
192
unset PYTORCH_BUILD_NUMBER
0 commit comments