Skip to content

Commit bd9fe78

Browse files
authored
Detect nvidia inside WSL2 (#3221)
1 parent 28b5b10 commit bd9fe78

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

runner/internal/common/gpu.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ const (
1616
)
1717

1818
func GetGpuVendor() GpuVendor {
19+
// FIXME: There might be errors other than os.ErrNotExist that are ignored silently.
20+
// Propagate and log.
1921
if _, err := os.Stat("/dev/kfd"); !errors.Is(err, os.ErrNotExist) {
2022
return GpuVendorAmd
2123
}
@@ -28,5 +30,11 @@ func GetGpuVendor() GpuVendor {
2830
if _, err := os.Stat("/dev/tenstorrent"); !errors.Is(err, os.ErrNotExist) {
2931
return GpuVendorTenstorrent
3032
}
33+
if _, err := os.Stat("/dev/dxg"); !errors.Is(err, os.ErrNotExist) {
34+
// WSL2
35+
if _, err := os.Stat("/usr/lib/wsl/lib/nvidia-smi"); !errors.Is(err, os.ErrNotExist) {
36+
return GpuVendorNvidia
37+
}
38+
}
3139
return GpuVendorNone
3240
}

0 commit comments

Comments
 (0)