Skip to content

feat: add opt-in direct GPU access (--gpu) - #12

Open
jgforbes wants to merge 1 commit into
fityannugroho:mainfrom
jgforbes:feat/gpu-access
Open

jgforbes wants to merge 1 commit into
fityannugroho:mainfrom
jgforbes:feat/gpu-access

Conversation

@jgforbes

Copy link
Copy Markdown
Contributor

$ nvidia-smi -L && ./opencodebox --gpu
GPU 0: NVIDIA GeForce RTX 3090 (UUID: GPU-a6984273-01a5-22e8-5ddd-8bbbf032c9e5)
Warning: --gpu exposes host GPU devices and read-only sysfs; GPU resources and driver access are shared with the host.
▄
█▀▀█ █▀▀█ █▀▀█ █▀▀▄ █▀▀▀ █▀▀█ █▀▀█ █▀▀█
█ █ █ █ █▀▀▀ █ █ █ █ █ █ █ █▀▀▀
▀▀▀▀ █▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀

Session GPU checks via nvidia-smi and torch.cuda
Continue opencode -s ses_ea3925f38ffevqS7Foiuo1Wx9f

Both commands ran successfully. Let me summarize the results for the user.

Everything checks out — CUDA is fully functional:

nvidia-smi -L

GPU 0: NVIDIA GeForce RTX 3090 (UUID: GPU-a6984273-01a5-22e8-5ddd-8bbbf032c9e5)

torch.cuda checks

Check Result
torch version 2.13.0+cu130
CUDA available ✅ True
CUDA built with 13.0
Device count 1
Device NVIDIA GeForce RTX 3090 (Ampere, sm_86)
Total memory 23.56 GiB
SMs 82
cuDNN 92000, enabled ✅
Compute test 1024×1024 matmul on cuda:0 — ✅ OK (float32)

The single RTX 3090 is visible to PyTorch, and an actual GPU kernel (matmul + synchronize) ran without errors, so the driver/CUDA/torch stack is working end-to-end.

Heads-up on versions: torch 2.13.0+cu130 is built against CUDA 13.0 — if you plan to compile extensions (flash-attn, deepspeed, custom kernels), make sure the local CUDA toolkit matches or is compatible with sm_86. Want me to check the driver version / nvcc toolkit as well?

Expose host GPU devices inside the sandbox behind an explicit --gpu flag.
NVIDIA (/dev/nvidiaN + auxiliary), DRM (dri/cardN, renderDN) and AMD (kfd)
character devices are discovered at launch and mounted individually with
--dev-bind, along with read-only sysfs and driver metadata (ld.so.cache,
OpenCL/Vulkan/glvnd ICDs, /proc/driver/nvidia). Symlinked nodes and device
directories are rejected, non-matching names are skipped, and a missing GPU
fails with a clear error before bwrap runs.

GPU mounts follow the private /dev, so explicit --with/--with-ro binds can
still override them and the OpenCode v2 isolation overlay stays last. The
feature is default-off; without --gpu no GPU-specific mounts or probes are
added.

Ported from the sandbox-podman-persistent-tmp branch (6283b83), scoped to
the GPU feature only. Tests are ported from unittest/test_podman to the
pytest harness in tests/ (14 new tests; full suite: 76 passed). Docs note
that dri/cardN also exposes display/KMS and that NPUs stay out of scope,
per upstream feedback on the earlier proposal (fityannugroho#6).
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.

1 participant