mirror of https://github.com/docker/compose.git
Parse reservation.devices for GPU requests
Signed-off-by: aiordache <anca.iordache@docker.com>
This commit is contained in:
parent
c6cdfec530
commit
fef73b8af3
|
@ -66,7 +66,9 @@ var compatibleComposeAttributes = []string{
|
||||||
"services.deploy.resources.reservations.cpus",
|
"services.deploy.resources.reservations.cpus",
|
||||||
"services.deploy.resources.reservations.memory",
|
"services.deploy.resources.reservations.memory",
|
||||||
"services.deploy.resources.reservations.devices",
|
"services.deploy.resources.reservations.devices",
|
||||||
|
"services.deploy.resources.reservations.devices.capabilities",
|
||||||
"services.deploy.resources.reservations.devices.count",
|
"services.deploy.resources.reservations.devices.count",
|
||||||
|
"services.deploy.resources.reservations.devices.driver",
|
||||||
"services.deploy.resources.reservations.generic_resources",
|
"services.deploy.resources.reservations.generic_resources",
|
||||||
"services.deploy.resources.reservations.generic_resources.discrete_resource_spec",
|
"services.deploy.resources.reservations.generic_resources.discrete_resource_spec",
|
||||||
"services.deploy.update_config",
|
"services.deploy.update_config",
|
||||||
|
@ -167,3 +169,9 @@ func (c *fargateCompatibilityChecker) CheckDeployResourcesDevicesCapabilities(s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *fargateCompatibilityChecker) CheckDeployResourcesDevicesDriver(s string, r types.DeviceRequest) {
|
||||||
|
if r.Driver != "" && r.Driver != "nvidia" {
|
||||||
|
c.Unsupported("services.deploy.resources.%s.devices.driver = %s", s, r.Driver)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -181,6 +181,25 @@ func toTaskResourceRequirements(reservations *types.Resource) []ecs.TaskDefiniti
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for _, r := range reservations.Devices {
|
||||||
|
hasGpuCap := false
|
||||||
|
for _, c := range r.Capabilities {
|
||||||
|
if c == "gpu" {
|
||||||
|
hasGpuCap = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if hasGpuCap {
|
||||||
|
count := r.Count
|
||||||
|
if count <= 0 {
|
||||||
|
count = 1
|
||||||
|
}
|
||||||
|
requirements = append(requirements, ecs.TaskDefinition_ResourceRequirement{
|
||||||
|
Type: ecsapi.ResourceTypeGpu,
|
||||||
|
Value: fmt.Sprint(count),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
return requirements
|
return requirements
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
19
ecs/gpu.go
19
ecs/gpu.go
|
@ -132,7 +132,7 @@ type resourceRequirements struct {
|
||||||
func getResourceRequirements(project *types.Project) (*resourceRequirements, error) {
|
func getResourceRequirements(project *types.Project) (*resourceRequirements, error) {
|
||||||
return toResourceRequirementsSlice(project).
|
return toResourceRequirementsSlice(project).
|
||||||
filter(func(requirements *resourceRequirements) bool {
|
filter(func(requirements *resourceRequirements) bool {
|
||||||
return requirements.gpus != 0
|
return requirements != nil && requirements.gpus != 0
|
||||||
}).
|
}).
|
||||||
max()
|
max()
|
||||||
}
|
}
|
||||||
|
@ -184,6 +184,23 @@ func toResourceRequirements(service types.ServiceConfig) (*resourceRequirements,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, r := range reservations.Devices {
|
||||||
|
requiresGpus := false
|
||||||
|
for _, c := range r.Capabilities {
|
||||||
|
if c == "gpu" {
|
||||||
|
requiresGpus = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if requiresGpus {
|
||||||
|
requiredGPUs = r.Count
|
||||||
|
if requiredGPUs <= 0 {
|
||||||
|
requiredGPUs = 1
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var nanocpu float64
|
var nanocpu float64
|
||||||
if reservations.NanoCPUs != "" {
|
if reservations.NanoCPUs != "" {
|
||||||
v, err := strconv.ParseFloat(reservations.NanoCPUs, 64)
|
v, err := strconv.ParseFloat(reservations.NanoCPUs, 64)
|
||||||
|
|
Loading…
Reference in New Issue