Update go-nvml dependency

This updates go-nvml to include fixes for getting devices by UUID
and to remove the panic from calls to Init and Shutdown.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar
2022-09-01 14:06:25 +02:00
parent 9175bde20b
commit da71bc2bff
5 changed files with 9 additions and 17 deletions

View File

@@ -38,21 +38,21 @@ func DeviceGetHandleByIndex(Index int) (Device, Return) {
// nvml.DeviceGetHandleBySerial()
func DeviceGetHandleBySerial(Serial string) (Device, Return) {
var Device Device
ret := nvmlDeviceGetHandleBySerial(Serial, &Device)
ret := nvmlDeviceGetHandleBySerial(Serial + string(rune(0)), &Device)
return Device, ret
}
// nvml.DeviceGetHandleByUUID()
func DeviceGetHandleByUUID(Uuid string) (Device, Return) {
var Device Device
ret := nvmlDeviceGetHandleByUUID(Uuid, &Device)
ret := nvmlDeviceGetHandleByUUID(Uuid + string(rune(0)), &Device)
return Device, ret
}
// nvml.DeviceGetHandleByPciBusId()
func DeviceGetHandleByPciBusId(PciBusId string) (Device, Return) {
var Device Device
ret := nvmlDeviceGetHandleByPciBusId(PciBusId, &Device)
ret := nvmlDeviceGetHandleByPciBusId(PciBusId + string(rune(0)), &Device)
return Device, ret
}

View File

@@ -32,13 +32,9 @@ var nvml *dl.DynamicLibrary
// nvml.Init()
func Init() Return {
lib := dl.New(nvmlLibraryName, nvmlLibraryLoadFlags)
if lib == nil {
panic(fmt.Sprintf("error instantiating DynamicLibrary for %s", nvmlLibraryName))
}
err := lib.Open()
if err != nil {
panic(fmt.Sprintf("error opening %s: %v", nvmlLibraryName, err))
return ERROR_LIBRARY_NOT_FOUND
}
nvml = lib
@@ -50,13 +46,9 @@ func Init() Return {
// nvml.InitWithFlags()
func InitWithFlags(Flags uint32) Return {
lib := dl.New(nvmlLibraryName, nvmlLibraryLoadFlags)
if lib == nil {
panic(fmt.Sprintf("error instantiating DynamicLibrary for %s", nvmlLibraryName))
}
err := lib.Open()
if err != nil {
panic(fmt.Sprintf("error opening %s: %v", nvmlLibraryName, err))
return ERROR_LIBRARY_NOT_FOUND
}
nvml = lib