Skip to content

Commit d773d8c

Browse files
authored
Merge pull request #275 from conda-forge/revert-272-cleanup_old_cuda_bits
Revert "Cleanup and consolidate CUDA images"
2 parents 1e6db00 + f450b55 commit d773d8c

File tree

8 files changed

+287
-47
lines changed

8 files changed

+287
-47
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,22 @@ jobs:
3636
SHORT_DESCRIPTION: "conda-forge build image for Cent0S 7 on aarch64"
3737

3838
- DOCKERIMAGE: linux-anvil-cuda
39-
DOCKERFILE: linux-anvil-cuda
4039
DOCKERTAG: "11.8"
4140
CUDA_VER: "11.8.0"
42-
DISTRO_ARCH: "amd64"
4341
DISTRO_NAME: "centos"
4442
DISTRO_VER: "7"
4543
SHORT_DESCRIPTION: "conda-forge build image for Cent0S 7 on x86_64 with CUDA"
4644

4745
- DOCKERIMAGE: linux-anvil-ppc64le-cuda
48-
DOCKERFILE: linux-anvil-cuda
4946
DOCKERTAG: "11.8"
5047
CUDA_VER: "11.8.0"
51-
DISTRO_ARCH: "ppc64le"
5248
DISTRO_NAME: "ubi"
5349
DISTRO_VER: "8"
5450
SHORT_DESCRIPTION: "conda-forge build image for Cent0S 8 on ppc64le with CUDA"
5551

5652
- DOCKERIMAGE: linux-anvil-aarch64-cuda
57-
DOCKERFILE: linux-anvil-cuda
5853
DOCKERTAG: "11.8"
5954
CUDA_VER: "11.8.0"
60-
DISTRO_ARCH: "arm64"
6155
DISTRO_NAME: "ubi"
6256
DISTRO_VER: "8"
6357
SHORT_DESCRIPTION: "conda-forge build image for Cent0S 8 on aarch64 with CUDA"

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ environment variables passed in to be able to build. In this case, you
1818
will want to use a command similar to the following:
1919

2020
```sh
21-
docker build --rm --build-arg DISTRO_NAME=centos --build-arg DISTRO_VER=6 --build-arg CUDA_VER=11.8.0 -f linux-anvil-cuda/Dockerfile .
21+
docker build --rm --build-arg DISTRO_NAME=centos --build-arg DISTRO_VER=6 --build-arg CUDA_VER=10.2 -f linux-anvil-cuda/Dockerfile .
2222
```
2323

2424
## Environment variables
2525

