Skip to content

conda: add _GLIBCXX_USE_CXX11_ABI=1 support for linux cpu wheel #1062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions conda/Dockerfile_cxx11-abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
FROM centos:8 as base

ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8

# change to a valid repo
RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*.repo
# enable to install ninja-build
RUN sed -i 's|enabled=0|enabled=1|g' /etc/yum.repos.d/CentOS-Linux-PowerTools.repo

RUN yum -y update
RUN yum install -y wget curl perl util-linux xz bzip2 git patch which unzip
RUN yum install -y autoconf automake make cmake gdb gcc gcc-c++

FROM base as patchelf
# Install patchelf
ADD ./common/install_patchelf.sh install_patchelf.sh
RUN bash ./install_patchelf.sh && rm install_patchelf.sh && cp $(which patchelf) /patchelf

FROM base as openssl
# Install openssl
ADD ./common/install_openssl.sh install_openssl.sh
RUN bash ./install_openssl.sh && rm install_openssl.sh

FROM base as conda
# Install Anaconda
ADD ./common/install_conda.sh install_conda.sh
RUN bash ./install_conda.sh && rm install_conda.sh

# Install MNIST test data
FROM base as mnist
ADD ./common/install_mnist.sh install_mnist.sh
RUN bash ./install_mnist.sh

FROM base as final
# Install LLVM
COPY --from=pytorch/llvm:9.0.1 /opt/llvm /opt/llvm
COPY --from=pytorch/llvm:9.0.1 /opt/llvm_no_cxx11_abi /opt/llvm_no_cxx11_abi
COPY --from=openssl /opt/openssl /opt/openssl
COPY --from=patchelf /patchelf /usr/local/bin/patchelf
COPY --from=conda /opt/conda /opt/conda
ADD ./java/jni.h /usr/local/include/jni.h
ENV PATH /opt/conda/bin:$PATH
COPY --from=mnist /usr/local/mnist /usr/local/mnist
RUN rm -rf /usr/local/cuda
RUN chmod o+rw /usr/local
RUN touch /.condarc && \
chmod o+rw /.condarc && \
chmod -R o+rw /opt/conda
2 changes: 1 addition & 1 deletion conda/build_all_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ set -eou pipefail

TOPDIR=$(git rev-parse --show-toplevel)

for CUDA_VERSION in 11.7 11.6 11.5 11.3 10.2 cpu; do
for CUDA_VERSION in 11.7 11.6 11.5 11.3 10.2 cpu cpu-cxx11-abi; do
CUDA_VERSION="${CUDA_VERSION}" conda/build_docker.sh
done
14 changes: 13 additions & 1 deletion conda/build_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@ DEVTOOLSET_VERSION="9"
if [[ ${CUDA_VERSION:0:2} == "10" ]]; then
DEVTOOLSET_VERSION="7"
fi
CONDA_LINUX_VERSION=${CONDA_LINUX_VERSION:-}

case ${CUDA_VERSION} in
cpu)
BASE_TARGET=base
DOCKER_TAG=cpu
;;
cpu-cxx11-abi)
BASE_TARGET=base
DOCKER_TAG=cpu-cxx11-abi
CONDA_LINUX_VERSION="cxx11-abi"
;;
all)
BASE_TARGET=all_cuda
DOCKER_TAG=latest
Expand All @@ -26,6 +32,12 @@ case ${CUDA_VERSION} in
;;
esac

if [[ -n ${CONDA_LINUX_VERSION} ]]; then
DOCKERFILE_SUFFIX=_${CONDA_LINUX_VERSION}
else
DOCKERFILE_SUFFIX=''
fi

(
set -x
docker build \
Expand All @@ -34,7 +46,7 @@ esac
--build-arg "CUDA_VERSION=${CUDA_VERSION}" \
--build-arg "DEVTOOLSET_VERSION=${DEVTOOLSET_VERSION}" \
-t "pytorch/conda-builder:${DOCKER_TAG}" \
-f "${TOPDIR}/conda/Dockerfile" \
-f "${TOPDIR}/conda/Dockerfile${DOCKERFILE_SUFFIX}" \
${TOPDIR}
)

Expand Down
4 changes: 2 additions & 2 deletions conda/build_pytorch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ else
build_version="$2"
build_number="$3"
fi
if [[ "$desired_cuda" != cpu ]]; then
if [[ "$desired_cuda" != cpu ]] && [[ "$desired_cuda" != cpu-cxx11-abi ]]; then
desired_cuda="$(echo $desired_cuda | tr -d cuda. )"
fi
echo "Building cuda version $desired_cuda and pytorch version: $build_version build_number: $build_number"
Expand Down Expand Up @@ -108,7 +108,7 @@ fi
if [[ "$OSTYPE" == "darwin"* ]]; then
DEVELOPER_DIR=/Applications/Xcode9.app/Contents/Developer
fi
if [[ "$desired_cuda" == 'cpu' ]]; then
if [[ "$desired_cuda" == 'cpu' ]] || [[ "$desired_cuda" == 'cpu-cxx11-abi' ]]; then
cpu_only=1
else
# Switch desired_cuda to be M.m to be consistent with other scripts in
Expand Down
11 changes: 9 additions & 2 deletions conda/pytorch-nightly/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@ export CMAKE_PREFIX_PATH=$PREFIX
export TH_BINARY_BUILD=1 # links CPU BLAS libraries thrice in a row (was needed for some MKL static linkage)
export PYTORCH_BUILD_VERSION=$PKG_VERSION
export PYTORCH_BUILD_NUMBER=$PKG_BUILDNUM
export USE_LLVM="/opt/llvm_no_cxx11_abi"
export LLVM_DIR="$USE_LLVM/lib/cmake/llvm"
if [[ "$DESIRED_DEVTOOLSET" == *"cxx11-abi"* ]]; then
export _GLIBCXX_USE_CXX11_ABI=1
export USE_LLVM="/opt/llvm"
export LLVM_DIR="$USE_LLVM/lib/cmake/llvm"
else
export _GLIBCXX_USE_CXX11_ABI=0
export USE_LLVM="/opt/llvm_no_cxx11_abi"
export LLVM_DIR="$USE_LLVM/lib/cmake/llvm"
fi

# set OPENSSL_ROOT_DIR=/opt/openssl if it exists
if [[ -e /opt/openssl ]]; then
Expand Down
1 change: 1 addition & 0 deletions conda/pytorch-nightly/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ build:
- DEVELOPER_DIR
- DEBUG
- USE_FBGEMM
- DESIRED_DEVTOOLSET
- USE_GLOO_WITH_OPENSSL # [unix]
- USE_SCCACHE # [win]
- USE_DISTRIBUTED # [unix]
Expand Down