Skip to content

Commit

Permalink
Add new cuda version (#102)
Browse files Browse the repository at this point in the history
* compact Dockerfile
* optimize install script
* update cuda pkgs
* fix sys py3
  • Loading branch information
haobibo authored Jun 14, 2024
1 parent c6be2b8 commit c860633
Show file tree
Hide file tree
Showing 9 changed files with 203 additions and 131 deletions.
57 changes: 41 additions & 16 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,30 @@ jobs:
alias_image cuda_11.8 latest cuda latest
push_image cuda
qpod_cuda_123:
name: 'cuda_12.3'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
source ./tool.sh
build_image tmp latest docker_atom/Dockerfile --build-arg "BASE_IMG=nvidia/cuda:12.3.2-cudnn9-devel-ubuntu22.04" && clear_images nvidia/cuda
build_image tmp latest docker_base/Dockerfile --build-arg "BASE_IMG=tmp"
build_image cuda_12.3 latest docker_cuda/Dockerfile --build-arg "BASE_IMG=tmp"
push_image cuda
qpod_cuda_120:
name: 'cuda_12.0'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
source ./tool.sh
build_image tmp latest docker_atom/Dockerfile --build-arg "BASE_IMG=nvidia/cuda:12.0.1-cudnn8-devel-ubuntu22.04" && clear_images nvidia/cuda
build_image tmp latest docker_base/Dockerfile --build-arg "BASE_IMG=tmp"
build_image cuda_12.0 latest docker_cuda/Dockerfile --build-arg "BASE_IMG=tmp"
push_image cuda
qpod_cuda_112:
name: 'cuda_11.2'
runs-on: ubuntu-latest
Expand All @@ -245,15 +269,15 @@ jobs:
push_image cuda
qpod_tf2:
name: 'tf2,tf2-cuda112'
needs: qpod_cuda_112
name: 'tf2,tf2-cuda123'
needs: qpod_cuda_123
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
source ./tool.sh
build_image tf2-cuda112 latest docker_core/Dockerfile --build-arg "BASE_IMG=cuda_11.2" --build-arg "ARG_PROFILE_PYTHON=tf2"
alias_image tf2-cuda112 latest tf2 latest
build_image tf2-cuda123 latest docker_core/Dockerfile --build-arg "BASE_IMG=cuda_12.3" --build-arg "ARG_PROFILE_PYTHON=tf2"
alias_image tf2-cuda123 latest tf2 latest
push_image
qpod_torch_cuda118:
Expand All @@ -269,26 +293,26 @@ jobs:
push_image
qpod_torch_cuda112:
name: 'torch-cuda112'
needs: qpod_cuda_112
name: 'torch-cuda123'
needs: qpod_cuda_123
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
source ./tool.sh
build_image torch-cuda112 latest docker_core/Dockerfile --build-arg "BASE_IMG=cuda_11.2" --build-arg "ARG_PROFILE_PYTHON=torch"
build_image torch-cuda123 latest docker_core/Dockerfile --build-arg "BASE_IMG=cuda_12.3" --build-arg "ARG_PROFILE_PYTHON=torch"
push_image
qpod_paddle_cuda118:
name: 'paddle-cuda,paddle-cuda118'
needs: qpod_cuda_118
qpod_paddle_cuda120:
name: 'paddle-cuda,paddle-cuda120'
needs: qpod_cuda_120
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
source ./tool.sh
build_image paddle-cuda118 latest docker_core/Dockerfile --build-arg "BASE_IMG=cuda_11.8" --build-arg "ARG_PROFILE_PYTHON=paddle,mkl"
alias_image paddle-cuda118 latest paddle-cuda latest
build_image paddle-cuda120 latest docker_core/Dockerfile --build-arg "BASE_IMG=cuda_12.0" --build-arg "ARG_PROFILE_PYTHON=paddle,mkl"
alias_image paddle-cuda120 latest paddle-cuda latest
push_image
qpod_paddle_cuda112:
Expand Down Expand Up @@ -379,9 +403,10 @@ jobs:
- uses: actions/checkout@v4
- run: |
source ./tool.sh && build_image docker-kit latest docker_docker_kit/Dockerfile
printenv > /tmp/docker.env
printenv | grep -v 'PATH' > /tmp/docker.env
docker run --rm ${IMG_PREFIX}/docker-kit printenv | sort
docker run --rm --env-file /tmp/docker.env -v $(pwd):/tmp -w /tmp \
${IMG_PREFIX}/docker-kit /opt/conda/bin/python /opt/utils/image-syncer/run_sync.py ${IMG_NAMESPACE}/base
${IMG_PREFIX}/docker-kit python /opt/utils/image-syncer/run_sync.py ${IMG_NAMESPACE}/base
push_image docker-kit
## Sync all images in this build (listed by "names") to mirror registry.
Expand All @@ -392,6 +417,6 @@ jobs:
- uses: actions/checkout@v4
- run: |
source ./tool.sh
printenv > /tmp/docker.env
printenv | grep -v 'PATH' > /tmp/docker.env
docker run --rm --env-file /tmp/docker.env -v $(pwd):/tmp -w /tmp \
${IMG_NAMESPACE:-qpod}/docker-kit /opt/conda/bin/python /opt/utils/image-syncer/run_jobs.py
${IMG_NAMESPACE:-qpod}/docker-kit python /opt/utils/image-syncer/run_jobs.py
2 changes: 1 addition & 1 deletion docker_atom/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ENV SHELL=/bin/bash \
SHELL ["/bin/bash", "--login", "-c"]

# --> Install OS libraries and setup some configurations
RUN set -x && cd /tmp \
RUN set -eux && cd /tmp \
&& apt-get -qq update --fix-missing && apt-get -y -qq upgrade \
&& apt-get -qq install -y --no-install-recommends \
apt-utils apt-transport-https ca-certificates gnupg2 dirmngr locales sudo lsb-release curl \
Expand Down
74 changes: 43 additions & 31 deletions docker_atom/work/script-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ setup_mamba() {
&& ln -sf /opt/mamba/mamba /usr/bin/ \
&& touch /etc/conda/.condarc \
&& printf "channels:\n" >> /etc/conda/.condarc \
&& printf " - conda-forge\n" >> /etc/conda/.condarc \
&& echo "@ Version of mamba:" && mamba info
&& printf " - conda-forge\n" >> /etc/conda/.condarc

echo "@ Version of mamba:" && mamba info
}


Expand Down Expand Up @@ -62,21 +63,21 @@ setup_conda_with_mamba() {

setup_conda_download() {
# https://docs.conda.io/projects/miniconda/en/latest/index.html
mkdir -pv "${CONDA_PREFIX}"
wget -qO- "https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-$(arch).sh" -O /tmp/conda.sh
bash /tmp/conda.sh -f -b -p "${CONDA_PREFIX}/"
rm -rf /tmp/conda.sh
setup_conda_postprocess
mkdir -pv "${CONDA_PREFIX}" \
&& wget -qO- "https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-$(arch).sh" -O /tmp/conda.sh \
&& bash /tmp/conda.sh -f -b -p "${CONDA_PREFIX}/" \
&& rm -rf /tmp/conda.sh \
&& setup_conda_postprocess
}

setup_nvtop() {
# The compiliation requries CMake 3.18 or higher. default version in CUDA 11.2 images is 3.16.3
curl -sL https://apt.kitware.com/keys/kitware-archive-latest.asc | sudo tee /etc/apt/trusted.gpg.d/kitware.asc \
curl -sL https://apt.kitware.com/keys/kitware-archive-latest.asc | sudo tee /etc/apt/trusted.gpg.d/kitware.asc \
&& echo "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/kitware.list \
&& apt-get -qq update -yq --fix-missing && apt-get -qq install -yq --no-install-recommends cmake

# Install Utilities "nvtop" from source: libdrm-dev libsystemd-dev used by AMD/Intel GPU support, libudev-dev used by ubuntu18.04
LIB_PATH=$(find / -name "libnvidia-ml*" 2>/dev/null) \
LIB_PATH=$(find / -name "libnvidia-ml*" 2>/dev/null) \
&& DIRECTORY=$(pwd) && cd /tmp \
&& sudo apt-get -qq update --fix-missing \
&& sudo apt-get -qq install -y --no-install-recommends libncurses5-dev libdrm-dev libsystemd-dev libudev-dev \
Expand All @@ -85,8 +86,9 @@ setup_nvtop() {
&& cmake .. -DCMAKE_LIBRARY_PATH="$(dirname ${LIB_PATH})" -DNVIDIA_SUPPORT=ON -DAMDGPU_SUPPORT=ON -DINTEL_SUPPORT=ON \
&& make && sudo make install \
&& cd "${DIRECTORY}" && rm -rf /tmp/nvtop \
&& sudo apt-get -qq remove -y libncurses5-dev libdrm-dev libsystemd-dev libudev-dev \
&& nvtop --version
&& sudo apt-get -qq remove -y libncurses5-dev libdrm-dev libsystemd-dev libudev-dev

nvtop --version
}


Expand Down Expand Up @@ -123,8 +125,9 @@ setup_java_maven() {
VERSION_MAVEN=$(curl -sL https://maven.apache.org/download.cgi | grep 'latest' | head -1 | grep -Po '\d[\d.]+') \
&& install_zip "http://archive.apache.org/dist/maven/maven-3/${VERSION_MAVEN}/binaries/apache-maven-${VERSION_MAVEN}-bin.zip" \
&& mv "/opt/apache-maven-${VERSION_MAVEN}" /opt/maven \
&& ln -sf /opt/maven/bin/mvn* /usr/bin/ \
&& echo "@ Version of Maven: $(mvn --version)"
&& ln -sf /opt/maven/bin/mvn* /usr/bin/

echo "@ Version of Maven: $(mvn --version)"
}


Expand All @@ -139,8 +142,9 @@ setup_node() {
&& ln -sf /opt/node/bin/n* /usr/bin/ \
&& echo 'export PATH=${PATH}:/opt/node/bin' >> /etc/profile.d/path-node.sh \
&& npm install -g npm \
&& echo "@ Version of Node and npm: $(node -v) $(npm -v)" \
&& cd /tmp && corepack enable && yarn set version stable \
&& cd /tmp && corepack enable && yarn set version stable

echo "@ Version of Node and npm: $(node -v) $(npm -v)" \
&& echo "@ Version of Yarn: $(yarn -v)"
}

Expand All @@ -153,8 +157,9 @@ setup_GO() {
&& echo 'export GOROOT="/opt/go"' >> /etc/profile.d/path-go.sh \
&& echo 'export GOBIN="$GOROOT/bin"' >> /etc/profile.d/path-go.sh \
&& echo 'export GOPATH="$GOROOT/path"' >> /etc/profile.d/path-go.sh \
&& echo 'export PATH=$PATH:$GOROOT/bin:$GOPATH/bin' >> /etc/profile.d/path-go.sh \
&& echo "@ Version of golang: $(go version)"
&& echo 'export PATH=$PATH:$GOROOT/bin:$GOPATH/bin' >> /etc/profile.d/path-go.sh

echo "@ Version of golang: $(go version)"
}


Expand All @@ -165,8 +170,9 @@ setup_rust() {
&& curl -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal --default-toolchain stable \
&& echo 'export CARGO_HOME="/opt/cargo"' >> /etc/profile.d/path-rust.sh \
&& echo 'export RUSTUP_HOME="/opt/rust"' >> /etc/profile.d/path-rust.sh \
&& echo 'export PATH=$PATH:/opt/cargo/bin' >> /etc/profile.d/path-rust.sh \
&& echo "@ Version of rustup: $(rustup --version)" \
&& echo 'export PATH=$PATH:/opt/cargo/bin' >> /etc/profile.d/path-rust.sh

echo "@ Version of rustup: $(rustup --version)" \
&& echo "@ Version of rustc: $(rustc --version)"
}

Expand All @@ -178,8 +184,9 @@ setup_julia() {
&& ln -fs /opt/julia/bin/julia /usr/bin/julia \
&& mkdir -p /opt/julia/pkg \
&& echo "import Libdl; push!(Libdl.DL_LOAD_PATH, \"/opt/conda/lib\")" >> /opt/julia/etc/julia/startup.jl \
&& echo "DEPOT_PATH[1]=\"/opt/julia/pkg\"" >> /opt/julia/etc/julia/startup.jl \
&& echo "@ Version of Julia: $(julia --version)"
&& echo "DEPOT_PATH[1]=\"/opt/julia/pkg\"" >> /opt/julia/etc/julia/startup.jl

echo "@ Version of Julia: $(julia --version)"
}


Expand All @@ -191,8 +198,9 @@ setup_lua_base() {
&& mv /opt/lua-* /tmp/lua && cd /tmp/lua \
&& make linux test && make install INSTALL_TOP=${LUA_HOME:-"/opt/lua"} \
&& ln -sf ${LUA_HOME:-"/opt/lua"}/bin/lua* /usr/bin/ \
&& rm -rf /tmp/lua \
&& echo "@ Version of LUA installed: $(lua -v)"
&& rm -rf /tmp/lua

echo "@ Version of LUA installed: $(lua -v)"
}

setup_lua_rocks() {
Expand All @@ -204,32 +212,36 @@ setup_lua_rocks() {
&& mv /opt/luarocks-* /tmp/luarocks && cd /tmp/luarocks \
&& ./configure --prefix=${LUA_HOME:-"/opt/lua"} --with-lua-include=${LUA_HOME:-"/opt/lua"}/include && make install \
&& ln -sf /opt/lua/bin/lua* /usr/bin/ \
&& rm -rf /tmp/luarocks \
&& echo "@ Version of luarocks: $(luarocks --version)"
&& rm -rf /tmp/luarocks

echo "@ Version of luarocks: $(luarocks --version)"
}

setup_traefik() {
TRAEFIK_VERSION=$(curl -sL https://github.com/traefik/traefik/releases.atom | grep 'releases/tag' | head -1 | grep -Po '\d[\d.]+') \
&& TRAEFIK_URL="https://github.com/traefik/traefik/releases/download/v${TRAEFIK_VERSION}/traefik_v${TRAEFIK_VERSION}_linux_$(dpkg --print-architecture).tar.gz" \
&& install_tar_gz "${TRAEFIK_URL}" traefik \
&& ln -sf /opt/traefik /usr/bin/ \
&& echo "@ Version of traefik: $(traefik version)"
&& ln -sf /opt/traefik /usr/bin/

echo "@ Version of traefik: $(traefik version)"
}


setup_bazel() {
BAZEL_VERSION=$(curl -sL https://github.com/bazelbuild/bazel/releases.atom | grep 'releases/tag' | head -1 | grep -Po '\d[\d.]+' ) \
&& BAZEL_URL="https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh" \
&& curl -o /tmp/bazel.sh -sL "${BAZEL_URL}" && chmod +x /tmp/bazel.sh \
&& /tmp/bazel.sh && rm /tmp/bazel.sh \
&& echo "@ Version of bazel: $(bazel --version)"
&& /tmp/bazel.sh && rm /tmp/bazel.sh

echo "@ Version of bazel: $(bazel --version)"
}


setup_gradle() {
GRADLE_VERSION=$(curl -sL https://github.com/gradle/gradle/releases.atom | grep 'releases/tag' | grep -v 'M' | head -1 | grep -Po '\d[\d.]+' ) \
&& install_zip "https://downloads.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip" \
&& mv /opt/gradle* /opt/gradle \
&& ln -sf /opt/gradle/bin/gradle /usr/bin \
&& echo "@ Version of gradle: $(gradle --version)"
&& ln -sf /opt/gradle/bin/gradle /usr/bin

echo "@ Version of gradle: $(gradle --version)"
}
8 changes: 4 additions & 4 deletions docker_atom/work/script-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ install_octave() { cat $1 | cut -d "%" -f 1 | sed '/^$/d' | xargs -r -n1 -I {}
install_zip() { curl -o /tmp/TMP.zip -sL $1 && unzip -q -d /opt/ /tmp/TMP.zip && rm /tmp/TMP.zip ; }

# function to download a .tar.gz file and unzip it to /opt/, add a second argument to extract only those file
install_tar_gz() { curl -o /tmp/TMP.tgz -sL $1 && tar -C /opt/ -xzf /tmp/TMP.tgz $2 && rm /tmp/TMP.tgz ; }
install_tar_gz() { curl -o /tmp/TMP.tgz -sL $1 && tar -C /opt/ -xzf /tmp/TMP.tgz ${2:-} && rm /tmp/TMP.tgz ; }

# function to download a .tar.bz file and unzip it to /opt/, add a second argument to extract only those file
install_tar_bz() { curl -o /tmp/TMP.tbz -sL $1 && tar -C /opt/ -xjf /tmp/TMP.tbz $2 && rm /tmp/TMP.tbz ; }
install_tar_bz() { curl -o /tmp/TMP.tbz -sL $1 && tar -C /opt/ -xjf /tmp/TMP.tbz ${2:-} && rm /tmp/TMP.tbz ; }

# function to download a .tar.xz file and unzip it to /opt/, add a second argument to extract only those file
install_tar_xz() { curl -o /tmp/TMP.txz -sL $1 && tar -C /opt/ -xJf /tmp/TMP.txz $2 && rm /tmp/TMP.txz ; }
install_tar_xz() { curl -o /tmp/TMP.txz -sL $1 && tar -C /opt/ -xJf /tmp/TMP.txz ${2:-} && rm /tmp/TMP.txz ; }

# function to install java packages from a text file which lists JAR file maven full names (add comments with % char)
install_mvn() { cat $1 | cut -d "%" -f 1 | xargs -r -n1 -I {} mvn dependency:copy -DlocalRepositoryDirectory="/tmp/m2repo" -Djavax.net.ssl.trustStorePassword=changeit -Dartifact="{}" -DoutputDirectory="$2" ; }
install_mvn() { cat $1 | cut -d "%" -f 1 | xargs -r -n1 -I {} mvn dependency:copy -DlocalRepositoryDirectory="/tmp/m2repo" -Djavax.net.ssl.trustStorePassword=changeit -Dartifact="{}" -DoutputDirectory="${2:-}" ; }

# function to clean up
install__clean(){
Expand Down
22 changes: 12 additions & 10 deletions docker_base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,32 @@ ARG PYTHON_VERSION="3.12"

ENV CONDA_PREFIX=/opt/conda

RUN set -x && source /opt/utils/script-setup.sh && source /opt/utils/script-setup-sys.sh \
RUN set -eux && source /opt/utils/script-setup.sh && source /opt/utils/script-setup-sys.sh \
&& export PATH=$PATH:${CONDA_PREFIX}/bin \
&& install_apt /opt/utils/install_list_base.apt \
&& echo "Install tini:" && setup_tini \
&& export HAS_SYS_PY3=$( [ -x "$(command -v python3)" ] && echo 'true' || echo 'false' ) && echo "@ Detect OS Py3 installed: $HAS_SYS_PY3" \
&& export HAS_SYS_PY3=$( [ -x "$(command -v python3)" ] && echo 'true' || echo 'false' ) && echo "@ Detect OS Py3 installed: ${HAS_SYS_PY3:-error}" \
&& echo "Install Mamba:" && setup_mamba \
&& echo "Install Python ${PYTHON_VERSION} and conda:" && setup_conda_with_mamba ${PYTHON_VERSION} \
&& echo "Backup the conda version of platform.py as it's different from the system version." \
&& cp "${CONDA_PREFIX}/lib/python${PYTHON_VERSION}"/platform.py "${CONDA_PREFIX}/lib/python${PYTHON_VERSION}"/platform.py.bak \
&& $($HAS_SYS_PY3) && ( \
echo "Replace system Python3 with conda Python - note that /bin and /sbin are symlinks of /usr/bin in docker image ubuntu" \
&& if $(${HAS_SYS_PY3:-false}) ; then \
py3versions -d \
&& PYTHON_VERSION_DEFAULT=$(py3versions -v -i) \
&& sed -i "s/${PYTHON_VERSION_DEFAULT}/${PYTHON_VERSION}/g" /usr/share/python3/debian_defaults \
&& PYTHON_PTH_FILE=$("${CONDA_PREFIX}"/bin/python3 -c 'import sys;print(sys.path[-1]+"/usr_share.pth")') \
&& echo "Found default system python3 version: ${PYTHON_VERSION_DEFAULT}" \
&& echo "Replace system Python3 with conda Python - note that /bin and /sbin are symlinks of /usr/bin in docker image ubuntu" \
&& sed -i "s/${PYTHON_VERSION_DEFAULT}/${PYTHON_VERSION}/g" /usr/share/python3/debian_defaults \
&& echo "/usr/share/pyshared/" >> "${PYTHON_PTH_FILE}" \
&& echo "/usr/share/python3/" >> "${PYTHON_PTH_FILE}" \
&& rm -rf $(/usr/bin/python3 -c 'import sys; print(" ".join(i for i in sys.path if "python" in i))') /usr/bin/python3* /usr/lib/python${PYTHON_VERSION} \
) || true \
&& ln -sf "${CONDA_PREFIX}"/lib/python${PYTHON_VERSION} /usr/lib/ \
&& rm -rf /usr/lib/python${PYTHON_VERSION} && ln -sf "${CONDA_PREFIX}"/lib/python${PYTHON_VERSION} /usr/lib/ ; \
else \
echo "No default python found in OS." ; \
fi \
&& ln -sf "${CONDA_PREFIX}"/bin/python3.* /usr/bin/ \
&& ln -sf "/usr/bin/python${PYTHON_VERSION}" /usr/bin/python \
&& ln -sf "/usr/bin/python${PYTHON_VERSION}" /usr/bin/python3 \
&& ls -alh /usr/bin/python* \
&& $($HAS_SYS_PY3) && ( py3versions -d ) || true \
&& lsb_release -a \
&& which python && python --version \
&& which python && python --version && ls -alh /usr/bin/python* \
&& install__clean && fix_permission 0 /opt
Loading

0 comments on commit c860633

Please sign in to comment.