Skip to content

Commit

Permalink
POD-819: Add --gpus=all if host requirments contain GPU (#1229)
Browse files Browse the repository at this point in the history
* POD-819: Add --gpus=all if host requirments contain GPU

* POD-819: Add nill check
  • Loading branch information
bkneis authored Aug 21, 2024
1 parent ad5e942 commit b48f066
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/driver/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"os"
"runtime"
"slices"
"strconv"
"strings"

Expand Down Expand Up @@ -325,6 +326,17 @@ func (d *dockerDriver) RunDockerDevContainer(
}

// runArgs
// check if we need to add --gpus=all to the run args based on the dev container's host requirments
if parsedConfig.HostRequirements != nil {
usesGpu, err := parsedConfig.HostRequirements.GPU.Bool()
if err != nil && usesGpu {
// check if the user manually add --gpus=all, if not then add it
if !slices.Contains(parsedConfig.RunArgs, "--gpus=all") {
args = append(args, "--gpus=all")
}
}
}

args = append(args, parsedConfig.RunArgs...)

// run detached
Expand Down

0 comments on commit b48f066

Please sign in to comment.