github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/devices/gpu/nvidia/nvml/shared.go (about)

     1  package nvml
     2  
     3  import "errors"
     4  
     5  var (
     6  	// UnavailableLib is returned when the nvml library could not be loaded.
     7  	UnavailableLib = errors.New("could not load NVML library")
     8  )
     9  
    10  // nvmlDriver implements NvmlDriver
    11  // Users are required to call Initialize method before using any other methods
    12  type nvmlDriver struct{}
    13  
    14  // NvmlDriver represents set of methods to query nvml library
    15  type NvmlDriver interface {
    16  	Initialize() error
    17  	Shutdown() error
    18  	SystemDriverVersion() (string, error)
    19  	DeviceCount() (uint, error)
    20  	DeviceInfoByIndex(uint) (*DeviceInfo, error)
    21  	DeviceInfoAndStatusByIndex(uint) (*DeviceInfo, *DeviceStatus, error)
    22  }
    23  
    24  // DeviceInfo represents nvml device data
    25  // this struct is returned by NvmlDriver DeviceInfoByIndex and
    26  // DeviceInfoAndStatusByIndex methods
    27  type DeviceInfo struct {
    28  	// The following fields are guaranteed to be retrieved from nvml
    29  	UUID            string
    30  	PCIBusID        string
    31  	DisplayState    string
    32  	PersistenceMode string
    33  
    34  	// The following fields can be nil after call to nvml, because nvml was
    35  	// not able to retrieve this fields for specific nvidia card
    36  	Name               *string
    37  	MemoryMiB          *uint64
    38  	PowerW             *uint
    39  	BAR1MiB            *uint64
    40  	PCIBandwidthMBPerS *uint
    41  	CoresClockMHz      *uint
    42  	MemoryClockMHz     *uint
    43  }
    44  
    45  // DeviceStatus represents nvml device status
    46  // this struct is returned by NvmlDriver DeviceInfoAndStatusByIndex method
    47  type DeviceStatus struct {
    48  	// The following fields can be nil after call to nvml, because nvml was
    49  	// not able to retrieve this fields for specific nvidia card
    50  	PowerUsageW        *uint
    51  	TemperatureC       *uint
    52  	GPUUtilization     *uint // %
    53  	MemoryUtilization  *uint // %
    54  	EncoderUtilization *uint // %
    55  	DecoderUtilization *uint // %
    56  	BAR1UsedMiB        *uint64
    57  	UsedMemoryMiB      *uint64
    58  	ECCErrorsL1Cache   *uint64
    59  	ECCErrorsL2Cache   *uint64
    60  	ECCErrorsDevice    *uint64
    61  }