gonvml

package module
v0.0.0-...-ac0b664 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2021 License: Apache-2.0 Imports: 4 Imported by: 71

README

Go Bindings for NVML

NVML or NVIDIA Management Library is a C-based API that can be used for monitoring NVIDIA GPU devices. It's closed source but can be downloaded as part of the GPU Deployment Kit.

The NVML API Reference describe various methods that are available as part of NVML.

The nvml.h file is included in this repository so that we don't depend on the presence of NVML in the build environment.

The bindings.go file is the cgo bridge which calls the NVML functions. The cgo preamble in bindings.go uses dlopen to dynamically load NVML and makes its functions available.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeviceCount

func DeviceCount() (uint, error)

DeviceCount returns the number of nvidia devices on the system.

func Initialize

func Initialize() error

Initialize initializes NVML. Call this before calling any other methods.

func Shutdown

func Shutdown() error

Shutdown shuts down NVML. Call this once NVML is no longer being used.

func SystemDriverVersion

func SystemDriverVersion() (string, error)

SystemDriverVersion returns the the driver version on the system.

Types

type Device

type Device struct {
	// contains filtered or unexported fields
}

Device is the handle for the device. This handle is obtained by calling DeviceHandleByIndex().

func DeviceHandleByIndex

func DeviceHandleByIndex(idx uint) (Device, error)

DeviceHandleByIndex returns the device handle for a particular index. The indices range from 0 to DeviceCount()-1. The order in which NVML enumerates devices has no guarantees of consistency between reboots.

func (Device) AverageGPUUtilization

func (d Device) AverageGPUUtilization(since time.Duration) (uint, error)

AverageGPUUtilization returns the utilization.gpu metric (percent of time one of more kernels were executing on the GPU) averaged over the samples collected in the last `since` duration.

func (Device) AveragePowerUsage

func (d Device) AveragePowerUsage(since time.Duration) (uint, error)

AveragePowerUsage returns the power usage for this GPU and its associated circuitry in milliwatts averaged over the samples collected in the last `since` duration.

func (Device) DecoderUtilization

func (d Device) DecoderUtilization() (uint, uint, error)

DecoderUtilization returns the percent of time over the last sample period during which the GPU video decoder was being used. The sampling period is variable and is returned in the second return argument in microseconds.

func (Device) EncoderUtilization

func (d Device) EncoderUtilization() (uint, uint, error)

EncoderUtilization returns the percent of time over the last sample period during which the GPU video encoder was being used. The sampling period is variable and is returned in the second return argument in microseconds.

func (Device) FanSpeed

func (d Device) FanSpeed() (uint, error)

FanSpeed returns the temperature for this GPU in the percentage of its full speed, with 100 being the maximum.

func (Device) MemoryInfo

func (d Device) MemoryInfo() (uint64, uint64, error)

MemoryInfo returns the total and used memory (in bytes) of the device.

func (Device) MinorNumber

func (d Device) MinorNumber() (uint, error)

MinorNumber returns the minor number for the device. The minor number for the device is such that the Nvidia device node file for each GPU will have the form /dev/nvidia[minor number].

func (Device) Name

func (d Device) Name() (string, error)

Name returns the product name of the device.

func (Device) PowerUsage

func (d Device) PowerUsage() (uint, error)

PowerUsage returns the power usage for this GPU and its associated circuitry in milliwatts. The reading is accurate to within +/- 5% of current power draw.

func (Device) Temperature

func (d Device) Temperature() (uint, error)

Temperature returns the temperature for this GPU in Celsius.

func (Device) UUID

func (d Device) UUID() (string, error)

UUID returns the globally unique immutable UUID associated with this device.

func (Device) UtilizationRates

func (d Device) UtilizationRates() (uint, uint, error)

UtilizationRates returns the percent of time over the past sample period during which: utilization.gpu: one or more kernels were executing on the GPU. utilization.memory: global (device) memory was being read or written.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL