feat: enable limiting and reserving gpu resources
This commit is contained in:
@@ -15,6 +15,7 @@ type Resource struct {
|
||||
Network string `json:"network"`
|
||||
NetworkIngress string `json:"network-ingress"`
|
||||
NetworkEgress string `json:"network-egress"`
|
||||
NvidiaGPU string `json:"nvidia-gpu"`
|
||||
}
|
||||
|
||||
// ReportSingleApp is an internal function that displays the app report for one or more apps
|
||||
|
||||
@@ -26,6 +26,7 @@ func main() {
|
||||
network := args.String("network", "", "network: The amount of network bandwidth to limit processes by")
|
||||
networkIngress := args.String("network-ingress", "", "network-ingress: The amount of ingress network bandwidth to limit processes by")
|
||||
networkEgress := args.String("network-egress", "", "network-egress: The amount of egress network bandwidth to limit processes by")
|
||||
nvidiaGpu := args.String("nvidia-gpu", "", "nvidia-gpu: The number of Nvidia GPUs to limit a process to")
|
||||
args.Parse(os.Args[2:])
|
||||
|
||||
resources := resource.Resource{
|
||||
@@ -35,6 +36,7 @@ func main() {
|
||||
Network: *network,
|
||||
NetworkIngress: *networkIngress,
|
||||
NetworkEgress: *networkEgress,
|
||||
NvidiaGPU: *nvidiaGpu,
|
||||
}
|
||||
|
||||
err = resource.CommandLimit(args.Args(), *processType, resources)
|
||||
@@ -57,6 +59,7 @@ func main() {
|
||||
network := args.String("network", "", "network: The amount of network bandwidth to reserve for processes")
|
||||
networkIngress := args.String("network-ingress", "", "network-ingress: The amount of ingress network bandwidth to reserve for processes")
|
||||
networkEgress := args.String("network-egress", "", "network-egress: The amount of egress network bandwidth to reserve for processes")
|
||||
nvidiaGpu := args.String("nvidia-gpu", "", "nvidia-gpu: The number of Nvidia GPUs to resource for a process")
|
||||
args.Parse(os.Args[2:])
|
||||
|
||||
resources := resource.Resource{
|
||||
@@ -66,6 +69,7 @@ func main() {
|
||||
Network: *network,
|
||||
NetworkIngress: *networkIngress,
|
||||
NetworkEgress: *networkEgress,
|
||||
NvidiaGPU: *nvidiaGpu,
|
||||
}
|
||||
|
||||
err = resource.CommandReserve(args.Args(), *processType, resources)
|
||||
|
||||
@@ -100,6 +100,7 @@ func clearByResourceType(appName string, processType string, resourceType string
|
||||
"network",
|
||||
"network-ingress",
|
||||
"network-egress",
|
||||
"nvidia-gpu",
|
||||
}
|
||||
|
||||
for _, key := range resources {
|
||||
@@ -121,6 +122,7 @@ func setResourceType(appName string, processType string, r Resource, resourceTyp
|
||||
"network": r.Network,
|
||||
"network-ingress": r.NetworkIngress,
|
||||
"network-egress": r.NetworkEgress,
|
||||
"nvidia-gpu": r.NvidiaGPU,
|
||||
}
|
||||
|
||||
hasValues := false
|
||||
@@ -182,6 +184,7 @@ func reportResourceType(appName string, processType string, resourceType string)
|
||||
"network",
|
||||
"network-ingress",
|
||||
"network-egress",
|
||||
"nvidia-gpu",
|
||||
}
|
||||
|
||||
for _, key := range resources {
|
||||
|
||||
@@ -32,6 +32,7 @@ func TriggerDockerArgsProcessDeploy(appName string, processType string) error {
|
||||
|
||||
validLimits := map[string]bool{
|
||||
"cpu": true,
|
||||
"nvidia-gpu": true,
|
||||
"memory": true,
|
||||
"memory-swap": true,
|
||||
}
|
||||
@@ -54,6 +55,10 @@ func TriggerDockerArgsProcessDeploy(appName string, processType string) error {
|
||||
parts[1] = "cpus"
|
||||
}
|
||||
|
||||
if parts[1] == "nvidia-gpu" {
|
||||
parts[1] = "gpus"
|
||||
}
|
||||
|
||||
limits[parts[1]] = value
|
||||
}
|
||||
if parts[0] == "reserve" {
|
||||
|
||||
Reference in New Issue
Block a user