26-
* `CUDA_VER`: This is the cuda & cudatoolkit version that will be used. The
27-
value of this variable should be in major-minor-patch format, e.g. `11.8.0`.
28-
* `DISTRO_ARCH`: This is the Linux architecture that the image should use.
29-
Should match the upstream Docker image, e.g. `amd64`.
26+
* `$CUDA_VER`: This is the cuda & cudatoolkit version that will be used. The
27+
value of this variable should be in major-minor for, e.g. `9.2` for versions
28+
`9.x` and `10.x`. For versions `11.x` the variable should be in
29+
major-minor-patch format, e.g. `11.2.0`.
3030
* `DISTRO_NAME`: This is the Linux distro image name that should be built with.
3131
Should match the upstream Docker image, e.g. `centos`.
3232
* `DISTRO_VER`: This is version of Linux distro (typical CentOS) that the image
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
ARG CUDA_VER
2+
ARG DISTRO_NAME
3+
ARG DISTRO_VER
4+
FROM --platform=linux/arm64 nvidia/cuda:${CUDA_VER}-devel-${DISTRO_NAME}${DISTRO_VER}
5+
6+
LABEL maintainer="conda-forge <[email protected]>"
7+
8+
ADD qemu-aarch64-static /usr/bin/qemu-aarch64-static
9+
10+
# Set CUDA_VER during runtime.
11+
ARG CUDA_VER
12+
ARG DISTRO_NAME
13+
ARG DISTRO_VER
14+
ENV CUDA_VER=${CUDA_VER} \
15+
DISTRO_NAME=${DISTRO_NAME} \
16+
DISTRO_VER=${DISTRO_VER}
17+
18+
# Set an encoding to make things work smoothly.
19+
ENV LANG en_US.UTF-8
20+
ENV LANGUAGE=en_US.UTF-8
21+
22+
# Set path to CUDA install.
23+
ENV CUDA_HOME /usr/local/cuda
24+
25+
# we want to persist a path in ldconfig (to avoid having to always set LD_LIBRARY_PATH), but *after* the existing entries;
26+
# since entries in ld.so.conf.d have precedence before the preconfigured directories, we first add the latter to the former
27+
# the upstream images for 10.x all have libcuda.so under $CUDA_HOME/compat;
28+
# add this to the ldconfig so it will be found correctly.
29+
# don't forget to update settings by running ldconfig
30+
RUN ldconfig -v 2>/dev/null | grep -v ^$'\t' | cut -f1 -d":" >> /etc/ld.so.conf.d/cuda-$CUDA_VER.conf && \
31+
echo "$CUDA_HOME/compat" >> /etc/ld.so.conf.d/cuda-$CUDA_VER.conf && \
32+
ldconfig
33+
34+
# bust the docker cache so that we always rerun the installs below
35+
ADD https://loripsum.net/api /opt/docker/etc/gibberish
36+
37+
# Resolves a nasty NOKEY warning that appears when using yum.
38+
# Naming convention changed with cos8 - see:
39+
# * https://lists.centos.org/pipermail/centos-devel/2019-September/017847.html
40+
# * https://www.centos.org/keys/#project-keys
41+
RUN if [ "${DISTRO_NAME}${DISTRO_VER}" = "centos7" ]; then \
42+
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 && \
43+
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-7-aarch64; \
44+
elif [ "${DISTRO_NAME}${DISTRO_VER}" = "centos8" ]; then \
45+
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial; \
46+
elif [ "${DISTRO_NAME}${DISTRO_VER}" = "ubi8" ]; then \
47+
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release; \
48+
fi
49+
50+
# Add custom `yum_clean_all` script before using `yum`
51+
COPY scripts/yum_clean_all /opt/docker/bin/
52+
53+
# Fallback to CentOS vault for CentOS 8 support.
54+
RUN if [ "${DISTRO_NAME}${DISTRO_VER}" = "centos8" ]; then \
55+
find /etc/yum.repos.d/ -name "CentOS-*.repo" -exec \
56+
sed -i 's/mirrorlist/#mirrorlist/g;s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' {} \; && \
57+
yum update -y --disablerepo=cuda && \
58+
/opt/docker/bin/yum_clean_all; \
59+
fi
60+
61+
# Install basic requirements.
62+
RUN yum update -y --disablerepo=cuda && \
63+
yum install -y \
64+
bzip2 \
65+
sudo \
66+
tar \
67+
which \
68+
&& \
69+
/opt/docker/bin/yum_clean_all
70+
71+
# Fix locale in CentOS8 images
72+
# See https://github.com/CentOS/sig-cloud-instance-images/issues/154
73+
RUN if [ "${DISTRO_NAME}${DISTRO_VER}" = "centos8" ] || [ "${DISTRO_NAME}${DISTRO_VER}" = "ubi8" ]; then \
74+
yum install -y glibc-langpack-en \
75+
&& \
76+
/opt/docker/bin/yum_clean_all; \
77+
fi
78+
79+
# Remove preinclude system compilers
80+
RUN rpm -e --nodeps --verbose gcc gcc-c++
81+
82+
# Run common commands
83+
COPY scripts/run_commands /opt/docker/bin/run_commands
84+
RUN /opt/docker/bin/run_commands
85+
86+
# Download and cache CUDA related packages.
87+
RUN source /opt/conda/etc/profile.d/conda.sh && \
88+
conda activate && \
89+
conda create -n test --yes --quiet --download-only \
90+
conda-forge::cudatoolkit=${CUDA_VER} \
91+
&& \
92+
conda remove --yes --quiet -n test --all && \
93+
conda clean -tiy && \
94+
chgrp -R lucky /opt/conda && \
95+
chmod -R g=u /opt/conda
96+
97+
# Add a file for users to source to activate the `conda`
98+
# environment `root`. Also add a file that wraps that for
99+
# use with the `ENTRYPOINT`.
100+
COPY linux-anvil-aarch64-cuda/entrypoint_source /opt/docker/bin/entrypoint_source
101+
COPY scripts/entrypoint /opt/docker/bin/entrypoint
102+
103+
# Ensure that all containers start with tini and the user selected process.
104+
# Activate the `conda` environment `root`.
105+
# Provide a default command (`bash`), which will start if the user doesn't specify one.
106+
ENTRYPOINT [ "/opt/conda/bin/tini", "--", "/opt/docker/bin/entrypoint" ]
107+
CMD [ "/bin/bash" ]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Add `CUDA_HOME` binaries to `PATH`.
2+
export PATH="${PATH}:${CUDA_HOME}/bin"
3+
4+
# Activate the `base` conda environment.
5+
conda activate base

