late-queen-51746
12/06/2025, 5:02 AMlimited-student-10747
12/06/2025, 5:55 AMnutritious-balloon-65098
12/06/2025, 5:55 AMnutritious-balloon-65098
12/06/2025, 5:59 AMconfig.toml):
[sandbox]
enable_gpu = true
cuda_visible_devices = "" # Empty = all GPUs, or "0,1" for specific GPUs
Via CLI:
openhands serve --gpu
Method 2: Software Agent SDK
from openhands.workspace.docker import DockerWorkspace
workspace = DockerWorkspace(
server_image="<http://ghcr.io/openhands/agent-server:latest|ghcr.io/openhands/agent-server:latest>",
enable_gpu=True
)
Key Implementation Details:
1. OpenHands Main App (openhands/runtime/impl/docker/docker_runtime.py):
◦ Uses Docker's DeviceRequest API
◦ Supports selective GPU mounting via cuda_visible_devices parameter
◦ Can mount all GPUs (count=-1) or specific GPU IDs
2. Software Agent SDK (openhands-workspace/openhands/workspace/docker/workspace.py):
◦ Adds --gpus all flag to docker run command
◦ Simpler implementation, always mounts all GPUs when enabled
Verification:
After enabling, test with:
nvidia-smi
in the OpenHands runtime environment to confirm GPU access.
No code changes were made - this was purely an informational request that I answered by analyzing the existing codebase in both repositories.
<sub>View full conversation</sub>limited-student-10747
12/06/2025, 7:54 AMnutritious-balloon-65098
12/06/2025, 7:54 AMlimited-student-10747
12/06/2025, 7:56 AMnutritious-balloon-65098
12/06/2025, 8:02 AMopenhands/usage/advanced/configuration-options.mdx)
• New "GPU Support" section with enable_gpu and cuda_visible_devices parameters
• Configuration examples, prerequisites, and verification steps
• Source: sandbox_config.py (lines 86, 96), docker_runtime.py (lines 497-511)
2. GUI Mode (openhands/usage/run-openhands/gui-mode.mdx)
• Enhanced existing GPU section with environment variable and config.toml examples
• Cross-reference to detailed configuration options
• Source: arg_utils.py (line 182 - --gpu flag)
3. Environment Variables (openhands/usage/environment-variables.mdx)
• Enhanced descriptions for SANDBOX_ENABLE_GPU and SANDBOX_CUDA_VISIBLE_DEVICES
• Source: sandbox_config.py field definitions
4. SDK Docker Sandbox (sdk/guides/agent-server/docker-sandbox.mdx)
• New comprehensive section with code examples for DockerWorkspace and DockerDevWorkspace
• Practical use cases (ML training, GPU-accelerated data processing)
• Documented SDK limitation: no selective GPU mounting (always uses --gpus all)
• Source: workspace.py (lines 113-116, ~295)
🔗 Pull Request
Draft PR Created: https://github.com/OpenHands/docs/pull/155
The PR includes:
• 4 files changed
• 215 insertions, 2 deletions
• All changes grounded in source code analysis
• Detailed PR description with source references
📝 Answer Recap
To enable GPU support in OpenHands Docker workspaces:
Main Application:
# CLI flag
openhands serve --gpu
# Or via config.toml
[sandbox]
enable_gpu = true
cuda_visible_devices = "0,1" # Optional: specific GPUs
# Or via environment variables
export SANDBOX_ENABLE_GPU=true
export SANDBOX_CUDA_VISIBLE_DEVICES="0,1"
Software Agent SDK:
from openhands.workspace import DockerWorkspace
workspace = DockerWorkspace(
server_image="<http://ghcr.io/openhands/agent-server:latest-python|ghcr.io/openhands/agent-server:latest-python>",
enable_gpu=True # Mounts all GPUs
)
Prerequisites: NVIDIA GPU drivers + NVIDIA Container Toolkit (nvidia-docker2)
The documentation is now ready for review! 🎉
<sub>View full conversation</sub>