Hi,
I have a linux device with below spec
Ubuntu version: 22.04
Graphical card: 61:00.0 3D controller: NVIDIA Corporation GA100 [A100 PCIe 40GB] (rev a1)
Nvidia Driver version: 550.54.14
CUDA Version: 12.4
Go version: go1.21.9 linux/amd64
I have a requirement to fetch Nvidia Gpu metrics. And I ran below sample go program which fetches Nvidia Gpu device count on above linux device
Sample go program
package main
import (
"fmt"
"log"
"github.com/NVIDIA/go-nvml/pkg/nvml"
)
func main() {
ret := nvml.Init()
if ret != nvml.SUCCESS {
log.Fatalf("Unable to initialize NVML: %v", nvml.ErrorString(ret))
}
defer func() {
ret := nvml.Shutdown()
if ret != nvml.SUCCESS {
log.Fatalf("Unable to shutdown NVML: %v", nvml.ErrorString(ret))
}
}()
count, ret := nvml.DeviceGetCount()
fmt.Println("count",count)
if ret != nvml.SUCCESS {
log.Fatalf("Unable to get device count: %v", nvml.ErrorString(ret))
}
for i := 0; i < count; i++ {
device, ret := nvml.DeviceGetHandleByIndex(i)
if ret != nvml.SUCCESS {
log.Fatalf("Unable to get device at index %d: %v", i, nvml.ErrorString(ret))
}
uuid, ret := device.GetUUID()
if ret != nvml.SUCCESS {
log.Fatalf("Unable to get uuid of device at index %d: %v", i, nvml.ErrorString(ret))
}
fmt.Printf("%v\n", uuid)
processInfos, ret := device.GetComputeRunningProcesses()
if ret != nvml.SUCCESS {
log.Fatalf("Unable to get process info for device at index %d: %v", i, nvml.ErrorString(ret))
}
fmt.Printf("Found %d processes on device %d\n", len(processInfos), i)
for pi, processInfo := range processInfos {
fmt.Printf("\t[%2d] ProcessInfo: %+v\n", pi, processInfo)
}
}
Below is the error I’m getting while running above sample code.
Error initializing NVML:ERROR_LIBRARY_NOT_FOUND
Can someone please suggest why nvml package is not getting initialized even nvml library is getting imported ??
Thanks