linux-anvil-cuda/Dockerfile

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,63 @@
11
# Set environment variables during runtime.
22
ARG CUDA_VER
3-
ARG DISTRO_ARCH
43
ARG DISTRO_NAME
54
ARG DISTRO_VER
6-
FROM --platform=linux/${DISTRO_ARCH} nvidia/cuda:${CUDA_VER}-devel-${DISTRO_NAME}${DISTRO_VER}
5+
FROM --platform=linux/amd64 nvidia/cuda:${CUDA_VER}-devel-${DISTRO_NAME}${DISTRO_VER}
76

87
LABEL maintainer="conda-forge <[email protected]>"
98

10-
# Set `ARG`s during runtime.
119
ARG CUDA_VER
12-
ARG DISTRO_ARCH
1310
ARG DISTRO_NAME
1411
ARG DISTRO_VER
1512
ENV CUDA_VER=${CUDA_VER} \
16-
DISTRO_ARCH=${DISTRO_ARCH} \
1713
DISTRO_NAME=${DISTRO_NAME} \
1814
DISTRO_VER=${DISTRO_VER}
1915

2016
# Set an encoding to make things work smoothly.
2117
ENV LANG en_US.UTF-8
22-
ENV LANGUAGE en_US.UTF-8
2318

2419
# Set path to CUDA install (this is a symlink to /usr/local/cuda-${CUDA_VER})
2520
ENV CUDA_HOME /usr/local/cuda
2621

27-
# bust the docker cache so that we always rerun the installs below
28-
ADD https://loripsum.net/api /opt/docker/etc/gibberish
29-
30-
# Add qemu in here so that we can use this image on regular linux hosts with qemu user installed
31-
ADD qemu-aarch64-static /usr/bin/qemu-aarch64-static
32-
ADD qemu-ppc64le-static /usr/bin/qemu-ppc64le-static
33-
3422
# we want to persist a path in ldconfig (to avoid having to always set LD_LIBRARY_PATH), but *after* the existing entries;
3523
# since entries in ld.so.conf.d have precedence before the preconfigured directories, we first add the latter to the former
36-
# the upstream images all have libcuda.so under $CUDA_HOME/compat;
37-
# add this to the ldconfig so it will be found correctly.
38-
# don't forget to update settings by running ldconfig
39-
RUN ldconfig -v 2>/dev/null | grep -v ^$'\t' | cut -f1 -d":" >> /etc/ld.so.conf.d/cuda-$CUDA_VER.conf && \
40-
echo "$CUDA_HOME/compat" >> /etc/ld.so.conf.d/cuda-$CUDA_VER.conf && \
41-
ldconfig
24+
RUN ldconfig -v 2>/dev/null | grep -v ^$'\t' | cut -f1 -d":" >> /etc/ld.so.conf.d/cuda-$CUDA_VER.conf \
25+
&& if [ ${CUDA_VER} != "9.2" ]; then \
26+
# the upstream images for 10.x all have libcuda.so under $CUDA_HOME/compat;
27+
# add this to the ldconfig so it will be found correctly.
28+
echo "$CUDA_HOME/compat" >> /etc/ld.so.conf.d/cuda-$CUDA_VER.conf ; \
29+
else \
30+
# For 9.2, the image nvidia/cuda:9.2-devel-centos6 contains neither
31+
# $CUDA_HOME/compat, nor any (non-stub) libcuda.so. We fix this by
32+
# adding cuda-compat-10.0 (which is not used for building, but to
33+
# test if loading the respective library/package works). However,
34+
# due to licensing reasons, these cannot be part of the conda-forge
35+
# docker images, but are instead added for CI purposes in:
36+
# github.com/conda-forge/conda-forge-ci-setup-feedstock/blob/master/recipe/run_conda_forge_build_setup_linux
37+
# Here we only set the ldconfig accordingly.
38+
echo "/usr/local/cuda-10.0/compat" >> /etc/ld.so.conf.d/cuda-$CUDA_VER.conf ; \
39+
fi \
40+
# don't forget to update settings by running ldconfig
41+
&& ldconfig
42+
43+
# bust the docker cache so that we always rerun the installs below
44+
ADD https://loripsum.net/api /opt/docker/etc/gibberish
4245

