codex icon indicating copy to clipboard operation
codex copied to clipboard

Allow GPU access inside sandbox

Open enolan opened this issue 1 year ago • 40 comments

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

enolan avatar Sep 04 '25 03:09 enolan

met the same issue

L1aoXingyu avatar Sep 11 '25 07:09 L1aoXingyu

I'm also interested in this.

davidstap avatar Sep 17 '25 08:09 davidstap

+1

nallana avatar Sep 22 '25 23:09 nallana

i found when i pass --dangerously-bypass-approvals-and-sandbox, it can use GPU in docker.

L1aoXingyu avatar Sep 23 '25 02:09 L1aoXingyu

+1

ShangAlex avatar Sep 30 '25 18:09 ShangAlex

same issue for me but --dangerously-bypass-approvals-and-sandbox (thanks @L1aoXingyu) works on campus HPC cluster

annawoodard avatar Oct 13 '25 14:10 annawoodard

+1

Hemistone avatar Oct 15 '25 01:10 Hemistone

+1

devjj avatar Oct 24 '25 02:10 devjj

@L1aoXingyu Thanks!

CedricHwong avatar Nov 08 '25 07:11 CedricHwong

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.)

Jadiker avatar Nov 11 '25 23:11 Jadiker

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.

glennmatlin avatar Nov 12 '25 22:11 glennmatlin

I hit the same issue and agree - it should be possible to allow GPU access while still restrict other access.

haimat avatar Nov 14 '25 14:11 haimat

Totally agree. Should have a command maybe called "enable_GPUs"

HenryQUQ avatar Nov 14 '25 14:11 HenryQUQ

really need this feature!!!!

Infinity12306 avatar Nov 17 '25 07:11 Infinity12306

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.

etraut-openai avatar Nov 27 '25 07:11 etraut-openai

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).

per-mathisen-arm avatar Dec 04 '25 15:12 per-mathisen-arm

This is not a "feature" , it is a lack of capability. Claude Code runs my GPU and never report any "access denied" errors

nuliknol avatar Dec 09 '25 03:12 nuliknol

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.

Jadiker avatar Dec 09 '25 09:12 Jadiker

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

hiuxia avatar Dec 12 '25 14:12 hiuxia

@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.

etraut-openai avatar Dec 14 '25 06:12 etraut-openai