Skip to content

Commit a75016d

Browse files
committed
update
1 parent 630c2e2 commit a75016d

15 files changed

+474
-101
lines changed

.ci/docker/Dockerfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
ARG BASE_IMAGE
2+
ARG CUDA_VERSION
3+
ARG UBUNTU_VERSIOn
4+
FROM ${BASE_IMAGE}
5+
6+
ENV DEBIAN_FRONTEND noninteractive
7+
8+
# Install common dependencies (so that this step can be cached separately)
9+
COPY ./common/install_base.sh install_base.sh
10+
RUN bash ./install_base.sh && rm install_base.sh
11+
12+
# Install user
13+
COPY ./common/install_user.sh install_user.sh
14+
RUN bash ./install_user.sh && rm install_user.sh
15+
16+
COPY ./common/install_docs_reqs.sh install_docs_reqs.sh
17+
RUN bash ./install_docs_reqs.sh && rm install_docs_reqs.sh
18+
19+
# Install conda and other packages
20+
ENV ANACONDA_PYTHON_VERSION=3.10
21+
ENV CONDA_CMAKE yes
22+
ENV DOCS yes
23+
ENV PATH /opt/conda/envs/py_$ANACONDA_PYTHON_VERSION/bin:/opt/conda/bin:$PATH
24+
COPY ./requirements.txt /opt/conda/
25+
COPY ./common/install_conda.sh install_conda.sh
26+
COPY ./common/common_utils.sh common_utils.sh
27+
RUN bash ./install_conda.sh && rm install_conda.sh common_utils.sh /opt/conda/requirements.txt
28+
29+
# Install gcc
30+
# ENV GCC_VERSION 9
31+
# COPY ./install_gcc.sh install_gcc.sh
32+
# RUN bash ./install_gcc.sh && rm install_gcc.sh
33+
34+
# Install CUDNN
35+
ENV CUDNN_VERSION=8
36+
COPY ./common/install_cudnn.sh install_cudnn.sh
37+
RUN bash ./install_cudnn.sh && rm install_cudnn.sh
38+
39+
USER jenkins
40+
CMD ["bash"]

.ci/docker/build.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
set -exu
9+
10+
IMAGE_NAME="$1"
11+
shift
12+
13+
export CUDA_VERSION="12.1.1"
14+
export UBUNTU_VERSION="20.04"
15+
16+
export BASE_IMAGE="nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION}"
17+
echo "Building ${IMAGE_NAME} Docker image"
18+
19+
docker build \
20+
--no-cache \
21+
--progress=plain \
22+
-f Dockerfile \
23+
--build-arg BASE_IMAGE="${BASE_IMAGE}" \
24+
--build-arg CUDA_VERSION="${CUDA_VERSION}" \
25+
--build-arg UBUNTU_VERSION="${UBUNTU_VERSION}" \
26+
"$@" \
27+
.

