mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
feat: Add GPU support (#6042)
This commit is contained in:
parent
b7bbf0f5eb
commit
150463e629
@ -34,6 +34,7 @@ class SandboxConfig:
|
||||
platform: The platform on which the image should be built. Default is None.
|
||||
remote_runtime_resource_factor: Factor to scale the resource allocation for remote runtime.
|
||||
Must be one of [1, 2, 4, 8]. Will only be used if the runtime is remote.
|
||||
enable_gpu: Whether to enable GPU.
|
||||
"""
|
||||
|
||||
remote_runtime_api_url: str = 'http://localhost:8000'
|
||||
@ -59,6 +60,7 @@ class SandboxConfig:
|
||||
platform: str | None = None
|
||||
close_delay: int = 15
|
||||
remote_runtime_resource_factor: int = 1
|
||||
enable_gpu: bool = False
|
||||
|
||||
def defaults_to_dict(self) -> dict:
|
||||
"""Serialize fields to a dict for the frontend, including type hints, defaults, and whether it's optional."""
|
||||
|
||||
@ -266,6 +266,14 @@ class DockerRuntime(ActionExecutionClient):
|
||||
detach=True,
|
||||
environment=environment,
|
||||
volumes=volumes,
|
||||
device_requests=(
|
||||
[docker.types.DeviceRequest(
|
||||
capabilities=[['gpu']],
|
||||
count=-1
|
||||
)]
|
||||
if self.config.sandbox.enable_gpu
|
||||
else None
|
||||
),
|
||||
)
|
||||
self.log('debug', f'Container started. Server url: {self.api_url}')
|
||||
self.send_status_message('STATUS$CONTAINER_STARTED')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user