Allow GPU access inside sandbox
What feature would you like to see?
Currently the sandbox breaks access to nvidia gpus on Linux:
enolan@chonk ~> nvidia-smi
Wed Sep 3 23:07:27 2025
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 570.153.02 Driver Version: 570.153.02 CUDA Version: 12.8 |
|-----------------------------------------+------------------------+----------------------+
[snip]
enolan@chonk ~> ~/.npm-global/bin/codex debug landlock nvidia-smi
Failed to initialize NVML: Unknown Error
There should be a way to allow Codex to use GPUs without completely disabling the sandbox. I want it to be able to run tests for my ML projects. Or it should be allowed by default maybe. But that's a lot of attack surface.
Are you interested in implementing this feature?
No
Additional information
No response
met the same issue
I'm also interested in this.
+1
i found when i pass --dangerously-bypass-approvals-and-sandbox, it can use GPU in docker.
+1
same issue for me but --dangerously-bypass-approvals-and-sandbox (thanks @L1aoXingyu) works on campus HPC cluster
+1
+1
@L1aoXingyu Thanks!
Similar issue on Windows and WSL using the VSCode extension. I'm not a security expert so it's not clear to me why it can't access GPU resources without being in "full access" mode. I still want to limit its access to files on my computer, as I have sensitive data, but I want it to be able to autonomously run ML experiments using my local GPU.
(One especially confusing aspect is the fact that in non-full-access mode, it can successfully run nvidia-smi and see that the GPU device exists, but torch.cuda.is_available() == False.)
i found when i pass
--dangerously-bypass-approvals-and-sandbox, it can use GPU in docker.
Dangerous bypass should not be required for GPU access -- ideally a flag should be used when calling just like how websearch has one.
I hit the same issue and agree - it should be possible to allow GPU access while still restrict other access.
Totally agree. Should have a command maybe called "enable_GPUs"
really need this feature!!!!
This limitation is due to the sandbox policy. To make this work, we'd need to determine which system call(s) need to be allowed to avoid blocking access to GPU functionality. If someone in the community is willing to investigate this, it would help accelerate this feature.
Not sure about the seccomp part (never used it), but for landlock you just need to add an exception path to /dev/gpu_name that allows it to write to it (LANDLOCK_ACCESS_FS_WRITE_FILE). The exception path support is relatively new in landlock, but as long as your linux distro version is somewhat recent it should be there (works for me on Ubuntu 22).
This is not a "feature" , it is a lack of capability. Claude Code runs my GPU and never report any "access denied" errors
The way I've currently gotten around this in VSCode is to create a devcontainer and then run ChatGPT in full access mode inside of that container. That way, the access is properly scoped, and GPU access is still enabled.
Run Codex with sandbox disabled:
codex --sandbox danger-full-access
or a “nuclear” option that bypasses both approvals and sandboxing:
codex --dangerously-bypass-approvals-and-sandbox
# alias: codex --yolo
@per-mathisen-arm, I've created a PR that implements your suggested approach. Would you be willing to do a code review? Even better if you or someone else in this thread would be willing to do a local build of the change and verify that it allows you to access the GPU.