1111from grpc_interceptor import AsyncServerInterceptor
1212from grpc_interceptor .exceptions import GrpcException
1313
14- from .... import envs
1514from ....detector import Device , str_range_to_list
1615from ...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