Skip to content
NVIDIAPublic

About

Golang bindings for Nvidia Datacenter GPU Manager (DCGM)

Resources

Contributing

Stars

161 stars

Watchers

6 watching

Forks

Latest commit

 

History

425 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-dcgm logo

go-dcgm

Go bindings for NVIDIA Data Center GPU Manager (DCGM).

API reference · Samples · DCGM user guide · Contribute

GitHub Actions build Codecov coverage Latest release Go Reference License: Apache-2.0 DCO


Overview

go-dcgm provides Go bindings for NVIDIA Data Center GPU Manager (DCGM). DCGM manages and monitors NVIDIA GPUs in cluster environments. DCGM Exporter uses these bindings to publish GPU telemetry to Prometheus.

This repository contains the pkg/dcgm package, sample programs, and the field-constant generator.

Requirements

  • Linux with an NVIDIA GPU and driver supported by DCGM. See the DCGM support matrix.
  • DCGM 4 installed on the host. The bindings load libdcgm.so.4 at runtime.
  • cgo enabled when building.

Connection strings in standalone mode require DCGM 4.5.0 or later.

Usage

go get github.com/NVIDIA/go-dcgm
cleanup, err := dcgm.Init(dcgm.Embedded)
if err != nil {
    log.Fatal(err)
}
defer cleanup()

gpus, err := dcgm.GetSupportedDevices()
if err != nil {
    log.Fatal(err)
}

for _, gpu := range gpus {
    info, err := dcgm.GetDeviceInfo(gpu)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("GPU %d: %s (%s)\n", gpu, info.Identifiers.Model, info.UUID)
}

dcgm.Init supports three modes:

  • Embedded runs the DCGM host engine inside your process.
  • Standalone connects to a running nv-hostengine over TCP or a Unix socket.
  • StartHostengine starts nv-hostengine as a child process and stops it on cleanup.

See the samples for complete programs, including device information, health checks, policies, diagnostics, and a REST API.

Diagnostics

RunDiag returns hierarchical DiagResults. New code should use results.Tests; each test includes its status, per-entity results, errors, information, and extra data. DiagResults.Software and DiagResult remain available as a deprecated compatibility view. See the diagnostic sample.

Development

The repository uses Task for common commands and Bazel for Go and cgo builds. See CONTRIBUTING.md for the pinned tool versions, or open the repository in a Dev Containers compatible editor to use the same environment as CI.

These checks do not need a GPU:

task build
task test
task validate

These need a GPU host with DCGM installed:

task test:integration
task test:race

After updating pkg/dcgm/dcgm_fields.h, regenerate the field constants with task generate and confirm them with task generate:check. See Updating DCGM Fields for the full process.

Contributing and support

Read CONTRIBUTING.md before submitting a change. For community support, open an issue.

Report potential security vulnerabilities through the NVIDIA Product Security process, not through a public issue.

License

go-dcgm is licensed under the Apache License, Version 2.0.

About

Golang bindings for Nvidia Datacenter GPU Manager (DCGM)

Resources

Contributing

Stars

161 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages