Skip to content

Commit 19b7f01

Browse files
committed
Docker: Reorder layers so that the copy of the repo happens last, ensuring better layer caching.
1 parent e78df34 commit 19b7f01

File tree

6 files changed

+74
-62
lines changed

6 files changed

+74
-62
lines changed

tutorials/accelerated-python/brev/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ services:
2727
user: root
2828
working_dir: *working-dir
2929
restart: "no"
30-
entrypoint: ["/update-git-branch.bash"]
30+
entrypoint: ["/opt/update-git-branch.bash"]
3131
jupyter:
3232
image: *image
3333
depends_on:

tutorials/accelerated-python/brev/dockerfile

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
FROM rapidsai/devcontainers:25.10-cpp-cuda12.9
22

33
ARG GIT_BRANCH_NAME
4-
ENV GIT_BRANCH_NAME=${GIT_BRANCH_NAME}
54

6-
COPY . /accelerated-computing-hub
7-
COPY brev/update-git-branch.bash /update-git-branch.bash
8-
9-
WORKDIR /accelerated-computing-hub/tutorials/accelerated-python/notebooks
5+
ENV GIT_BRANCH_NAME=${GIT_BRANCH_NAME} \
6+
PIP_ROOT_USER_ACTION=ignore \
7+
CUDF_VENV=/opt/venvs/cudf \
8+
ACH_TUTORIAL=accelerated-python
109

11-
ENV PIP_ROOT_USER_ACTION=ignore \
12-
CUDF_VENV=/opt/venvs/cudf
10+
# Copy only requirements.txt first for better Docker layer caching.
11+
COPY tutorials/${ACH_TUTORIAL}/brev/requirements.txt /opt/requirements.txt
1312

1413
RUN `# Install Python packages` \
15-
&& pip install --root-user-action=ignore -r /accelerated-computing-hub/tutorials/accelerated-python/brev/requirements.txt \
14+
&& pip install --root-user-action=ignore -r /opt/requirements.txt \
1615
&& `# Install system packages` \
1716
&& apt-get update -y \
1817
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends git-lfs \
@@ -41,4 +40,9 @@ RUN `# Install Python packages` \
4140
--display-name="Python 3 (cuDF 25.8)" \
4241
--prefix=/usr/local
4342

44-
ENTRYPOINT ["/accelerated-computing-hub/brev/jupyter-start.bash"]
43+
COPY . /accelerated-computing-hub
44+
COPY brev/update-git-branch.bash /opt/update-git-branch.bash
45+
46+
WORKDIR /accelerated-computing-hub/tutorials/${ACH_TUTORIAL}/notebooks
47+
48+
ENTRYPOINT ["/accelerated-computing-hub/brev/jupyter-start.bash"]

tutorials/cuda-cpp/brev/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ services:
2525
- BREV_ENV_ID
2626
user: root
2727
working_dir: *working-dir
28-
entrypoint: ["/update-git-branch.bash"]
28+
entrypoint: ["/opt/update-git-branch.bash"]
2929
restart: "no"
3030
jupyter:
3131
image: *image

tutorials/cuda-cpp/brev/dockerfile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
FROM rapidsai/devcontainers:25.10-cpp-cuda12.9
22

33
ARG GIT_BRANCH_NAME
4-
ENV GIT_BRANCH_NAME=${GIT_BRANCH_NAME}
54

6-
COPY . /accelerated-computing-hub
7-
COPY brev/update-git-branch.bash /update-git-branch.bash
8-
9-
WORKDIR /accelerated-computing-hub/tutorials/cuda-cpp/notebooks
5+
ENV GIT_BRANCH_NAME=${GIT_BRANCH_NAME} \
6+
PIP_ROOT_USER_ACTION=ignore \
7+
ACH_TUTORIAL=accelerated-python
108

11-
ENV PIP_ROOT_USER_ACTION=ignore
9+
# Copy only requirements.txt first for better Docker layer caching.
10+
COPY tutorials/${ACH_TUTORIAL}/brev/requirements.txt /opt/requirements.txt
1211