4346
# Add the archived repo URL and fix RPM imports
4447
ADD centos7-repos /tmp/centos7-repos
4548
ADD scripts/fix_rpm /opt/docker/bin/fix_rpm
4649
RUN /opt/docker/bin/fix_rpm
4750

48-
# Add custom `yum_clean_all` script before using `yum`
49-
COPY scripts/yum_clean_all /opt/docker/bin/
50-
5151
# Install basic requirements.
52+
COPY scripts/yum_clean_all /opt/docker/bin/
5253
RUN yum update -y --disablerepo=cuda && \
5354
yum install -y \
5455
bzip2 \
5556
sudo \
5657
tar \
57-
which \
58-
&& \
58+
which && \
5959
/opt/docker/bin/yum_clean_all
6060

61-
# Fix locale in UBI 8 images
62-
# See https://github.com/CentOS/sig-cloud-instance-images/issues/154
63-
RUN if [ "${DISTRO_NAME}${DISTRO_VER}" = "ubi8" ]; then \
64-
yum install -y \
65-
glibc-langpack-en \
66-
&& \
67-
/opt/docker/bin/yum_clean_all; \
68-
fi
69-
7061
# Remove preinclude system compilers
7162
RUN rpm -e --nodeps --verbose gcc gcc-c++
7263

@@ -85,14 +76,26 @@ RUN source /opt/conda/etc/profile.d/conda.sh && \
8576
chgrp -R lucky /opt/conda && \
8677
chmod -R g=u /opt/conda
8778

79+
# Symlink CUDA headers that were moved from $CUDA_HOME/include to /usr/include
80+
# in CUDA 10.1.
81+
RUN for HEADER_FILE in cublas_api.h cublas.h cublasLt.h cublas_v2.h cublasXt.h nvblas.h; do \
82+
if [[ ! -f "${CUDA_HOME}/include/${HEADER_FILE}" ]]; \
83+
then ln -s "/usr/include/${HEADER_FILE}" "${CUDA_HOME}/include/${HEADER_FILE}"; \
84+
fi; \
85+
done
86+
87+
# Add qemu in here so that we can use this image on regular linux hosts with qemu user installed
88+
ADD qemu-aarch64-static /usr/bin/qemu-aarch64-static
89+
ADD qemu-ppc64le-static /usr/bin/qemu-ppc64le-static
90+
8891
# Add a file for users to source to activate the `conda`
8992
# environment `base`. Also add a file that wraps that for
9093
# use with the `ENTRYPOINT`.
9194
COPY linux-anvil-cuda/entrypoint_source /opt/docker/bin/entrypoint_source
9295
COPY scripts/entrypoint /opt/docker/bin/entrypoint
9396

9497
# Ensure that all containers start with tini and the user selected process.
95-
# Activate the `conda` environment `base`.
98+
# Activate the `conda` environment `base` and the devtoolset compiler.
9699
# Provide a default command (`bash`), which will start if the user doesn't specify one.
97100
ENTRYPOINT [ "/opt/conda/bin/tini", "--", "/opt/docker/bin/entrypoint" ]
98101
CMD [ "/bin/bash" ]

0 commit comments

Comments
 (0)