.ci/docker/common.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
set -ex
9+
PYTHON_VERSION="3.10"
10+
# shellcheck source=/dev/null
11+
as_ci_user() {
12+
# NB: unsetting the environment variables works around a conda bug
13+
# https://github.com/conda/conda/issues/6576
14+
# NB: Pass on PATH and LD_LIBRARY_PATH to sudo invocation
15+
# NB: This must be run from a directory that the user has access to
16+
sudo -E -H -u jenkins env -u SUDO_UID -u SUDO_GID -u SUDO_COMMAND -u SUDO_USER env "PATH=${PATH}" "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" "$@"
17+
}
18+
19+
pip_install() {
20+
as_ci_user conda run -n "py_${PYTHON_VERSION}" pip install --progress-bar off "$@"
21+
}
22+
23+
install_pip_dependencies() {
24+
pushd /opt/conda
25+
pip_install -r /opt/conda/requirements.txt
26+
as_ci_user conda run -n "py_${PYTHON_VERSION}" pip uninstall -y ghstack
27+
popd
28+
}
29+
30+
# Don't want to use sccache
31+
rm -rf /opt/cache/bin/*
32+
33+
install_pip_dependencies

.ci/docker/common/common_utils.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
# Work around bug where devtoolset replaces sudo and breaks it.
4+
as_jenkins() {
5+
# NB: unsetting the environment variables works around a conda bug
6+
# https://github.com/conda/conda/issues/6576
7+
# NB: Pass on PATH and LD_LIBRARY_PATH to sudo invocation
8+
# NB: This must be run from a directory that jenkins has access to,
9+
# works around https://github.com/conda/conda-package-handling/pull/34
10+
sudo -E -H -u jenkins env -u SUDO_UID -u SUDO_GID -u SUDO_COMMAND -u SUDO_USER env "PATH=$PATH" "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" $*
11+
}
12+
13+
conda_install() {
14+
# Ensure that the install command don't upgrade/downgrade Python
15+
# This should be called as
16+
# conda_install pkg1 pkg2 ... [-c channel]
17+
as_jenkins conda install -q -n py_$ANACONDA_PYTHON_VERSION -y python="$ANACONDA_PYTHON_VERSION" $*
18+
}
19+
20+
conda_run() {
21+
as_jenkins conda run -n py_$ANACONDA_PYTHON_VERSION --no-capture-output $*
22+
}
23+
24+
pip_install() {
25+
as_jenkins conda run -n py_$ANACONDA_PYTHON_VERSION pip install --progress-bar off $*
26+
}

.ci/docker/common/install_base.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
# Based off of https://github.com/pytorch/pytorch/tree/b52e0bf131a4e55cd987176f9c5a8d2ad6783b4f/.ci/docker
3+
4+
set -ex
5+
6+
install_ubuntu() {
7+
# Install common dependencies
8+
apt-get update
9+
# TODO: Some of these may not be necessary
10+
apt-get install -y --no-install-recommends \
11+
build-essential \
12+
ca-certificates \
13+
cmake=3.16* \
14+
curl \
15+
git \
16+
wget \
17+
sudo \
18+
vim \
19+
jq \
20+
vim \
21+
unzip \
22+
gdb \
23+
rsync \
24+
libssl-dev \
25+
p7zip-full \
26+
libglfw3 \
27+
libglfw3-dev \
28+
sox \
29+
libsox-dev \
30+
libsox-fmt-all
31+
32+
# Cleanup package manager
33+
apt-get autoclean && apt-get clean
34+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
35+
}
36+
37+
# Install base packages depending on the base OS
38+
ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
39+
case "$ID" in
40+
ubuntu)
41+
install_ubuntu
42+
;;
43+
*)
44+
echo "Unable to determine OS..."
45+
exit 1
46+
;;
47+
esac

.ci/docker/common/install_conda.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
# Optionally install conda
6+
if [ -n "$ANACONDA_PYTHON_VERSION" ]; then
7+
BASE_URL="https://repo.anaconda.com/miniconda"
8+
9+
MAJOR_PYTHON_VERSION=$(echo "$ANACONDA_PYTHON_VERSION" | cut -d . -f 1)
10+
MINOR_PYTHON_VERSION=$(echo "$ANACONDA_PYTHON_VERSION" | cut -d . -f 2)
11+
12+
CONDA_FILE="Miniconda3-latest-Linux-x86_64.sh"
13+
14+
mkdir -p /opt/conda
15+
chown jenkins:jenkins /opt/conda
16+
17+
source "$(dirname "${BASH_SOURCE[0]}")/common_utils.sh"
18+
19+
pushd /tmp
20+
wget -q "${BASE_URL}/${CONDA_FILE}"
21+
# NB: Manually invoke bash per https://github.com/conda/conda/issues/10431
22+
as_jenkins bash "${CONDA_FILE}" -b -f -p "/opt/conda"
23+
popd
24+
25+
# NB: Don't do this, rely on the rpath to get it right
26+
#echo "/opt/conda/lib" > /etc/ld.so.conf.d/conda-python.conf
27+
#ldconfig
28+
sed -e 's|PATH="\(.*\)"|PATH="/opt/conda/bin:\1"|g' -i /etc/environment
29+
export PATH="/opt/conda/bin:$PATH"
30+
31+
# Ensure we run conda in a directory that jenkins has write access to
32+
pushd /opt/conda
33+
34+
# Prevent conda from updating to 4.14.0, which causes docker build failures
35+
# See https://hud.pytorch.org/pytorch/pytorch/commit/754d7f05b6841e555cea5a4b2c505dd9e0baec1d
36+
# Uncomment the below when resolved to track the latest conda update
37+
# as_jenkins conda update -y -n base conda
38+
39+
# Install correct Python version
40+
as_jenkins conda create -n py_$ANACONDA_PYTHON_VERSION -y python="$ANACONDA_PYTHON_VERSION"
41+
42+
# Install PyTorch conda deps, as per https://github.com/pytorch/pytorch README
43+
CONDA_COMMON_DEPS="astunparse pyyaml mkl=2021.4.0 mkl-include=2021.4.0 setuptools"
44+
45+
# Install llvm-8 as it is required to compile llvmlite-0.30.0 from source
46+
# and libpython-static for torch deploy
47+
conda_install llvmdev=8.0.0 "libpython-static=${ANACONDA_PYTHON_VERSION}"
48+
49+
# Use conda cmake in some cases. Conda cmake will be newer than our supported
50+
# min version (3.5 for xenial and 3.10 for bionic), so we only do it in those
51+
# following builds that we know should use conda. Specifically, Ubuntu bionic
52+
# and focal cannot find conda mkl with stock cmake, so we need a cmake from conda
53+
conda_install cmake
54+
55+
conda_install "magma-cuda$(TMP=${CUDA_VERSION/./};echo ${TMP%.*[0-9]})" -c pytorch
56+
57+
# Install some other packages, including those needed for Python test reporting
58+
pip_install -r /opt/conda/requirements.txt
59+
60+
apt-get update
61+
apt-get -y install expect-dev
62+
63+
# HACK HACK HACK
64+
# gcc-9 for ubuntu-18.04 from http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu
65+
# Pulls llibstdc++6 13.1.0-8ubuntu1~18.04 which is too new for conda
66+
# So remove libstdc++6.so.3.29 installed by https://anaconda.org/anaconda/libstdcxx-ng/files?version=11.2.0
67+
# Same is true for gcc-12 from Ubuntu-22.04
68+
if grep -e [12][82].04.[623] /etc/issue >/dev/null; then
69+
rm /opt/conda/envs/py_$ANACONDA_PYTHON_VERSION/lib/libstdc++.so.6
70+
fi
71+
72+
popd
73+
fi

.ci/docker/common/install_cudnn.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
if [[ ${CUDNN_VERSION} == 8 ]]; then
4+
# cuDNN license: https://developer.nvidia.com/cudnn/license_agreement
5+
mkdir tmp_cudnn
6+
pushd tmp_cudnn
7+
if [[ ${CUDA_VERSION:0:4} == "12.1" ]]; then
8+
CUDNN_NAME="cudnn-linux-x86_64-8.9.2.26_cuda12-archive"
9+
curl --retry 3 -OLs https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-x86_64/${CUDNN_NAME}.tar.xz
10+
elif [[ ${CUDA_VERSION:0:4} == "11.8" ]]; then
11+
CUDNN_NAME="cudnn-linux-x86_64-8.7.0.84_cuda11-archive"
12+
curl --retry 3 -OLs https://developer.download.nvidia.com/compute/redist/cudnn/v8.7.0/local_installers/11.8/${CUDNN_NAME}.tar.xz
13+
else
14+
print "Unsupported CUDA version ${CUDA_VERSION}"
15+
exit 1
16+
fi
17+
18+
tar xf ${CUDNN_NAME}.tar.xz
19+
cp -a ${CUDNN_NAME}/include/* /usr/local/cuda/include/
20+
cp -a ${CUDNN_NAME}/lib/* /usr/local/cuda/lib64/
21+
popd
22+
rm -rf tmp_cudnn
23+
ldconfig
24+
fi
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
# Based off of https://github.com/pytorch/pytorch/tree/b52e0bf131a4e55cd987176f9c5a8d2ad6783b4f/.ci/docker
3+
set -ex
4+
5+
apt-get update
6+
apt-get install -y gpg-agent
7+
8+
curl --retry 3 -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
9+
sudo apt-get install -y nodejs
10+
11+
curl --retry 3 -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
12+
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
13+
14+
apt-get update
15+
apt-get install -y --no-install-recommends yarn
16+
yarn global add katex --prefix /usr/local
17+
18+
sudo apt-get -y install doxygen
19+
20+
apt-get autoclean && apt-get clean
21+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

.ci/docker/common/install_gcc.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
# Need the official toolchain repo to get alternate packages
6+
add-apt-repository ppa:ubuntu-toolchain-r/test
7+
apt-get update
8+
apt-get install -y g++-$GCC_VERSION
9+
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-"$GCC_VERSION" 50
10+
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-"$GCC_VERSION" 50
11+
update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-"$GCC_VERSION" 50
12+
13+
14+
# Cleanup package manager
15+
apt-get autoclean && apt-get clean
16+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

.ci/docker/common/install_user.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
# Based off of https://github.com/pytorch/pytorch/tree/b52e0bf131a4e55cd987176f9c5a8d2ad6783b4f/.ci/docker
3+
set -ex
4+
5+
# Mirror jenkins user in container
6+
# jenkins user as ec2-user should have the same user-id
7+
echo "jenkins:x:1000:1000::/var/lib/jenkins:" >> /etc/passwd
8+
echo "jenkins:x:1000:" >> /etc/group
9+
# Needed on focal or newer
10+
echo "jenkins:*:19110:0:99999:7:::" >>/etc/shadow
11+
12+
# Create $HOME
13+
mkdir -p /var/lib/jenkins
14+
chown jenkins:jenkins /var/lib/jenkins
15+
mkdir -p /var/lib/jenkins/.ccache
16+
chown jenkins:jenkins /var/lib/jenkins/.ccache
17+
18+
# Allow writing to /usr/local (for make install)
19+
chown jenkins:jenkins /usr/local
20+
21+
# Allow sudo
22+
# TODO: Maybe we shouldn't
23+
echo 'jenkins ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/jenkins
24+
25+
# Test that sudo works
26+
sudo -u jenkins sudo -v

0 commit comments

Comments
 (0)