feat: Add GPU support (#6042)

This commit is contained in:
மனோஜ்குமார் பழனிச்சாமி 2025-01-05 11:58:05 +05:30 committed by GitHub
parent b7bbf0f5eb
commit 150463e629
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View File

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

View File

@ -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')