View | Details | Raw Unified | Return to bug 59499
Collapse All | Expand All

(-)a/internal/lookup/root/root.go (+9 lines)
Lines 120-125 func (r *Driver) DriverLibraryLocator(additionalDirs ...string) (lookup.Locator, Link Here
120
	}
120
	}
121
121
122
	searchPaths := []string{libcudasoParentDirPath}
122
	searchPaths := []string{libcudasoParentDirPath}
123
	// Some distributions expose the driver libraries through an alternatives
124
	// directory that is listed in ld.so.cache but is not the directory that
125
	// contains libcuda.so. Add the resolved NVML directory to the search paths
126
	// used for versioned driver libraries as well.
127
	if nvmlPaths, err := r.Libraries().Locate("libnvidia-ml.so.1"); err == nil {
128
		for _, path := range nvmlPaths {
129
			searchPaths = append(searchPaths, r.RelativeToRoot(filepath.Dir(path)))
130
		}
131
	}
123
	for _, dir := range additionalDirs {
132
	for _, dir := range additionalDirs {
124
		if strings.HasPrefix(dir, "/") {
133
		if strings.HasPrefix(dir, "/") {
125
			searchPaths = append(searchPaths, dir)
134
			searchPaths = append(searchPaths, dir)
(-)a/internal/lookup/root/root_test.go (+32 lines)
Lines 17-22 Link Here
17
package root
17
package root
18
18
19
import (
19
import (
20
	"os"
20
	"path/filepath"
21
	"path/filepath"
21
	"testing"
22
	"testing"
22
23
Lines 79-81 func TestDriverLibrariesLocate(t *testing.T) { Link Here
79
		}
80
		}
80
	}
81
	}
81
}
82
}
83
84
func TestDriverLibraryLocatorIncludesNvmlDirectory(t *testing.T) {
85
	logger, _ := testlog.NewNullLogger()
86
	rootfs := t.TempDir()
87
88
	libcudaDir := filepath.Join(rootfs, "usr", "lib64")
89
	nvmlDir := filepath.Join(rootfs, "etc", "libnvidiacurrent")
90
	require.NoError(t, os.MkdirAll(libcudaDir, 0755))
91
	require.NoError(t, os.MkdirAll(nvmlDir, 0755))
92
93
	const version = "999.88.77"
94
	libcuda := filepath.Join(libcudaDir, "libcuda.so."+version)
95
	require.NoError(t, os.WriteFile(libcuda, nil, 0644))
96
97
	nvml := filepath.Join(nvmlDir, "libnvidia-ml.so."+version)
98
	require.NoError(t, os.WriteFile(nvml, nil, 0644))
99
	require.NoError(t, os.Symlink("libnvidia-ml.so."+version, filepath.Join(nvmlDir, "libnvidia-ml.so.1")))
100
101
	driver := New(
102
		WithLogger(logger),
103
		WithDriverRoot(rootfs),
104
		WithLibrarySearchPaths(libcudaDir, nvmlDir),
105
	)
106
107
	libraries, err := driver.DriverLibraryLocator()
108
	require.NoError(t, err)
109
110
	candidates, err := libraries.Locate("*.so." + version)
111
	require.NoError(t, err)
112
	require.ElementsMatch(t, []string{libcuda, nvml}, candidates)
113
}

Return to bug 59499