Skip to content

Commit ed331dc

Browse files
committed
fix: failed to allocate by policy
Signed-off-by: thxCode <thxcode0824@gmail.com>
1 parent 12cf315 commit ed331dc

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

gpustack_runtime/deployer/k8s/deviceplugin/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ async def serve_async(
110110
device=dev,
111111
id_by="index" if manu == ManufacturerEnum.ASCEND else "uuid",
112112
allocation_policy=allocation_policy,
113+
max_allocations=envs.GPUSTACK_RUNTIME_KUBERNETES_KDP_PER_DEVICE_MAX_ALLOCATIONS,
113114
),
114115
)
115116

gpustack_runtime/deployer/k8s/deviceplugin/plugin.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from grpc_interceptor import AsyncServerInterceptor
1212
from grpc_interceptor.exceptions import GrpcException
1313

14-
from .... import envs
1514
from ....detector import Device, str_range_to_list
1615
from ...cdi import (
1716
generate_config,
@@ -135,7 +134,7 @@ def __init__(
135134
device: Device,
136135
id_by: Literal["uuid", "index"] = "uuid",
137136
allocation_policy: Literal["env", "cdi", "opaque"] = "cdi",
138-
max_allocations: int | None = None,
137+
max_allocations: int | None = 10,
139138
):
140139
"""
141140
Initializes the SharableDevicePlugin.
@@ -150,18 +149,12 @@ def __init__(
150149
Controls the device allocation policy.
151150
max_allocations:
152151
Controls the maximum allocations per underlying device.
153-
If None, uses the environment variable `GPUSTACK_RUNTIME_KUBERNETES_KDP_PER_DEVICE_MAX_ALLOCATIONS`.
154152
155153
"""
156154
self._device = device
157155
self._id_by = id_by
158156
self._allocation_policy = allocation_policy
159-
self._max_allocations = max_allocations
160-
if not self._max_allocations:
161-
self._max_allocations = (
162-
envs.GPUSTACK_RUNTIME_KUBERNETES_KDP_PER_DEVICE_MAX_ALLOCATIONS
163-
)
164-
self._max_allocations = max(self._max_allocations, 1)
157+
self._max_allocations = max(max_allocations, 1)
165158
self._cdi_kind = manufacturer_to_cdi_kind(device.manufacturer)
166159
self._runtime_env = manufacturer_to_runtime_env(device.manufacturer)
167160
self._kdp_resource = cdi_kind_to_kdp_resource(
@@ -425,8 +418,7 @@ def _allocate(
425418
self,
426419
req: ContainerAllocateRequest,
427420
) -> ContainerAllocateResponse:
428-
policy = envs.GPUSTACK_RUNTIME_KUBERNETES_KDP_DEVICE_ALLOCATION_POLICY.lower()
429-
421+
policy = self._allocation_policy
430422
request_dp_device_ids = req.devices_ids
431423

432424
# CDI device allocation.

0 commit comments

Comments
 (0)