feat: enable limiting and reserving gpu resources
This commit is contained in:
@@ -26,6 +26,7 @@ Valid resource options include:
|
|||||||
- `--network`
|
- `--network`
|
||||||
- `--network-ingress`
|
- `--network-ingress`
|
||||||
- `--network-egress`
|
- `--network-egress`
|
||||||
|
- `--nvidia-gpu`
|
||||||
|
|
||||||
See the [Supported Resource Management Properties](/docs/advanced-usage/schedulers/docker-local.md#supported-resource-management-properties) section of the docker local scheduler documentation for more information on how each resource limit maps to Docker.
|
See the [Supported Resource Management Properties](/docs/advanced-usage/schedulers/docker-local.md#supported-resource-management-properties) section of the docker local scheduler documentation for more information on how each resource limit maps to Docker.
|
||||||
|
|
||||||
@@ -86,6 +87,7 @@ dokku resource:limit node-js-app
|
|||||||
network: 100
|
network: 100
|
||||||
network-ingress:
|
network-ingress:
|
||||||
network-egress:
|
network-egress:
|
||||||
|
nvidia-gpu:
|
||||||
```
|
```
|
||||||
|
|
||||||
This may also be combined with the `--process-type` flag to see app limits on a process-type level. Note that the displayed values are not merged with the defaults.
|
This may also be combined with the `--process-type` flag to see app limits on a process-type level. Note that the displayed values are not merged with the defaults.
|
||||||
@@ -103,6 +105,7 @@ dokku resource:limit --process-type web node-js-app
|
|||||||
network:
|
network:
|
||||||
network-ingress:
|
network-ingress:
|
||||||
network-egress:
|
network-egress:
|
||||||
|
nvidia-gpu:
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Clearing Resource Limits
|
#### Clearing Resource Limits
|
||||||
@@ -182,6 +185,7 @@ dokku resource:reserve node-js-app
|
|||||||
network:
|
network:
|
||||||
network-ingress:
|
network-ingress:
|
||||||
network-egress:
|
network-egress:
|
||||||
|
nvidia-gpu:
|
||||||
```
|
```
|
||||||
|
|
||||||
This may also be combined with the `--process-type` flag to see app reservations on a process-type level. Note that the displayed values are not merged with the defaults.
|
This may also be combined with the `--process-type` flag to see app reservations on a process-type level. Note that the displayed values are not merged with the defaults.
|
||||||
@@ -198,6 +202,7 @@ dokku resource:reserve --process-type web node-js-app
|
|||||||
network:
|
network:
|
||||||
network-ingress:
|
network-ingress:
|
||||||
network-egress:
|
network-egress:
|
||||||
|
nvidia-gpu:
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Clearing Resource Reservations
|
#### Clearing Resource Reservations
|
||||||
@@ -238,12 +243,14 @@ dokku resource:report
|
|||||||
web limit network: 10
|
web limit network: 10
|
||||||
web limit network ingress:
|
web limit network ingress:
|
||||||
web limit network egress:
|
web limit network egress:
|
||||||
|
web limit nvidia gpu:
|
||||||
web reservation cpu:
|
web reservation cpu:
|
||||||
web reservation memory: 512
|
web reservation memory: 512
|
||||||
web reservation memory swap:
|
web reservation memory swap:
|
||||||
web reservation network: 8
|
web reservation network: 8
|
||||||
web reservation network ingress:
|
web reservation network ingress:
|
||||||
web reservation network egress:
|
web reservation network egress:
|
||||||
|
web reservation nvidia gpu:
|
||||||
=====> python-sample resource information
|
=====> python-sample resource information
|
||||||
web limit cpu:
|
web limit cpu:
|
||||||
web limit memory:
|
web limit memory:
|
||||||
@@ -251,12 +258,14 @@ dokku resource:report
|
|||||||
web limit network:
|
web limit network:
|
||||||
web limit network ingress:
|
web limit network ingress:
|
||||||
web limit network egress:
|
web limit network egress:
|
||||||
|
web limit nvidia gpu:
|
||||||
web reservation cpu:
|
web reservation cpu:
|
||||||
web reservation memory:
|
web reservation memory:
|
||||||
web reservation memory swap:
|
web reservation memory swap:
|
||||||
web reservation network:
|
web reservation network:
|
||||||
web reservation network ingress:
|
web reservation network ingress:
|
||||||
web reservation network egress:
|
web reservation network egress:
|
||||||
|
web reservation nvidia gpu:
|
||||||
=====> ruby-sample resource information
|
=====> ruby-sample resource information
|
||||||
web limit cpu:
|
web limit cpu:
|
||||||
web limit memory:
|
web limit memory:
|
||||||
@@ -264,12 +273,14 @@ dokku resource:report
|
|||||||
web limit network:
|
web limit network:
|
||||||
web limit network ingress:
|
web limit network ingress:
|
||||||
web limit network egress:
|
web limit network egress:
|
||||||
|
web limit nvidia gpu:
|
||||||
web reservation cpu:
|
web reservation cpu:
|
||||||
web reservation memory:
|
web reservation memory:
|
||||||
web reservation memory swap:
|
web reservation memory swap:
|
||||||
web reservation network:
|
web reservation network:
|
||||||
web reservation network ingress:
|
web reservation network ingress:
|
||||||
web reservation network egress:
|
web reservation network egress:
|
||||||
|
web reservation nvidia gpu:
|
||||||
```
|
```
|
||||||
|
|
||||||
You can run the command for a specific app also.
|
You can run the command for a specific app also.
|
||||||
@@ -286,12 +297,14 @@ dokku resource:report node-js-app
|
|||||||
web limit network: 10
|
web limit network: 10
|
||||||
web limit network ingress:
|
web limit network ingress:
|
||||||
web limit network egress:
|
web limit network egress:
|
||||||
|
web limit nvidia gpu:
|
||||||
web reservation cpu:
|
web reservation cpu:
|
||||||
web reservation memory: 512
|
web reservation memory: 512
|
||||||
web reservation memory swap:
|
web reservation memory swap:
|
||||||
web reservation network: 8
|
web reservation network: 8
|
||||||
web reservation network ingress:
|
web reservation network ingress:
|
||||||
web reservation network egress:
|
web reservation network egress:
|
||||||
|
web reservation nvidia gpu:
|
||||||
```
|
```
|
||||||
|
|
||||||
You can pass flags which will output only the value of the specific information you want. For example:
|
You can pass flags which will output only the value of the specific information you want. For example:
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ The `docker-local` scheduler supports a minimal list of resource _limits_ and _r
|
|||||||
- See the ["Memory" section](https://docs.docker.com/config/containers/resource_constraints/#memory) of the Docker Runtime Options documentation for more information.
|
- See the ["Memory" section](https://docs.docker.com/config/containers/resource_constraints/#memory) of the Docker Runtime Options documentation for more information.
|
||||||
- memory-swap: (docker option: `--memory-swap`) and should be specified with a suffix of `b` (bytes), `k` (kilobytes), `m` (megabytes), `g` (gigabytes)
|
- memory-swap: (docker option: `--memory-swap`) and should be specified with a suffix of `b` (bytes), `k` (kilobytes), `m` (megabytes), `g` (gigabytes)
|
||||||
- See the ["Memory" section](https://docs.docker.com/config/containers/resource_constraints/#memory) of the Docker Runtime Options documentation for more information.
|
- See the ["Memory" section](https://docs.docker.com/config/containers/resource_constraints/#memory) of the Docker Runtime Options documentation for more information.
|
||||||
|
- nvidia-gpus: (docker option: `--gpus`), is specified in number of Nvidia GPUs a process can access.
|
||||||
|
- See the ["GPU" section](https://docs.docker.com/config/containers/resource_constraints/#gpu) of the Docker Runtime Options documentation for more information.
|
||||||
|
|
||||||
### Resource Reservations
|
### Resource Reservations
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ type Resource struct {
|
|||||||
Network string `json:"network"`
|
Network string `json:"network"`
|
||||||
NetworkIngress string `json:"network-ingress"`
|
NetworkIngress string `json:"network-ingress"`
|
||||||
NetworkEgress string `json:"network-egress"`
|
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
|
// 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")
|
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")
|
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")
|
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:])
|
args.Parse(os.Args[2:])
|
||||||
|
|
||||||
resources := resource.Resource{
|
resources := resource.Resource{
|
||||||
@@ -35,6 +36,7 @@ func main() {
|
|||||||
Network: *network,
|
Network: *network,
|
||||||
NetworkIngress: *networkIngress,
|
NetworkIngress: *networkIngress,
|
||||||
NetworkEgress: *networkEgress,
|
NetworkEgress: *networkEgress,
|
||||||
|
NvidiaGPU: *nvidiaGpu,
|
||||||
}
|
}
|
||||||
|
|
||||||
err = resource.CommandLimit(args.Args(), *processType, resources)
|
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")
|
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")
|
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")
|
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:])
|
args.Parse(os.Args[2:])
|
||||||
|
|
||||||
resources := resource.Resource{
|
resources := resource.Resource{
|
||||||
@@ -66,6 +69,7 @@ func main() {
|
|||||||
Network: *network,
|
Network: *network,
|
||||||
NetworkIngress: *networkIngress,
|
NetworkIngress: *networkIngress,
|
||||||
NetworkEgress: *networkEgress,
|
NetworkEgress: *networkEgress,
|
||||||
|
NvidiaGPU: *nvidiaGpu,
|
||||||
}
|
}
|
||||||
|
|
||||||
err = resource.CommandReserve(args.Args(), *processType, resources)
|
err = resource.CommandReserve(args.Args(), *processType, resources)
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ func clearByResourceType(appName string, processType string, resourceType string
|
|||||||
"network",
|
"network",
|
||||||
"network-ingress",
|
"network-ingress",
|
||||||
"network-egress",
|
"network-egress",
|
||||||
|
"nvidia-gpu",
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, key := range resources {
|
for _, key := range resources {
|
||||||
@@ -121,6 +122,7 @@ func setResourceType(appName string, processType string, r Resource, resourceTyp
|
|||||||
"network": r.Network,
|
"network": r.Network,
|
||||||
"network-ingress": r.NetworkIngress,
|
"network-ingress": r.NetworkIngress,
|
||||||
"network-egress": r.NetworkEgress,
|
"network-egress": r.NetworkEgress,
|
||||||
|
"nvidia-gpu": r.NvidiaGPU,
|
||||||
}
|
}
|
||||||
|
|
||||||
hasValues := false
|
hasValues := false
|
||||||
@@ -182,6 +184,7 @@ func reportResourceType(appName string, processType string, resourceType string)
|
|||||||
"network",
|
"network",
|
||||||
"network-ingress",
|
"network-ingress",
|
||||||
"network-egress",
|
"network-egress",
|
||||||
|
"nvidia-gpu",
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, key := range resources {
|
for _, key := range resources {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ func TriggerDockerArgsProcessDeploy(appName string, processType string) error {
|
|||||||
|
|
||||||
validLimits := map[string]bool{
|
validLimits := map[string]bool{
|
||||||
"cpu": true,
|
"cpu": true,
|
||||||
|
"nvidia-gpu": true,
|
||||||
"memory": true,
|
"memory": true,
|
||||||
"memory-swap": true,
|
"memory-swap": true,
|
||||||
}
|
}
|
||||||
@@ -54,6 +55,10 @@ func TriggerDockerArgsProcessDeploy(appName string, processType string) error {
|
|||||||
parts[1] = "cpus"
|
parts[1] = "cpus"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if parts[1] == "nvidia-gpu" {
|
||||||
|
parts[1] = "gpus"
|
||||||
|
}
|
||||||
|
|
||||||
limits[parts[1]] = value
|
limits[parts[1]] = value
|
||||||
}
|
}
|
||||||
if parts[0] == "reserve" {
|
if parts[0] == "reserve" {
|
||||||
|
|||||||
@@ -141,10 +141,6 @@ teardown() {
|
|||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_output "536870912"
|
assert_output "536870912"
|
||||||
# run /bin/bash -c "docker inspect --format '{{.HostConfig.NanoCpus}}' $CID"
|
|
||||||
# echo "output: $output"
|
|
||||||
# echo "status: $status"
|
|
||||||
# assert_output "500000000"
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku resource:reserve-clear --process-type worker $TEST_APP"
|
run /bin/bash -c "dokku resource:reserve-clear --process-type worker $TEST_APP"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
|
|||||||
Reference in New Issue
Block a user