Skip to content

Commit

Permalink
Device: Improvements to GPU CDI mode & Ubuntu Core validation (#14348)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomponline authored Oct 25, 2024
2 parents 41eac02 + 19f1c10 commit faa3772
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lxd/device/cdi/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ func generateNvidiaSpec(s *state.State, cdiID ID, inst instance.Instance) (*spec
//
rootPath = os.Getenv("SNAP") + "/gpu-2404-2"
devRootPath = "/"

// Let's ensure that user did:
// snap connect mesa-2404:kernel-gpu-2404 pc-kernel
if !shared.PathExists("/snap/lxd/current/gpu-2404-2/usr/bin/nvidia-smi") {
return nil, fmt.Errorf("Failed to find nvidia-smi tool. Please ensure that pc-kernel snap is connected to mesa-2404.")
}
} else if shared.InSnap() {
rootPath = "/var/lib/snapd/hostfs"
devRootPath = rootPath
Expand Down
8 changes: 8 additions & 0 deletions lxd/device/gpu_physical.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ func (d *gpuPhysical) validateConfig(instConf instance.ConfigReader) error {
return fmt.Errorf(`Cannot use %q when "id" is set`, field)
}
}

// If user requests CDI in conjunction with nvidia.runtime=true we should forbid that.
if shared.IsTrue(instConf.ExpandedConfig()["nvidia.runtime"]) {
_, err := cdi.ToCDI(d.config["id"])
if err == nil {
return fmt.Errorf("CDI mode is incompatible with nvidia.runtime=true")
}
}
}

return nil
Expand Down

0 comments on commit faa3772

Please sign in to comment.