Skip to content

Commit cb73aa3

Browse files
committed
Switch to devtoolset7 for all nightlies
1 parent 9e77954 commit cb73aa3

File tree

6 files changed

+122
-45
lines changed

6 files changed

+122
-45
lines changed

check_binary.sh

+36-23
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,21 @@ fi
3737
echo "Checking that the gcc ABI is what we expect"
3838
if [[ "$(uname)" != 'Darwin' ]]; then
3939
function is_expected() {
40-
if [[ "$DESIRED_DEVTOOLSET" == 'devtoolset7' ]]; then
41-
if [[ "$1" -gt 0 || "$1" == "ON" ]]; then
42-
echo 1
43-
fi
44-
else
45-
if [[ -z "$1" || "$1" == 0 || "$1" == "OFF" ]]; then
46-
echo 1
47-
fi
40+
# This commented out logic is what you'd expect if 'devtoolset7' actually
41+
# built with the new GCC ABI, but it doesn't; it always builds with ABI=0.
42+
# When a compiler is added that does build with new ABI, then replace
43+
# devtoolset7 (and the DESIRED_DEVTOOLSET variable) with your new compiler
44+
#if [[ "$DESIRED_DEVTOOLSET" == 'devtoolset7' ]]; then
45+
# if [[ "$1" -gt 0 || "$1" == "ON" ]]; then
46+
# echo 1
47+
# fi
48+
#else
49+
# if [[ -z "$1" || "$1" == 0 || "$1" == "OFF" ]]; then
50+
# echo 1
51+
# fi
52+
#fi
53+
if [[ -z "$1" || "$1" == 0 || "$1" == "OFF" ]]; then
54+
echo 1
4855
fi
4956
}
5057

@@ -82,21 +89,27 @@ if [[ "$(uname)" != 'Darwin' ]]; then
8289
exit 1
8390
fi
8491

85-
# We also check that there are[not] cxx11 symbols in libtorch
86-
echo "Checking that symbols in libtorch.so have the right gcc abi"
87-
libtorch="${install_root}/lib/libtorch.so"
88-
cxx11_symbols="$(nm "$libtorch" | c++filt | grep __cxx11 | wc -l)" || true
89-
if [[ "$(is_expected $cxx11_symbols)" != 1 ]]; then
90-
if [[ "$cxx11_symbols" == 0 ]]; then
91-
echo "No cxx11 symbols found, but there should be."
92-
else
93-
echo "Found cxx11 symbols but there shouldn't be. Dumping symbols"
94-
nm "$libtorch" | c++filt | grep __cxx11
95-
fi
96-
exit 1
97-
else
98-
echo "cxx11 symbols seem to be in order"
99-
fi
92+
# We also check that there are [not] cxx11 symbols in libtorch
93+
# TODO this doesn't catch everything. Even when building with the old ABI
94+
# there are 44 symbols in the new ABI in the libtorch library, making this
95+
# check return true. This should actually check that the number of new ABI
96+
# symbols is sufficiently large.
97+
# Also, this is wrong on the old ABI, since there are some cxx11 symbols with
98+
# devtoolset7.
99+
#echo "Checking that symbols in libtorch.so have the right gcc abi"
100+
#libtorch="${install_root}/lib/libtorch.so"
101+
#cxx11_symbols="$(nm "$libtorch" | c++filt | grep __cxx11 | wc -l)" || true
102+
#if [[ "$(is_expected $cxx11_symbols)" != 1 ]]; then
103+
# if [[ "$cxx11_symbols" == 0 ]]; then
104+
# echo "No cxx11 symbols found, but there should be."
105+
# else
106+
# echo "Found cxx11 symbols but there shouldn't be. Dumping symbols"
107+
# nm "$libtorch" | c++filt | grep __cxx11
108+
# fi
109+
# exit 1
110+
#else
111+
# echo "cxx11 symbols seem to be in order"
112+
#fi
100113
fi # if on Darwin
101114

102115
###############################################################################

