Skip to content

Commit d98a381

Browse files
authored
Allow unprivileged docker runs for local testing (#380)
2 parents ddeddb4 + 5da33bf commit d98a381

2 files changed

Lines changed: 19 additions & 8 deletions

File tree

.github/workflows/docker-ci.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
with:
3030
context: .
3131
tags: pysages:latest
32+
build-args: |
33+
JAX_PLATFORMS=cpu
3234
outputs: type=docker,dest=/tmp/pysages.tar
3335
- name: Upload artifact
3436
uses: actions/upload-artifact@v4
@@ -142,11 +144,11 @@ jobs:
142144
- name: Load and run test
143145
run: |
144146
SCRIPT="cd PySAGES/examples/openmm/umbrella_integration &&"
145-
SCRIPT="${SCRIPT} mpirun --allow-run-as-root --oversubscribe -n 6"
147+
SCRIPT="${SCRIPT} mpirun --oversubscribe -n 6"
146148
SCRIPT="${SCRIPT} python3 -m mpi4py.futures"
147149
SCRIPT="${SCRIPT} integration.py --replicas=5 --time-steps=1000 --mpi"
148150
docker load --input /tmp/pysages.tar
149-
docker run --privileged -t pysages bash -c "${SCRIPT}"
151+
docker run --user pysages -e HOME=/home/pysages -t pysages bash -c "${SCRIPT}"
150152
151153
cv-pucker-openmm-unbiased:
152154
runs-on: ubuntu-latest
@@ -214,11 +216,11 @@ jobs:
214216
- name: Load and run test
215217
run: |
216218
SCRIPT="cd PySAGES/examples/openmm/string &&"
217-
SCRIPT="${SCRIPT} mpirun --allow-run-as-root --oversubscribe -n 6"
219+
SCRIPT="${SCRIPT} mpirun --oversubscribe -n 6"
218220
SCRIPT="${SCRIPT} python3 -m mpi4py.futures"
219221
SCRIPT="${SCRIPT} integration.py --replicas=5 --string-steps=2 --time-steps=1000 --mpi"
220222
docker load --input /tmp/pysages.tar
221-
docker run --privileged -t pysages bash -c "${SCRIPT}"
223+
docker run --user pysages -e HOME=/home/pysages -t pysages bash -c "${SCRIPT}"
222224
223225
openmm-nacl-metad-displacement:
224226
runs-on: ubuntu-latest
@@ -396,12 +398,12 @@ jobs:
396398
run: |
397399
SCRIPT="cd PySAGES/examples/hoomd-blue/umbrella_integration &&"
398400
SCRIPT="${SCRIPT} python3 ./gen_gsd.py &&"
399-
SCRIPT="${SCRIPT} mpirun --allow-run-as-root --oversubscribe -n 2"
401+
SCRIPT="${SCRIPT} mpirun --oversubscribe -n 2"
400402
SCRIPT="${SCRIPT} python3 -m mpi4py.futures"
401403
SCRIPT="${SCRIPT} integration.py --replicas=5 --time-steps=1000 --mpi &&"
402404
SCRIPT="${SCRIPT} mkdir /tmp/plots && mv *.pdf /tmp/plots/"
403405
docker load --input /tmp/pysages.tar
404-
docker run -v /tmp:/tmp -t pysages bash -c "${SCRIPT}"
406+
docker run -v /tmp:/tmp --user pysages -e HOME=/home/pysages -t pysages bash -c "${SCRIPT}"
405407
- name: Upload artifacts
406408
uses: actions/upload-artifact@v4
407409
with:

Dockerfile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,17 @@ RUN python -m pip install --upgrade pip
66
RUN python -m pip install ase dill "gsd<3.3" matplotlib "pyparsing<3"
77

88
# Install JAX and JAX-based libraries
9-
RUN python -m pip install --upgrade "jax[cuda]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
10-
RUN python -m pip install --upgrade "dm-haiku<0.0.11" "e3nn-jax!=0.20.4" "jax-md>=0.2.7" jaxopt
9+
# TODO: Remove jax pin once DLPack buffer alignment is fixed
10+
RUN python -m pip install --upgrade "jax[cuda]==0.4.34" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
11+
RUN python -m pip install --upgrade "jax==0.4.34" "dm-haiku<0.0.11" "e3nn-jax!=0.20.4" "jax-md>=0.2.7" jaxopt
12+
13+
ARG JAX_PLATFORMS=""
14+
ENV JAX_PLATFORMS=${JAX_PLATFORMS}
1115

1216
COPY . /PySAGES
1317
RUN pip install /PySAGES/
18+
19+
# Disable CAP_SYS_PTRACE requirement for vader's CMA single-copy path.
20+
ENV OMPI_MCA_btl_vader_single_copy_mechanism=none
21+
# Non-privileged setups (e.g. MPI CI jobs) can use `docker run --user pysages`.
22+
RUN useradd -m -u 1000 pysages && chown -R pysages:pysages /PySAGES

0 commit comments

Comments
 (0)