Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GPU support for podman #21

Merged
merged 3 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .obs/workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ rebuild:
- trigger_services:
project: home:pjbgf:devel:languages:go:unstable
package: qubesome
- rebuild_package:
project: home:pjbgf:devel:languages:go:unstable
package: qubesome
filters:
event: push
branches:
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,5 @@ require (
golang.org/x/net v0.31.0 // indirect
golang.org/x/text v0.20.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/grpc/security/advancedtls v1.0.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
)
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0=
google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA=
google.golang.org/grpc/security/advancedtls v1.0.0 h1:/KQ7VP/1bs53/aopk9QhuPyFAp9Dm9Ejix3lzYkCrDA=
google.golang.org/grpc/security/advancedtls v1.0.0/go.mod h1:o+s4go+e1PJ2AjuQMY5hU82W7lDlefjJA6FqEHRVHWk=
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
19 changes: 11 additions & 8 deletions internal/profiles/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import (
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
"github.com/google/uuid"
"github.com/qubesome/cli/internal/command"
"github.com/qubesome/cli/internal/drive"
"github.com/qubesome/cli/internal/env"
"github.com/qubesome/cli/internal/files"
"github.com/qubesome/cli/internal/images"
"github.com/qubesome/cli/internal/runners/util/container"
"github.com/qubesome/cli/internal/types"
"github.com/qubesome/cli/internal/util/dbus"
"github.com/qubesome/cli/internal/util/drive"
"github.com/qubesome/cli/internal/util/env"
"github.com/qubesome/cli/internal/util/gpu"
"github.com/qubesome/cli/internal/util/mtls"
"github.com/qubesome/cli/internal/util/resolution"
Expand Down Expand Up @@ -168,10 +168,6 @@ func StartFromGit(runner, name, gitURL, path, local string) error {
return fmt.Errorf("cannot file profile %q in config %q", name, cfgPath)
}

if p.Runner != "" {
runner = p.Runner
}

// When sourcing from git, ensure profile path is relative to the git repository.
pp, err := securejoin.SecureJoin(filepath.Dir(cfgPath), p.Path)
if err != nil {
Expand All @@ -198,6 +194,12 @@ func Start(runner string, profile *types.Profile, cfg *types.Config) (err error)
return err
}

// If runner is not being overwritten (via -runner), use the runner
// set at profile level in the config.
if runner == "" && profile.Runner != "" {
runner = profile.Runner
}

binary := files.ContainerRunnerBinary(runner)
fi, err := os.Lstat(binary)
if err != nil || !fi.Mode().IsRegular() {
Expand Down Expand Up @@ -502,9 +504,10 @@ func createNewDisplay(bin string, ca, cert, key []byte, profile *types.Profile,
}
if profile.HostAccess.Gpus != "" {
if strings.HasSuffix(bin, "podman") {
dockerArgs = append(dockerArgs, "--runtime=nvidia.com/gpu=all")
dockerArgs = append(dockerArgs, "--device=nvidia.com/gpu=all")
} else {
dockerArgs = append(dockerArgs, "--gpus", profile.HostAccess.Gpus)
}
dockerArgs = append(dockerArgs, "--gpus", profile.HostAccess.Gpus)
}

if profile.DNS != "" {
Expand Down
4 changes: 2 additions & 2 deletions internal/qubesome/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (

securejoin "github.com/cyphar/filepath-securejoin"
"github.com/qubesome/cli/internal/command"
"github.com/qubesome/cli/internal/drive"
"github.com/qubesome/cli/internal/env"
"github.com/qubesome/cli/internal/files"
"github.com/qubesome/cli/internal/images"
"github.com/qubesome/cli/internal/inception"
Expand All @@ -22,6 +20,8 @@ import (
"github.com/qubesome/cli/internal/runners/podman"
"github.com/qubesome/cli/internal/types"
"github.com/qubesome/cli/internal/util/dbus"
"github.com/qubesome/cli/internal/util/drive"
"github.com/qubesome/cli/internal/util/env"
"gopkg.in/yaml.v3"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/runners/docker/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
"strconv"
"strings"

"github.com/qubesome/cli/internal/env"
"github.com/qubesome/cli/internal/files"
"github.com/qubesome/cli/internal/runners/util/container"
"github.com/qubesome/cli/internal/runners/util/mime"
"github.com/qubesome/cli/internal/runners/util/usb"
"github.com/qubesome/cli/internal/types"
"github.com/qubesome/cli/internal/util/dbus"
"github.com/qubesome/cli/internal/util/env"
"github.com/qubesome/cli/internal/util/gpu"
"golang.org/x/sys/execabs"
)
Expand Down
4 changes: 2 additions & 2 deletions internal/runners/podman/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
"strconv"
"strings"

"github.com/qubesome/cli/internal/env"
"github.com/qubesome/cli/internal/files"
"github.com/qubesome/cli/internal/runners/util/container"
"github.com/qubesome/cli/internal/runners/util/mime"
"github.com/qubesome/cli/internal/runners/util/usb"
"github.com/qubesome/cli/internal/types"
"github.com/qubesome/cli/internal/util/dbus"
"github.com/qubesome/cli/internal/util/env"
"github.com/qubesome/cli/internal/util/gpu"
"golang.org/x/sys/execabs"
)
Expand Down Expand Up @@ -82,7 +82,7 @@ func Run(ew types.EffectiveWorkload) error {
}

if wl.HostAccess.Gpus != "" {
args = append(args, "--gpus", wl.HostAccess.Gpus)
args = append(args, "--device=nvidia.com/gpu=all")
}

for _, cap := range wl.HostAccess.CapsAdd {
Expand Down
2 changes: 1 addition & 1 deletion internal/types/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"slices"
"strings"

"github.com/qubesome/cli/internal/env"
"github.com/qubesome/cli/internal/util/env"
)

type Workload struct {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.