Skip to content

Commit 53b8397

Browse files
zhuhong61guoyejun
andauthored
manywheel: add _GLIBCXX_USE_CXX11_ABI=1 support for linux cpu wheel (#990)
The target of this commit is to add the support for a new linux cpu pip wheel file built with _GLIBCXX_USE_CXX11_ABI=1. Currently, linux wheels are built in a system based on CentOS7 and devtoolset7, and CXX11_ABI is ignored by the compiler. The same issue with devtoolset8 and devtoolset9, and so we add a Docker file (Dockerfile_cxx11-abi) with Ubuntu 18.04 as base image to support CXX11_ABI=1, by referring the Dockerfile for libtorch. To build the new docker image with CXX11_ABI support, run: GPU_ARCH_TYPE=cpu-cxx11-abi manywheel/build_docker.sh or manywheel/build_all_docker.sh To build a linux cpu pip wheel with CXX11_ABI within this image, run: // the below settings are special for this image export DESIRED_CUDA=cpu-cxx11-abi # change from cpu for wheel name export GPU_ARCH_TYPE=cpu-cxx11-abi # change from cpu for build.sh export DOCKER_IMAGE=pytorch/manylinuxcxx11-abi-builder:cpu-cxx11-abi export DESIRED_DEVTOOLSET=cxx11-abi // the below settings are as usual export BINARY_ENV_FILE=/tmp/env export BUILDER_ROOT=/builder export DESIRED_PYTHON=3.7 # or 3.8, 3.9, etc. export IS_GHA=1 export PACKAGE_TYPE=manywheel export PYTORCH_FINAL_PACKAGE_DIR=/artifacts export PYTORCH_ROOT=/pytorch export GITHUB_WORKSPACE=/your_path_to_workspace // the '-e DESIRED_DEVTOOLSET' below is newly added for this container, // others are as usual set -x mkdir -p artifacts/ container_name=$(docker run \ -e BINARY_ENV_FILE \ -e BUILDER_ROOT \ -e DESIRED_CUDA \ -e DESIRED_PYTHON \ -e GPU_ARCH_TYPE \ -e IS_GHA \ -e PACKAGE_TYPE \ -e PYTORCH_FINAL_PACKAGE_DIR \ -e PYTORCH_ROOT \ -e DOCKER_IMAGE \ -e DESIRED_DEVTOOLSET \ --tty \ --detach \ -v "${GITHUB_WORKSPACE}/pytorch:/pytorch" \ -v "${GITHUB_WORKSPACE}/builder:/builder" \ -v "${RUNNER_TEMP}/artifacts:/artifacts" \ -w / \ "${DOCKER_IMAGE}" ) // build pip wheel as usual, // and the built wheel file name looks like: torch-1.12.0.dev20220312+cpu.cxx11.abi-cp37-cp37m-linux_x86_64.whl docker exec -t -w "${PYTORCH_ROOT}" "${container_name}" bash -c "bash .circleci/scripts/binary_populate_env.sh" docker exec -t "${container_name}" bash -c "source ${BINARY_ENV_FILE} && bash /builder/manywheel/build.sh" // to verify the built wheel file, we'll see 'True' $ pip install torch-1.12.0.dev20220312+cpu.cxx11.abi-cp37-cp37m-linux_x86_64.whl $ python -c 'import torch; print(torch._C._GLIBCXX_USE_CXX11_ABI)' True Co-authored-by: Guo Yejun <[email protected]> Co-authored-by: Zhu Hong <[email protected]> Co-authored-by: Guo Yejun <[email protected]>
1 parent 15ddf79 commit 53b8397

File tree

4 files changed

+65
-1
lines changed

4 files changed

+65
-1
lines changed

manywheel/Dockerfile_cxx11-abi

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
FROM ubuntu:18.04 as base
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
5+
RUN apt-get clean && apt-get update
6+
RUN apt-get install -y curl locales git-all autoconf automake make cmake wget unzip vim gcc g++
7+
8+
RUN locale-gen en_US.UTF-8
9+
10+
ENV LC_ALL en_US.UTF-8
11+
ENV LANG en_US.UTF-8
12+
ENV LANGUAGE en_US.UTF-8
13+
14+
# Install openssl
15+
FROM base as openssl
16+
ADD ./common/install_openssl.sh install_openssl.sh
17+
RUN bash ./install_openssl.sh && rm install_openssl.sh
18+
19+
# Install python
20+
FROM base as python
21+
ADD common/install_cpython.sh install_cpython.sh
22+
RUN apt-get update -y && \
23+
apt-get install build-essential gdb lcov libbz2-dev libffi-dev \
24+
libgdbm-dev liblzma-dev libncurses5-dev libreadline6-dev \
25+
libsqlite3-dev libssl-dev lzma lzma-dev tk-dev uuid-dev zlib1g-dev -y && \
26+
bash ./install_cpython.sh && \
27+
rm install_cpython.sh && \
28+
apt-get clean
29+
30+
FROM base as intel
31+
# Install MKL
32+
ADD ./common/install_mkl.sh install_mkl.sh
33+
RUN bash ./install_mkl.sh && rm install_mkl.sh
34+
35+
FROM base as conda
36+
ADD ./common/install_conda.sh install_conda.sh
37+
RUN bash ./install_conda.sh && rm install_conda.sh
38+
RUN /opt/conda/bin/conda install -y cmake=3.14
39+
40+
FROM base as final
41+
# Install LLVM
42+
COPY --from=pytorch/llvm:9.0.1 /opt/llvm /opt/llvm
43+
COPY --from=pytorch/llvm:9.0.1 /opt/llvm_no_cxx11_abi /opt/llvm_no_cxx11_abi
44+
COPY --from=openssl /opt/openssl /opt/openssl
45+
# Install patchelf
46+
ADD ./common/install_patchelf.sh install_patchelf.sh
47+
RUN bash ./install_patchelf.sh && rm install_patchelf.sh
48+
COPY --from=intel /opt/intel /opt/intel
49+
# Install Anaconda
50+
COPY --from=conda /opt/conda /opt/conda
51+
# Install python
52+
COPY --from=python /opt/python /opt/python
53+
COPY --from=python /opt/_internal /opt/_internal
54+
ENV PATH /opt/conda/bin:$PATH

manywheel/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ case "${GPU_ARCH_TYPE:-BLANK}" in
1515
rocm)
1616
bash "${SCRIPTPATH}/build_rocm.sh"
1717
;;
18-
cpu)
18+
cpu | cpu-cxx11-abi)
1919
bash "${SCRIPTPATH}/build_cpu.sh"
2020
;;
2121
*)

