Skip to content

docs(examples): add NGC PyTorch GPU sandbox example - #6158

Open
dmonakhov wants to merge 1 commit into
ai-openshell:mainfrom
dmonakhov:ngc-pytorch-gpu-example
Open

dmonakhov wants to merge 1 commit into
ai-openshell:mainfrom
dmonakhov:ngc-pytorch-gpu-example

Conversation

@dmonakhov

@dmonakhov dmonakhov commented Dec 2, 2026 •

Copy link
Copy Markdown

NGC images such as nvcr.io/nvidia/pytorch keep HPC-X and other libraries under /opt, which the default policy does not grant. import torch then fails with "libmpi.so.40: cannot open shared object file", and the denial is hard to diagnose: Landlock does not govern stat(), so ls and ldconfig still show the library, and glibc reports EACCES as "No such file or directory".

Add an example policy that grants /opt and /sys read-only and /dev/shm read-write on top of the default policy, with a one-command CUDA check and an explanation of each addition.

Original discussion: #5445
Fixes #6159

NGC images such as nvcr.io/nvidia/pytorch keep HPC-X and other libraries
under /opt, which the default policy does not grant. `import torch` then
fails with "libmpi.so.40: cannot open shared object file", and the denial
is hard to diagnose: Landlock does not govern stat(), so ls and ldconfig
still show the library, and glibc reports EACCES as "No such file or
directory".

Add an example policy that grants /opt and /sys read-only and /dev/shm
read-write on top of the default policy, with a one-command CUDA check and
an explanation of each addition.

Signed-off-by: Dmitry Monakhov <dmonakhov@nvidia.com>
# NGC images install HPC-X, UCX, and other libraries under /opt. The
# loader cache resolves libmpi.so.40 there, so `import torch` fails
# without it.
- /opt

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My question to the other maintainers is whether /opt should be treated similarly to other standard paths?

@elezar

elezar commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Thanks for the example. A few suggestions on policy.yaml:

1. Drop entries the baseline already provides (read_only and read_write)

/bin, /usr, /lib, /etc, /proc, /var/log and /dev/urandom (read-only), plus /tmp and /dev/null (read-write), copy restrictive_default_policy() (crates/openshell-policy/src/lib.rs). The supervisor baseline (PROXY_BASELINE_READ_ONLY and PROXY_BASELINE_READ_WRITE in crates/openshell-supervisor/src/lib.rs) also adds all of them except /bin in proxy mode. Keeping them means the example silently pins an old default if the default changes. Please list only the additions (/opt…, /sys, /dev/shm), or explain why the full list is required. This also keeps the README sentence "makes these additions to the default policy" accurate.

2. Narrow /opt

The failure in the README is libmpi.so.40 resolved under /opt/hpcx. /opt also contains /opt/openshell, which is OpenShell control state (CONTROL_ROOTS in crates/openshell-core/src/container_paths.rs). On the VM driver this includes the sandbox JWT and CA under /opt/openshell/auth and /opt/openshell/tls; on Podman it includes the supervisor binary and /opt/tools. Landlock grants cannot exclude a subdirectory, so a read-only /opt rule covers the whole tree and relies on file permissions to protect the token. It also covers whatever else a given image installs under /opt. Please grant /opt/hpcx (and any other specific directories the import needs), or document why the whole of /opt is required and that /opt/openshell is covered.

3. Separate the always-needed paths from the GPU-only ones (/sys and /dev/shm)

The README ties each path to PyTorch behavior, but the example only runs with --gpu. Several of these reads happen on any PyTorch import, so the reason for each entry should say whether it applies without a GPU:

  • Needed with or without a GPU: /sys/devices/system/cpu (the cpuinfo error) and /dev/shm for DataLoader workers. GPU-gated runtime enrichment wouldn't help here, because a CPU-only sandbox would still fail. Keep these in the policy, or treat them as a general baseline question.
  • GPU-only: /sys/bus/pci, /sys/class and /sys/devices/system/node (NVML, NCCL and hwloc topology), plus /dev/shm for NCCL's shared-memory transport. These could be derived at runtime for --gpu sandboxes. The existing enrichment (enrich_gpu_filesystem_paths in crates/openshell-sandbox/src/boundary_server.rs) adds neither /sys nor /dev/shm today. feat(gpu): derive Docker sandbox requirements from CDI specs #4204 derives GPU filesystem requirements from CDI specs and may be a place to cover them, but it is Docker-only, so Kubernetes, Podman and VM users would still need the entries.

Please run the example without --gpu, and with each of /opt/hpcx, /sys and /dev/shm removed in turn, then state in the README which paths each case needs. If the GPU-only grants can move to runtime enrichment, narrow /sys to the directories NCCL actually reads. If they can't yet, say so in the policy comments and link #4204.

Process note: #6159 has state:triage-needed, not state:accepted, and the author does not have write access, so the issue-acceptance gate isn't met.

@purp purp added area:runtime Sandbox execution, isolation, supervision, policy enforcement, networking, and provider lifecycle. topic:documentation Architecture docs, READMEs, project website updates, and automated documentation generation. topic:gpu GPU scheduling, Kubernetes DRA, CDI, MIG, and hardware-accelerated runtime integration. topic:policy Policy authoring, validation, proving, distribution, enforcement, ergonomics, and hardening. labels Dec 3, 2026
@purp purp added the state:accepted A maintainer decided OpenShell should pursue this issue label Dec 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:runtime Sandbox execution, isolation, supervision, policy enforcement, networking, and provider lifecycle. state:accepted A maintainer decided OpenShell should pursue this issue topic:documentation Architecture docs, READMEs, project website updates, and automated documentation generation. topic:gpu GPU scheduling, Kubernetes DRA, CDI, MIG, and hardware-accelerated runtime integration. topic:policy Policy authoring, validation, proving, distribution, enforcement, ergonomics, and hardening.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pytorch fails to work inside sandbox with standard nvcr.io/nvidia/pytorch container out of box

3 participants