diff --git a/cmd/nvidia-ctk/cdi/generate/generate.go b/cmd/nvidia-ctk/cdi/generate/generate.go index 4aa448e6..72d9180a 100644 --- a/cmd/nvidia-ctk/cdi/generate/generate.go +++ b/cmd/nvidia-ctk/cdi/generate/generate.go @@ -241,7 +241,7 @@ func (m command) generateSpec() (*specs.Spec, error) { graphicsEdits, err := m.editsForGraphicsDevice(nil) if err != nil { - return nil, fmt.Errorf("failed to generated edits for graphics libraries") + return nil, fmt.Errorf("failed to generate edits for graphics libraries: %v", err) } libOptions := []string{ diff --git a/internal/discover/graphics.go b/internal/discover/graphics.go index a6659a3a..99b2a70b 100644 --- a/internal/discover/graphics.go +++ b/internal/discover/graphics.go @@ -109,6 +109,13 @@ func (d drmDevicesByPath) Hooks() ([]Hook, error) { if len(devices) == 0 { return nil, nil } + links, err := d.getSpecificLinkArgs(devices) + if err != nil { + return nil, fmt.Errorf("failed to determine specific links: %v", err) + } + if len(links) == 0 { + return nil, nil + } hookPath := nvidiaCTKDefaultFilePath targets, err := d.lookup.Locate(d.nvidiaCTKExecutablePath) @@ -123,10 +130,6 @@ func (d drmDevicesByPath) Hooks() ([]Hook, error) { d.logger.Debugf("Using NVIDIA Container Toolkit CLI path %v", hookPath) args := []string{hookPath, "hook", "create-symlinks"} - links, err := d.getSpecificLinkArgs(devices) - if err != nil { - return nil, fmt.Errorf("failed to determine specific links: %v", err) - } for _, l := range links { args = append(args, "--link", l) } @@ -150,7 +153,8 @@ func (d drmDevicesByPath) getSpecificLinkArgs(devices []Device) ([]string, error linkLocator := lookup.NewFileLocator(d.logger, d.root) candidates, err := linkLocator.Locate("/dev/dri/by-path/pci-*-*") if err != nil { - return nil, fmt.Errorf("failed to locate devices by path: %v", err) + d.logger.Warningf("Failed to locate by-path links: %v; ignoring", err) + return nil, nil } var links []string