manywheel/build_all_docker.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ TOPDIR=$(git rev-parse --show-toplevel)
77
GPU_ARCH_TYPE=cpu "${TOPDIR}/manywheel/build_docker.sh"
88
MANYLINUX_VERSION=2014 GPU_ARCH_TYPE=cpu "${TOPDIR}/manywheel/build_docker.sh"
99

10+
GPU_ARCH_TYPE=cpu-cxx11-abi "${TOPDIR}/manywheel/build_docker.sh"
11+
1012
for cuda_version in 11.5 11.3 10.2; do
1113
GPU_ARCH_TYPE=cuda GPU_ARCH_VERSION="${cuda_version}" "${TOPDIR}/manywheel/build_docker.sh"
1214
MANYLINUX_VERSION=2014 GPU_ARCH_TYPE=cuda GPU_ARCH_VERSION="${cuda_version}" "${TOPDIR}/manywheel/build_docker.sh"

manywheel/build_docker.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ case ${GPU_ARCH_TYPE} in
2020
GPU_IMAGE=centos:7
2121
DOCKER_GPU_BUILD_ARG=""
2222
;;
23+
cpu-cxx11-abi)
24+
TARGET=final
25+
DOCKER_TAG=cpu-cxx11-abi
26+
LEGACY_DOCKER_IMAGE=${DOCKER_REGISTRY}/pytorch/manylinux-cpu-cxx11-abi
27+
GPU_IMAGE=""
28+
DOCKER_GPU_BUILD_ARG=""
29+
MANY_LINUX_VERSION="cxx11-abi"
30+
;;
2331
cuda)
2432
TARGET=cuda_final
2533
DOCKER_TAG=cuda${GPU_ARCH_VERSION}

0 commit comments

Comments
 (0)