conda/build_pytorch.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
123123
if [[ -z "$MAC_PACKAGE_WORK_DIR" ]]; then
124124
MAC_PACKAGE_WORK_DIR="$(pwd)/tmp_conda_${DESIRED_PYTHON}_$(date +%H%M%S)"
125125
fi
126-
if [[ -z "$WIN_PACKAGE_WORK_DIR" ]]; then
126+
if [[ "$OSTYPE" == "msys" && -z "$WIN_PACKAGE_WORK_DIR" ]]; then
127127
WIN_PACKAGE_WORK_DIR="$(echo $(pwd -W) | tr '/' '\\')\\tmp_conda_${DESIRED_PYTHON}_$(date +%H%M%S)"
128128
fi
129129

@@ -156,6 +156,8 @@ if [[ ! -d "$pytorch_rootdir" ]]; then
156156
fi
157157
pushd "$pytorch_rootdir"
158158
git submodule update --init --recursive
159+
echo "Using Pytorch from "
160+
git --no-pager log --max-count 1
159161
popd
160162

161163
# Windows builds need to install conda
@@ -237,6 +239,9 @@ else
237239
if [[ "$desired_cuda" == "10.0" ]]; then
238240
export CONDA_CUDATOOLKIT_CONSTRAINT=" - cudatoolkit >=10.0,<10.1 # [not osx]"
239241
export MAGMA_PACKAGE=" - magma-cuda100 # [not osx and not win]"
242+
elif [[ "$desired_cuda" == "9.2" ]]; then
243+
export CONDA_CUDATOOLKIT_CONSTRAINT=" - cudatoolkit >=9.2,<9.3 # [not osx]"
244+
export MAGMA_PACKAGE=" - magma-cuda92 # [not osx and not win]"
240245
elif [[ "$desired_cuda" == "9.0" ]]; then
241246
export CONDA_CUDATOOLKIT_CONSTRAINT=" - cudatoolkit >=9.0,<9.1 # [not osx]"
242247
export MAGMA_PACKAGE=" - magma-cuda90 # [not osx and not win]"

conda/switch_cuda_version.sh

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#!/bin/bash
2+
set -ex -o pipefail
3+
14
if [[ "$OSTYPE" == "msys" ]]; then
25
CUDA_DIR="/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v$1"
36
else

manywheel/build.sh

