21 lines
489 B
Go
21 lines
489 B
Go
//go:build linux || windows
|
|
|
|
package gpu
|
|
|
|
import (
|
|
"log/slog"
|
|
"strings"
|
|
)
|
|
|
|
func cudaGetVisibleDevicesEnv(gpuInfo []GpuInfo) (string, string) {
|
|
ids := []string{}
|
|
for _, info := range gpuInfo {
|
|
if info.Library != "cuda" {
|
|
// TODO shouldn't happen if things are wired correctly...
|
|
slog.Debug("cudaGetVisibleDevicesEnv skipping over non-cuda device", "library", info.Library)
|
|
continue
|
|
}
|
|
ids = append(ids, info.ID)
|
|
}
|
|
return "CUDA_VISIBLE_DEVICES", strings.Join(ids, ",")
|
|
}
|