Skip to content

Commit 8578139

Browse files
committed
docker: Add free-threaded base
1 parent 69ffd48 commit 8578139

6 files changed

Lines changed: 120 additions & 21 deletions

File tree

docker/Dockerfile.amd

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,34 @@
44
##############################################################
55

66
ARG ROCM_VERSION=6.3.2
7+
ARG FROM_IMAGE=ubuntu:22.04
78

9+
FROM $base AS ubuntu-base
810
FROM rocm/dev-ubuntu-22.04:${ROCM_VERSION}-complete AS sdk-base
911

12+
ENV DEBIAN_FRONTEND=noninteractive
13+
14+
# Base may be specified with the nogil base image to provide Python
15+
COPY --from=ubuntu-base /opt /opt
16+
ENV PATH="/opt/python3/bin:${PATH}"
17+
1018
ARG UCX_BRANCH="v1.16.0"
1119
ARG OMPI_BRANCH="v5.0.x"
1220

1321
# Update and Install basic Linux development tools
1422
RUN rm /etc/apt/sources.list.d/* \
1523
&& apt-get update \
16-
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
17-
dh-autoreconf python3-venv python3-dev python3-pip git \
24+
&& apt-get install -y --no-install-recommends \
25+
dh-autoreconf git \
1826
ca-certificates ssh make libtinfo* initramfs-tools libelf-dev \
1927
wget build-essential autoconf automake libtool \
20-
pkg-config libnuma* gfortran flex hwloc cmake
28+
pkg-config libnuma* gfortran flex hwloc cmake && \
29+
if [ ! -d "/opt/python3" ]; then \
30+
apt-get install -y --no-install-recommends \
31+
python3-venv python3-dev python3-pip; \
32+
else \
33+
echo "Using free-threaded Python build"; \
34+
fi;
2135

2236
ENV ROCM_HOME=/opt/rocm\
2337
UCX_HOME=/opt/ucx \
@@ -84,8 +98,8 @@ RUN rm -rf /tmp/ucx && rm -rf /tmp/ompi
8498
# Adding OpenMPI and UCX to Environment
8599
ENV PATH=$OMPI_HOME/bin:$UCX_HOME/bin:$PATH \
86100
LD_LIBRARY_PATH=$OMPI_HOME/lib:$UCX_HOME/lib:$LD_LIBRARY_PATH \
87-
C_INCLUDE_PATH=$OMPI_HOME/include:$UCX_HOME/include:$C_INCLUDE_PATH \
88-
CPLUS_INCLUDE_PATH=$OMPI_HOME/include:$UCX_HOME/include:$CPLUS_INCLUDE_PATH \
101+
C_INCLUDE_PATH=$OMPI_HOME/include:$UCX_HOME/include:$C_INCLUDE_PATH \
102+
CPLUS_INCLUDE_PATH=$OMPI_HOME/include:$UCX_HOME/include:$CPLUS_INCLUDE_PATH \
89103
CPATH=$OMPI_HOME/include:$UCX_HOME/include:$CPATH \
90104
INCLUDE=$OMPI_HOME/include:$UCX_HOME/include:$INCLUDE \
91105
PKG_CONFIG_PATH=$OMPI_HOME/lib/pkgconfig:$UCX_HOME/lib/pkgconfig:$PKG_CONFIG_PATH

docker/Dockerfile.cpu

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,22 @@
44
# architectures using GCC compilers and OpenMPI.
55
##############################################################
66

7-
# Base image
8-
FROM ubuntu:22.04 AS base
9-
7+
# Base image is either ubuntu or the nogil base
8+
ARG FROM_IMAGE=ubuntu:22.04
109
ARG gcc=""
1110

11+
FROM $FROM_IMAGE AS base
12+
1213
ENV DEBIAN_FRONTEND=noninteractive
1314

14-
# Install python
15+
# Install python, if not already present
1516
RUN apt-get update && \
16-
apt-get install -y software-properties-common dh-autoreconf python3-venv python3-dev python3-pip
17+
apt-get install -y software-properties-common dh-autoreconf && \
18+
if [ ! -d "/opt/python3" ]; then \
19+
apt-get install -y -q python3-venv python3-dev python3-pip; \
20+
else \
21+
echo "Using free-threaded Python build"; \
22+
fi;
1723

1824
# Install for basic base not containing it
1925
RUN apt-get install -y wget flex libnuma-dev hwloc curl cmake git \

docker/Dockerfile.devito

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,23 @@ FROM $base AS builder
1111
ARG USER_ID=1000
1212
ARG GROUP_ID=1000
1313

14+
1415
################## Install devito ############################################
1516

1617
ENV PIP_USE_PEP517=1
17-
# Install pip dependencies
18+
19+
# Install pip dependencies
1820
RUN python3 -m venv /venv && \
19-
/venv/bin/pip install --no-cache-dir --upgrade pip wheel setuptools && \
20-
/venv/bin/pip install --no-cache-dir jupyter && \
21-
ln -fs /app/nvtop/build/src/nvtop /venv/bin/nvtop
21+
/venv/bin/pip install --no-cache-dir --upgrade pip wheel setuptools
22+
# Jupyter cannot yet be installed with a free-threaded Python build
23+
# See https://github.com/jupyterlab/jupyterlab/issues/16915
24+
ARG base
25+
RUN case "$base" in *nogil) \
26+
echo "Skipping jupyter installation for free-threaded build";; \
27+
*) \
28+
/venv/bin/pip install --no-cache-dir jupyter;; \
29+
esac;
30+
RUN ln -fs /app/nvtop/build/src/nvtop /venv/bin/nvtop
2231

2332
# Copy Devito
2433
ADD . /app/devito

docker/Dockerfile.intel

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@
44
##############################################################
55

66
# Base image
7-
FROM ubuntu:22.04 as base
7+
ARG FROM_IMAGE=ubuntu:22.04
8+
FROM $FROM_IMAGE as base
89

910
ENV DEBIAN_FRONTEND noninteractive
1011

11-
# Install python
12+
# Install python, if not already present
1213
RUN apt-get update && \
13-
apt-get install -y dh-autoreconf python3-venv python3-dev python3-pip
14+
apt-get install -y dh-autoreconf && \
15+
if [ ! -d "/opt/python3" ]; then \
16+
apt-get install -y -q python3-venv python3-dev python3-pip; \
17+
else \
18+
echo "Using free-threaded Python build"; \
19+
fi;
1420

1521
# Install for basic base not containing it
1622
RUN apt-get install -y wget flex libnuma-dev hwloc curl cmake \

docker/Dockerfile.nogil

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
##############################################################
2+
# Builds a base image with free-threaded Python 3.13
3+
##############################################################
4+
5+
ARG FROM_IMAGE=ubuntu:22.04
6+
7+
FROM $FROM_IMAGE AS builder
8+
9+
ENV DEBIAN_FRONTEND=noninteractive
10+
11+
# Add deb-src URI sources for Python build dependence discovery
12+
RUN echo "deb-src http://archive.ubuntu.com/ubuntu/ jammy main" >> /etc/apt/sources.list && \
13+
apt-get update
14+
15+
# Install required build dependencies for Python
16+
RUN apt-get build-dep -y python3
17+
18+
# Install dependencies for all optional modules
19+
# See https://devguide.python.org/getting-started/setup-building/index.html#install-dependencies
20+
RUN apt-get install -y \
21+
git build-essential gdb lcov pkg-config \
22+
libbz2-dev libffi-dev libgdbm-dev libgdbm-compat-dev liblzma-dev \
23+
libncurses5-dev libreadline6-dev libsqlite3-dev libssl-dev \
24+
lzma lzma-dev tk-dev uuid-dev zlib1g-dev libmpdec-dev libzstd-dev
25+
26+
27+
# Clone CPython repository at the 3.13 branch
28+
RUN git clone --depth 1 --branch 3.13 https://github.com/python/cpython.git /tmp/cpython
29+
30+
31+
# Configure, build, and install Python 3.13 with the GIL disabled
32+
WORKDIR /tmp/cpython
33+
RUN ./configure \
34+
--prefix=/opt/python3 \
35+
--disable-gil \
36+
--enable-optimizations \
37+
--enable-multilib \
38+
--enable-shared \
39+
LDFLAGS="-Wl,-rpath /opt/python3/lib"
40+
RUN make -j$(nproc)
41+
RUN make install
42+
43+
44+
# Reset the working directory and clean up
45+
WORKDIR /
46+
RUN rm -rf /tmp/cpython
47+
48+
# Set the PATH to include custom Python build
49+
ENV PATH="/opt/python3/bin:${PATH}"
50+
51+
52+
# Install some Python runtime dependencies
53+
RUN apt-get install -y \
54+
libnuma-dev && \
55+
rm -rf /var/lib/apt/lists/*
56+
57+
RUN python3 -m pip install --upgrade pip && \
58+
python3 -m pip cache purge

docker/Dockerfile.nvidia

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ ARG arch="nvc"
77
########################################################################
88
# Build base image with apt setup and common env
99
########################################################################
10-
FROM ubuntu:22.04 AS sdk-base
10+
ARG FROM_IMAGE=ubuntu:22.04
11+
FROM $FROM_IMAGE AS sdk-base
1112

1213
SHELL ["/bin/bash", "-c"]
1314

@@ -16,7 +17,12 @@ ENV DEBIAN_FRONTEND noninteractive
1617
# Install python
1718
RUN apt-get update && \
1819
apt-get install -y -q gpg apt-utils curl wget libnuma-dev cmake git \
19-
dh-autoreconf python3-venv python3-dev python3-pip
20+
dh-autoreconf && \
21+
if [ ! -d "/opt/python3" ]; then \
22+
apt-get install -y -q python3-venv python3-dev python3-pip; \
23+
else \
24+
echo "Using free-threaded Python build"; \
25+
fi;
2026

2127
# nodesource: nvdashboard requires nodejs>=10
2228
RUN curl https://developer.download.nvidia.com/hpc-sdk/ubuntu/DEB-GPG-KEY-NVIDIA-HPC-SDK | gpg --yes --dearmor -o /usr/share/keyrings/nvidia-hpcsdk-archive-keyring.gpg
@@ -97,8 +103,8 @@ RUN echo "$HPCSDK_HOME/cuda/lib" >> /etc/ld.so.conf.d/nvidia.conf && \
97103
echo "$HPCSDK_HOME/compilers/lib" >> /etc/ld.so.conf.d/nvidia.conf && \
98104
echo "$HPCSDK_HOME/comm_libs/mpi/lib" >> /etc/ld.so.conf.d/nvidia.conf && \
99105
echo "$HPCSDK_CUPTI/lib64" >> /etc/ld.so.conf.d/nvidia.conf && \
100-
echo "$HPCSDK_HOME/math_libs/lib64" >> /etc/ld.so.conf.d/nvidia.conf
101-
106+
echo "$HPCSDK_HOME/math_libs/lib64" >> /etc/ld.so.conf.d/nvidia.conf
107+
102108
# Compiler, CUDA, and Library paths
103109
# CUDA_HOME has been deprecated but keep for now because of other dependencies (@mloubout).
104110
ENV CUDA_HOME $HPCSDK_HOME/cuda

0 commit comments

Comments
 (0)