Skip to content

Commit fa13036

Browse files
Consolidate NVIDIA envs to envs/x86/cuda and add CPU-only build (envs/x86/none)
Merge sm70 and sm100 into a single envs/x86/cuda Dockerfile that accepts CUDA_ARCH and CUDA_VERSION as build arguments. Add a new envs/x86/none environment for CPU-only platforms (no GPU). Update build-nvidia.yml to point at the consolidated Dockerfile and add build-none.yml for the CPU-only image. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent de5573e commit fa13036

8 files changed

Lines changed: 90 additions & 43 deletions

File tree

.github/workflows/build-none.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Build CPU-only Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- envs/x86/none/**
9+
- .github/workflows/build-none.yml
10+
pull_request:
11+
paths:
12+
- envs/x86/none/**
13+
- .github/workflows/build-none.yml
14+
workflow_dispatch:
15+
16+
env:
17+
REGISTRY: docker.io
18+
IMAGE_NAME: higherordermethods/selfish
19+
20+
jobs:
21+
build:
22+
name: Build CPU-only image
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: read
26+
steps:
27+
- name: Check out repository
28+
uses: actions/checkout@v4
29+
30+
- name: Log in to Docker Hub
31+
if: github.event_name != 'pull_request'
32+
uses: docker/login-action@v3
33+
with:
34+
username: ${{ secrets.DOCKERHUB_USERNAME }}
35+
password: ${{ secrets.DOCKERHUB_TOKEN }}
36+
37+
- name: Set up Buildx
38+
uses: docker/setup-buildx-action@v3
39+
40+
- name: Generate image metadata
41+
id: meta
42+
run: |
43+
CPU_PLATFORM="x86"
44+
45+
# Tags: <version>-<cpu_platform>-none
46+
echo "tags<<EOF" >> $GITHUB_OUTPUT
47+
echo "${{ env.IMAGE_NAME }}:latest-${CPU_PLATFORM}-none" >> $GITHUB_OUTPUT
48+
echo "${{ env.IMAGE_NAME }}:${{ github.sha }}-${CPU_PLATFORM}-none" >> $GITHUB_OUTPUT
49+
echo "EOF" >> $GITHUB_OUTPUT
50+
51+
- name: Cache Docker layers
52+
uses: actions/cache@v4
53+
with:
54+
path: /tmp/.buildx-cache
55+
key: ${{ runner.os }}-buildx-none-${{ github.sha }}
56+
restore-keys: |
57+
${{ runner.os }}-buildx-none-
58+
59+
- name: Build and push Docker image
60+
uses: docker/build-push-action@v5
61+
with:
62+
context: .
63+
file: envs/x86/none/Dockerfile
64+
push: ${{ github.event_name != 'pull_request' }}
65+
tags: ${{ steps.meta.outputs.tags }}
66+
cache-from: type=local,src=/tmp/.buildx-cache
67+
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
68+
labels: |
69+
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
70+
org.opencontainers.image.revision=${{ github.sha }}
71+
72+
- name: Move cache
73+
run: |
74+
rm -rf /tmp/.buildx-cache
75+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

.github/workflows/build-nvidia.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ on:
55
branches:
66
- main
77
paths:
8-
- envs/x86/sm70/**
9-
- envs/x86/sm100/**
8+
- envs/x86/cuda/**
109
- .github/workflows/build-nvidia.yml
1110
pull_request:
1211
paths:
13-
- envs/x86/sm70/**
14-
- envs/x86/sm100/**
12+
- envs/x86/cuda/**
1513
- .github/workflows/build-nvidia.yml
1614
workflow_dispatch:
1715

@@ -30,8 +28,10 @@ jobs:
3028
matrix:
3129
include:
3230
- gpu_arch: sm70
31+
cuda_arch: "70"
3332
cuda_version: "12.4"
3433
- gpu_arch: sm100
34+
cuda_arch: "100"
3535
cuda_version: "13.0"
3636
steps:
3737
- name: Check out repository
@@ -77,11 +77,12 @@ jobs:
7777
uses: docker/build-push-action@v5
7878
with:
7979
context: .
80-
file: envs/x86/${{ matrix.gpu_arch }}/Dockerfile
80+
file: envs/x86/cuda/Dockerfile
8181
push: ${{ github.event_name != 'pull_request' }}
8282
tags: ${{ steps.meta.outputs.tags }}
8383
build-args: |
8484
CUDA_VERSION=${{ matrix.cuda_version }}
85+
CUDA_ARCH=${{ matrix.cuda_arch }}
8586
cache-from: type=local,src=/tmp/.buildx-cache
8687
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
8788
labels: |
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ CMD ["interactive-shell"]
8383
# Build stage with Spack pre-installed and ready to be used
8484
FROM bootstrap AS builder
8585

86+
ARG CUDA_VERSION=12.4
87+
ARG CUDA_ARCH=70
8688

8789
# What we want to install and how we want to install it
8890
# is specified in a manifest file (spack.yaml)
@@ -91,15 +93,15 @@ set -o noclobber \
9193
&& (echo spack: \
9294
&& echo ' specs:' \
9395
&& echo ' - feq-parse@2.2.2' \
94-
&& echo ' - openmpi@5.0.8 +cuda cuda_arch=70' \
96+
&& echo " - openmpi@5.0.8 +cuda cuda_arch=${CUDA_ARCH}" \
9597
&& echo ' - hdf5@1.14.5 +fortran +mpi' \
9698
&& echo ' - cmake@3.31.11'\
9799
&& echo ' packages:' \
98100
&& echo ' all:' \
99101
&& echo ' require:' \
100102
&& echo ' - target=x86_64_v3' \
101103
&& echo ' prefer:' \
102-
&& echo ' - cuda_arch=70' \
104+
&& echo " - cuda_arch=${CUDA_ARCH}" \
103105
&& echo ' cuda:' \
104106
&& echo ' buildable: false' \
105107
&& echo ' externals:' \
@@ -114,7 +116,7 @@ set -o noclobber \
114116
&& echo ' view: /opt/views/view') > /opt/spack-environment/spack.yaml
115117

116118
# Apply feq-parse patch to add "c" build dependency
117-
COPY ./envs/x86/sm70/feq-parse.patch /tmp/feq-parse.patch
119+
COPY ./envs/x86/cuda/feq-parse.patch /tmp/feq-parse.patch
118120
#
119121
RUN SPACK_PKGS_ROOT=$(spack repo list | awk '{print $NF}') &&\
120122
SPACK_BUILTIN_PKGS_ROOT=${SPACK_PKGS_ROOT/repos\/spack_repo\/builtin} &&\
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
spack:
22
specs:
33
- feq-parse@2.2.2
4-
- openmpi@5.0.8 +cuda cuda_arch=70
4+
- openmpi@5.0.8 +cuda
55
- hdf5@1.14.5 +fortran +mpi
66

77
packages:
88
all:
99
require:
1010
- "target=x86_64_v3"
11-
prefer:
12-
- "cuda_arch=70"
1311

1412
container:
1513
format: docker
Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
FROM docker.io/rockylinux:9 AS bootstrap
22

3-
ARG CUDA_VERSION=13.0
4-
53
ENV SPACK_ROOT=/opt/spack \
64
CURRENTLY_BUILDING_DOCKER_IMAGE=1 \
75
container=docker
@@ -36,15 +34,6 @@ RUN dnf update -y \
3634
&& rm -rf /var/cache/dnf \
3735
&& dnf clean all
3836

39-
# Install CUDA toolkit from NVIDIA repo
40-
RUN dnf config-manager \
41-
--add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/cuda-rhel9.repo \
42-
&& dnf clean all \
43-
&& dnf update -y \
44-
&& dnf install -y cuda-toolkit-$(echo ${CUDA_VERSION} | tr '.' '-')
45-
46-
RUN ls -l /usr/local/cuda-${CUDA_VERSION}/include/cuda.h
47-
4837
RUN mkdir $SPACK_ROOT && cd $SPACK_ROOT && \
4938
git init --quiet && git remote add origin https://github.com/spack/spack.git && git fetch --depth=1 origin develop && git checkout --detach FETCH_HEAD && \
5039
mkdir -p $SPACK_ROOT/opt/spack
@@ -91,20 +80,13 @@ set -o noclobber \
9180
&& (echo spack: \
9281
&& echo ' specs:' \
9382
&& echo ' - feq-parse@2.2.2' \
94-
&& echo ' - openmpi@5.0.8 +cuda cuda_arch=100' \
83+
&& echo ' - openmpi@5.0.8' \
9584
&& echo ' - hdf5@1.14.5 +fortran +mpi' \
9685
&& echo ' - cmake@3.31.11'\
9786
&& echo ' packages:' \
9887
&& echo ' all:' \
9988
&& echo ' require:' \
10089
&& echo ' - target=x86_64_v3' \
101-
&& echo ' prefer:' \
102-
&& echo ' - cuda_arch=100' \
103-
&& echo ' cuda:' \
104-
&& echo ' buildable: false' \
105-
&& echo ' externals:' \
106-
&& echo " - spec: \"cuda@${CUDA_VERSION}\"" \
107-
&& echo " prefix: \"/usr/local/cuda-${CUDA_VERSION}\"" \
10890
&& echo '' \
10991
&& echo ' concretizer:' \
11092
&& echo ' unify: true' \
@@ -114,7 +96,7 @@ set -o noclobber \
11496
&& echo ' view: /opt/views/view') > /opt/spack-environment/spack.yaml
11597

11698
# Apply feq-parse patch to add "c" build dependency
117-
COPY ./envs/x86/sm100/feq-parse.patch /tmp/feq-parse.patch
99+
COPY ./envs/x86/none/feq-parse.patch /tmp/feq-parse.patch
118100
#
119101
RUN SPACK_PKGS_ROOT=$(spack repo list | awk '{print $NF}') &&\
120102
SPACK_BUILTIN_PKGS_ROOT=${SPACK_PKGS_ROOT/repos\/spack_repo\/builtin} &&\
@@ -155,15 +137,6 @@ RUN dnf update -y \
155137
gcc-gfortran \
156138
lcov
157139

158-
# Install CUDA toolkit (nvcc + libraries) so downstream projects can compile against CUDA
159-
ARG CUDA_VERSION=13.0
160-
RUN dnf config-manager \
161-
--add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/cuda-rhel9.repo \
162-
&& dnf clean all \
163-
&& dnf update -y \
164-
&& dnf install -y \
165-
cuda-toolkit-$(echo ${CUDA_VERSION} | tr '.' '-')
166-
167140
# paths.view is a symlink, so copy the parent to avoid dereferencing and duplicating it
168141
COPY --from=builder /opt/views /opt/views
169142

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
spack:
22
specs:
33
- feq-parse@2.2.2
4-
- openmpi@5.0.8 +cuda cuda_arch=100
4+
- openmpi@5.0.8
55
- hdf5@1.14.5 +fortran +mpi
66

77
packages:
88
all:
99
require:
1010
- "target=x86_64_v3"
11-
prefer:
12-
- "cuda_arch=100"
1311

1412
container:
1513
format: docker

0 commit comments

Comments
 (0)