1312
RUN `# Install Python packages` \
14-
&& pip install --root-user-action=ignore -r /accelerated-computing-hub/tutorials/cuda-cpp/brev/requirements.txt \
13+
&& pip install --root-user-action=ignore -r /opt/requirements.txt \
1514
&& `# Install system packages` \
1615
&& apt-get update -y \
1716
&& apt-get install -y --no-install-recommends ffmpeg git-lfs \
@@ -29,4 +28,9 @@ RUN `# Install Python packages` \
2928
&& ln -fs /accelerated-computing-hub/brev/ipython-startup-add-cwd-to-path.py ~/.ipython/profile_default/startup/00-add-cwd-to-path.py \
3029
&& python -m jupyter labextension disable "@jupyterlab/apputils-extension:announcements"
3130

31+
COPY . /accelerated-computing-hub
32+
COPY brev/update-git-branch.bash /opt/update-git-branch.bash
33+
34+
WORKDIR /accelerated-computing-hub/tutorials/${ACH_TUTORIAL}/notebooks
35+
3236
ENTRYPOINT ["/accelerated-computing-hub/brev/jupyter-start.bash"]

tutorials/stdpar/brev/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ services:
2525
- BREV_ENV_ID
2626
user: root
2727
working_dir: *working-dir
28-
entrypoint: ["/update-git-branch.bash"]
28+
entrypoint: ["/opt/update-git-branch.bash"]
2929
restart: "no"
3030
jupyter:
3131
image: *image

tutorials/stdpar/brev/docker-recipe.py

Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import platform
77
from hpccm.primitives import raw
88

9+
tutorial = 'stdpar'
910
ubuntu_ver = '22.04'
1011
nvhpc_ver = '24.3'
1112
cuda_ver = '12.3'
@@ -17,10 +18,46 @@
1718

1819
Stage0 += baseimage(image=f'nvcr.io/nvidia/nvhpc:{nvhpc_ver}-devel-cuda{cuda_ver}-ubuntu{ubuntu_ver}')
1920

20-
Stage0 += copy(src='.', dest='/accelerated-computing-hub')
21-
Stage0 += copy(src='brev/update-git-branch.bash', dest='/update-git-branch.bash')
21+
Stage0 += raw(docker='ARG GIT_BRANCH_NAME')
2222

23-
Stage0 += workdir(directory=f'/accelerated-computing-hub/tutorials/stdpar/notebooks')
23+
Stage0 += environment(variables={
24+
'GIT_BRANCH_NAME': '${GIT_BRANCH_NAME}',
25+
26+
'ACH_STDPAR_NVHPC_VERSION': nvhpc_ver,
27+
'ACH_STDPAR_CUDA_VERSION': cuda_ver,
28+
'ACH_STDPAR_ARCH': arch,
29+
30+
'ACPP_APPDB_DIR': '/accelerated-computing-hub/',
31+
32+
'PATH': '$PATH:/opt/adaptivecpp/bin',
33+
'LD_LIBRARY_PATH': f'/usr/lib/llvm-{llvm_ver}/lib:$LD_LIBRARY_PATH',
34+
'LIBRARY_PATH': f'/usr/lib/llvm-{llvm_ver}/lib:$LIBRARY_PATH',
35+
36+
# Silence pip warnings about running as root
37+
'PIP_ROOT_USER_ACTION': 'ignore',
38+
39+
# Simplify running HPC-X on systems without InfiniBand
40+
'OMPI_MCA_coll_hcoll_enable': '0',
41+
42+
# We do not need VFS for the exercises, and using it from a container in a 'generic' way is not trivial:
43+
'UCX_VFS_ENABLE': 'n',
44+
45+
# Allow HPC-X to oversubscribe the CPU with more ranks than cores without using mpirun --oversubscribe
46+
'OMPI_MCA_rmaps_base_oversubscribe' : 'true',
47+
48+
# Select matplotdir config directory to silence warning
49+
'MPLCONFIGDIR': '/tmp/matplotlib',
50+
51+
# Allow OpenMPI to run as root:
52+
'OMPI_ALLOW_RUN_AS_ROOT': '1',
53+
'OMPI_ALLOW_RUN_AS_ROOT_CONFIRM': '1',
54+
55+
# Workaround hwloc binding:
56+
'OMPI_MCA_hwloc_base_binding_policy': 'none',
57+
58+
# Workaround nvfortran limit of 64k thread blocks
59+
'NVCOMPILER_ACC_GANGLIMIT': '67108864', # (1 << 26)
60+
})
2461