+16
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,22 @@ DEPS_SONAME=(
7171
"libnvrtc-builtins.so"
7272
"libgomp.so.1"
7373
)
74+
elif [[ $CUDA_VERSION == "9.2" ]]; then
75+
DEPS_LIST=(
76+
"/usr/local/cuda/lib64/libcudart.so.9.2"
77+
"/usr/local/cuda/lib64/libnvToolsExt.so.1"
78+
"/usr/local/cuda/lib64/libnvrtc.so.9.2"
79+
"/usr/local/cuda/lib64/libnvrtc-builtins.so"
80+
"/usr/lib64/libgomp.so.1"
81+
)
82+
83+
DEPS_SONAME=(
84+
"libcudart.so.9.2"
85+
"libnvToolsExt.so.1"
86+
"libnvrtc.so.9.2"
87+
"libnvrtc-builtins.so"
88+
"libgomp.so.1"
89+
)
7490
elif [[ $CUDA_VERSION == "10.0" ]]; then
7591
DEPS_LIST=(
7692
"/usr/local/cuda/lib64/libcudart.so.10.0"

update_compiler.sh

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
set -ex
3+
4+
# Expected to be run on a Docker image built from
5+
# https://github.com/pytorch/builder/blob/master/conda/Dockerfile (or the
6+
# manywheel equivalent)
7+
# Updates the compiler toolchain from devtoolset 3 to 7
8+
9+
# ~~~
10+
# Why does this file exist? Why not just update the compiler on the base docker
11+
# images?
12+
#
13+
# So, all the nightlies used to be built on devtoolset3 with the old gcc ABI.
14+
# These packages worked well for most people, but could not be linked against
15+
# by client c++ libraries that were compiled using the new gcc ABI. Since both
16+
# gcc ABIs are still common in the wild, we should be able to support both
17+
# ABIs. Hence, we need a script to alter the compiler on the root docker images
18+
# to configure which ABI we want to build with.
19+
#
20+
# So then this script was written to change from devtoolset3 to devtoolset7. It
21+
# turns out that this doesn't actually fix the problem, since devtoolset7 is
22+
# incapable of building with the new gcc ABI. BUT, devtoolset7 /is/ able to
23+
# build with avx512 instructions, which are needed for fbgemm to get good
24+
# performance. So now this script is called by default on all nightlies.
25+
#
26+
# But we still don't have the new gcc ABI. So what should happen next is
27+
# - Upgrade the compiler on all the base docker images to be devtoolset7.
28+
# There's no reason to keep around devtoolset3. It will never be used.
29+
# - Alter this script to install another compiler toolchain, not a devtoolset#,
30+
# which can build with the new gcc ABI. Then use this script as intended, in
31+
# a parallel suite of new-gcc-ABI nightlies.
32+
#
33+
# When this script is finally changed to build with the new gcc ABI, then we'll
34+
# need to set this variable manually because
35+
# https://github.com/pytorch/pytorch/blob/master/torch/abi-check.cpp sets the
36+
# ABI to 0 by default.
37+
# ``` export _GLIBCXX_USE_CXX11_ABI=1 ```
38+
# Note that this probably needs to get set in the .circleci infra that's
39+
# running this, since env variables set in this file are probably discarded.
40+
# ~~~
41+
42+
# The gcc version should be 4.9.2 right now
43+
echo "Initial gcc version is $(gcc --version)"
44+
45+
# Uninstall devtoolset-3
46+
yum remove -y -q devtoolset-3-gcc devtoolset-3-gcc-c++ devtoolset-3-gcc-gfortran devtoolset-3-binutils
47+
48+
# Install devtoolset-7
49+
yum install -y -q devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-gcc-gfortran devtoolset-7-binutils
50+
51+
# Replace PATH and LD_LIBRARY_PATH to updated devtoolset
52+
export PATH=$(echo $PATH | sed 's/devtoolset-3/devtoolset-7/g')
53+
export LD_LIBRARY_PATH=$(echo $LD_LIBRARY_PATH | sed 's/devtoolset-3/devtoolset-7/g')
54+
55+
# The gcc version should now be 7.3.1
56+
echo "Final gcc version is $(gcc --version)"

upgrade_gcc_abi.sh

+5-21
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,7 @@
11
#!/bin/bash
2-
set -ex
32

4-
# Expected to be run on a Docker image built from
5-
# https://github.com/pytorch/builder/blob/master/conda/Dockerfile (or the
6-
# manywheel equivalent)
7-
# Upgrades the devtoolset from 3 to 7
8-
9-
# The gcc version should be 4.9.2 right now
10-
echo "Initial gcc version is $(gcc --version)"
11-
12-
# Uninstall devtoolset-3
13-
yum remove -y -q devtoolset-3-gcc devtoolset-3-gcc-c++ devtoolset-3-gcc-gfortran devtoolset-3-binutils
14-
15-
# Install devtoolset-7
16-
yum install -y -q devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-gcc-gfortran devtoolset-7-binutils
17-
18-
# Replace PATH and LD_LIBRARY_PATH to updated devtoolset
19-
export PATH=$(echo $PATH | sed 's/devtoolset-3/devtoolset-7/g')
20-
export LD_LIBRARY_PATH=$(echo $LD_LIBRARY_PATH | sed 's/devtoolset-3/devtoolset-7/g')
21-
22-
# The gcc version should now be 7.3.1
23-
echo "Final gcc version is $(gcc --version)"
3+
# This script has been renamed. This redirection only needs to be here for a
4+
# few hours for current outstanding PRs. If you are reading this after July
5+
# 24th then you can remove this safely.
6+
SOURCE_DIR=$(cd $(dirname $0) && pwd)
7+
source "${SOURCE_DIR}/update_compiler.sh"

0 commit comments

Comments
 (0)