Files
moby/daemon/devices_linux.go
T
Paweł Gronowski 13a8626eeb daemon/devices: Turn RegisterGPUDeviceDrivers into func
Change GPU device driver registration from init-time function assignment
to direct function exports.

This removes the init() function and global function variable pattern in
favor of a more explicit approach.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2026-03-04 18:22:18 +01:00

23 lines
770 B
Go

package daemon
import "tags.cncf.io/container-device-interface/pkg/cdi"
// RegisterGPUDeviceDrivers registers GPU device drivers.
// If the cdiCache is provided, it is used to detect presence of CDI specs for AMD GPUs.
// For NVIDIA GPUs, presence of CDI specs is detected by checking for the nvidia-cdi-hook binary.
func RegisterGPUDeviceDrivers(cdiCache *cdi.Cache) {
// Register NVIDIA device drivers.
if nvidiaDrivers := getNVIDIADeviceDrivers(); len(nvidiaDrivers) > 0 {
for name, driver := range nvidiaDrivers {
registerDeviceDriver(name, driver)
}
return
}
// Register AMD driver if AMD CDI spec or helper binary is present.
if amdDriver := getAMDDeviceDrivers(cdiCache); amdDriver != nil {
registerDeviceDriver("amd", amdDriver)
return
}
}