2562
Stage0 += packages(ospackages=[
2663
'libtbb-dev', # Required for GCC C++ parallel algorithms
@@ -45,6 +82,9 @@
4582
# Install CMake
4683
Stage0 += cmake(eula=True, version=cmake_ver)
4784

85+
# Copy only requirements.txt first for better Docker layer caching.
86+
Stage0 += copy(src=f'tutorials/{tutorial}/brev/requirements.txt', dest='/opt/requirements.txt')
87+
4888
Stage0 += shell(commands=[
4989
'set -ex', # Exit on first error and debug output
5090

@@ -55,7 +95,7 @@
5595

5696
# Install python packages
5797
'pip install --upgrade pip',
58-
f'pip install --root-user-action=ignore -r /accelerated-computing-hub/tutorials/stdpar/brev/requirements.txt',
98+
f'pip install --root-user-action=ignore -r /opt/requirements.txt',
5999

60100
# Build and install AdaptiveCpp
61101
'git clone --depth=1 --shallow-submodules --recurse-submodules -b develop https://github.com/AdaptiveCpp/AdaptiveCpp',
@@ -109,45 +149,9 @@
109149
'python -m jupyter labextension disable "@jupyterlab/apputils-extension:announcements"',
110150
])
111151

112-
Stage0 += raw(docker='ARG GIT_BRANCH_NAME')
113-
114-
Stage0 += environment(variables={
115-
'GIT_BRANCH_NAME': '${GIT_BRANCH_NAME}',
116-
117-
'ACH_STDPAR_NVHPC_VERSION': nvhpc_ver,
118-
'ACH_STDPAR_CUDA_VERSION': cuda_ver,
119-
'ACH_STDPAR_ARCH': arch,
120-
121-
'ACPP_APPDB_DIR': '/accelerated-computing-hub/',
122-
123-
'PATH': '$PATH:/opt/adaptivecpp/bin',
124-
'LD_LIBRARY_PATH': f'/usr/lib/llvm-{llvm_ver}/lib:$LD_LIBRARY_PATH',
125-
'LIBRARY_PATH': f'/usr/lib/llvm-{llvm_ver}/lib:$LIBRARY_PATH',
126-
127-
# Silence pip warnings about running as root
128-
'PIP_ROOT_USER_ACTION': 'ignore',
129-
130-
# Simplify running HPC-X on systems without InfiniBand
131-
'OMPI_MCA_coll_hcoll_enable': '0',
132-
133-
# We do not need VFS for the exercises, and using it from a container in a 'generic' way is not trivial:
134-
'UCX_VFS_ENABLE': 'n',
135-
136-
# Allow HPC-X to oversubscribe the CPU with more ranks than cores without using mpirun --oversubscribe
137-
'OMPI_MCA_rmaps_base_oversubscribe' : 'true',
138-
139-
# Select matplotdir config directory to silence warning
140-
'MPLCONFIGDIR': '/tmp/matplotlib',
141-
142-
# Allow OpenMPI to run as root:
143-
'OMPI_ALLOW_RUN_AS_ROOT': '1',
144-
'OMPI_ALLOW_RUN_AS_ROOT_CONFIRM': '1',
145-
146-
# Workaround hwloc binding:
147-
'OMPI_MCA_hwloc_base_binding_policy': 'none',
152+
Stage0 += copy(src='.', dest='/accelerated-computing-hub')
153+
Stage0 += copy(src='brev/update-git-branch.bash', dest='/opt/update-git-branch.bash')
148154

149-
# Workaround nvfortran limit of 64k thread blocks
150-
'NVCOMPILER_ACC_GANGLIMIT': '67108864', # (1 << 26)
151-
})
155+
Stage0 += workdir(directory=f'/accelerated-computing-hub/tutorials/{tutorial}/notebooks')
152156

153157
Stage0 += raw(docker='ENTRYPOINT ["/accelerated-computing-hub/brev/jupyter-start.bash"]')

0 commit comments

Comments
 (0)