Skip to content

Disable Python user site in Apptainer jobs#787

Open
fomo-bot wants to merge 2 commits into
mainfrom
disable-python-user-site-apptainer
Open

Disable Python user site in Apptainer jobs#787
fomo-bot wants to merge 2 commits into
mainfrom
disable-python-user-site-apptainer

Conversation

@fomo-bot

@fomo-bot fomo-bot commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Disable Python user-site packages for Slurm Apptainer train/eval jobs.
  • Export the Apptainer/Singularity environment variables so PYTHONNOUSERSITE=1 is present before Python starts in the container.
  • Re-export PYTHONNOUSERSITE=1 inside the container shell as a belt-and-suspenders guard.

Why

Apptainer mounts $HOME by default. Because the container Python is 3.12, Python was discovering host packages under ~/.local/lib/python3.12/site-packages inside the container. In ORCD H200 debug runs this caused CuPy to import from the host user site and warn about mixed cupy-cuda12x/cupy-cuda13x installs.

The container already includes the needed CuPy package, so the harness should keep host user-site packages out of sys.path.

Validation

  • bash -n scripts/slurm_apptainer_train.sbatch
  • bash -n scripts/slurm_apptainer_eval.sbatch
  • Verified with the cached PR777 PhysicsNeMo Apptainer image and PYTHONNOUSERSITE=1:
    • site.ENABLE_USER_SITE is False
    • /home/jrusak/.local/... is not on sys.path
    • cupy imports from /usr/local/lib/python3.12/dist-packages/cupy
    • only cupy-cuda13x==13.6.0 is installed in the visible environment
    • dask.array imports and computes successfully
    • xarray opens /orcd/data/abodner/002/jrusak/om4_onedeg_v3/OM4.zarr

jder added a commit that referenced this pull request Jul 9, 2026
@jder jder marked this pull request as ready for review July 9, 2026 18:42
@jder jder requested a review from alxmrs July 9, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants