NVIDIA Management Library (NVML) Go bindings
Go
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
cmd
.gitignore
LICENSE
README.md
doc.go
lib.go
session.go

README.md

NVIDIA Management Library (NVML) Go Bindings

GoDoc

There are multiple NVML Go bindings lying around GitHub. But they either are unmaintained or require configuring compiler flags. This package uses cgo and aims to be usable without any configuration.

Currently very few functionalities are exported from the underlying C library because those are what I need. But if you want more features, please submit an issue and I'll be happy to implement.

Example

Following is an easy example that displays processes information on all devices.

package main

import (
    "fmt"

    "github.com/hotpxl/nvml"
)

func main() {
    s, err := nvml.NewSession()
    if err != nil {
        panic(err)
    }
    defer s.Close()

    devices, err := s.GetAllDevices()
    if err != nil {
        panic(err)
    }
    for _, d := range devices {
        p, err := d.Processes()
        if err != nil {
            panic(err)
        }
        fmt.Printf("%+v\n", p)
    }
}

A second example cmd/nvml-monitor monitors device information and uploads to etcd.