@@ -77,6 +77,9 @@ const (
77
77
NvidiaVisibleDevicesEnvVar = "NVIDIA_VISIBLE_DEVICES"
78
78
GPUAssociationType = "gpu"
79
79
80
+ // neuronRuntime is the name of the neuron docker runtime.
81
+ neuronRuntime = "neuron"
82
+
80
83
ContainerOrderingCreateCondition = "CREATE"
81
84
ContainerOrderingStartCondition = "START"
82
85
@@ -1430,8 +1433,8 @@ func (task *Task) dockerExposedPorts(container *apicontainer.Container) nat.Port
1430
1433
}
1431
1434
1432
1435
// DockerHostConfig construct the configuration recognized by docker
1433
- func (task * Task ) DockerHostConfig (container * apicontainer.Container , dockerContainerMap map [string ]* apicontainer.DockerContainer , apiVersion dockerclient.DockerVersion ) (* dockercontainer.HostConfig , * apierrors.HostConfigError ) {
1434
- return task .dockerHostConfig (container , dockerContainerMap , apiVersion )
1436
+ func (task * Task ) DockerHostConfig (container * apicontainer.Container , dockerContainerMap map [string ]* apicontainer.DockerContainer , apiVersion dockerclient.DockerVersion , cfg * config. Config ) (* dockercontainer.HostConfig , * apierrors.HostConfigError ) {
1437
+ return task .dockerHostConfig (container , dockerContainerMap , apiVersion , cfg )
1435
1438
}
1436
1439
1437
1440
// ApplyExecutionRoleLogsAuth will check whether the task has execution role
@@ -1459,7 +1462,7 @@ func (task *Task) ApplyExecutionRoleLogsAuth(hostConfig *dockercontainer.HostCon
1459
1462
return nil
1460
1463
}
1461
1464
1462
- func (task * Task ) dockerHostConfig (container * apicontainer.Container , dockerContainerMap map [string ]* apicontainer.DockerContainer , apiVersion dockerclient.DockerVersion ) (* dockercontainer.HostConfig , * apierrors.HostConfigError ) {
1465
+ func (task * Task ) dockerHostConfig (container * apicontainer.Container , dockerContainerMap map [string ]* apicontainer.DockerContainer , apiVersion dockerclient.DockerVersion , cfg * config. Config ) (* dockercontainer.HostConfig , * apierrors.HostConfigError ) {
1463
1466
dockerLinkArr , err := task .dockerLinks (container , dockerContainerMap )
1464
1467
if err != nil {
1465
1468
return nil , & apierrors.HostConfigError {Msg : err .Error ()}
@@ -1488,12 +1491,8 @@ func (task *Task) dockerHostConfig(container *apicontainer.Container, dockerCont
1488
1491
Resources : resources ,
1489
1492
}
1490
1493
1491
- if task .isGPUEnabled () && task .shouldRequireNvidiaRuntime (container ) {
1492
- if task .NvidiaRuntime == "" {
1493
- return nil , & apierrors.HostConfigError {Msg : "Runtime is not set for GPU containers" }
1494
- }
1495
- seelog .Debugf ("Setting runtime as %s for container %s" , task .NvidiaRuntime , container .Name )
1496
- hostConfig .Runtime = task .NvidiaRuntime
1494
+ if err := task .overrideContainerRuntime (container , hostConfig , cfg ); err != nil {
1495
+ return nil , err
1497
1496
}
1498
1497
1499
1498
if container .DockerConfig .HostConfig != nil {
@@ -1537,6 +1536,24 @@ func (task *Task) dockerHostConfig(container *apicontainer.Container, dockerCont
1537
1536
return hostConfig , nil
1538
1537
}
1539
1538
1539
+ // overrideContainerRuntime overrides the runtime for the container in host config if needed.
1540
+ func (task * Task ) overrideContainerRuntime (container * apicontainer.Container , hostCfg * dockercontainer.HostConfig ,
1541
+ cfg * config.Config ) * apierrors.HostConfigError {
1542
+ if task .isGPUEnabled () && task .shouldRequireNvidiaRuntime (container ) {
1543
+ if task .NvidiaRuntime == "" {
1544
+ return & apierrors.HostConfigError {Msg : "Runtime is not set for GPU containers" }
1545
+ }
1546
+ seelog .Debugf ("Setting runtime as %s for container %s" , task .NvidiaRuntime , container .Name )
1547
+ hostCfg .Runtime = task .NvidiaRuntime
1548
+ }
1549
+
1550
+ if cfg .InferentiaSupportEnabled && container .RequireNeuronRuntime () {
1551
+ seelog .Debugf ("Setting runtime as %s for container %s" , neuronRuntime , container .Name )
1552
+ hostCfg .Runtime = neuronRuntime
1553
+ }
1554
+ return nil
1555
+ }
1556
+
1540
1557
// Requires an *apicontainer.Container and returns the Resources for the HostConfig struct
1541
1558
func (task * Task ) getDockerResources (container * apicontainer.Container ) dockercontainer.Resources {
1542
1559
// Convert MB to B and set Memory
0 commit comments