Bump gonvml module and remove CGO dependency.
Signed-off-by: Carlos de Paula <me@carlosedp.com>
This commit is contained in:
7
vendor/github.com/mindprince/gonvml/.travis.gofmt.sh
generated
vendored
Normal file
7
vendor/github.com/mindprince/gonvml/.travis.gofmt.sh
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -n "$(gofmt -s -l .)" ]; then
|
||||
echo "Go code is not properly formatted:"
|
||||
gofmt -s -d -e .
|
||||
exit 1
|
||||
fi
|
9
vendor/github.com/mindprince/gonvml/.travis.yml
generated
vendored
Normal file
9
vendor/github.com/mindprince/gonvml/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
language: go
|
||||
|
||||
go:
|
||||
- "1.8"
|
||||
- "1.9"
|
||||
- "1.10"
|
||||
|
||||
script:
|
||||
- make presubmit
|
1
vendor/github.com/mindprince/gonvml/BUILD
generated
vendored
1
vendor/github.com/mindprince/gonvml/BUILD
generated
vendored
@@ -4,6 +4,7 @@ go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"bindings.go",
|
||||
"bindings_nocgo.go",
|
||||
"nvml.h",
|
||||
],
|
||||
cgo = True,
|
||||
|
3
vendor/github.com/mindprince/gonvml/Makefile
generated
vendored
3
vendor/github.com/mindprince/gonvml/Makefile
generated
vendored
@@ -18,3 +18,6 @@ PKG=github.com/mindprince/gonvml
|
||||
build:
|
||||
docker run -v $(shell pwd):/go/src/$(PKG) --workdir=/go/src/$(PKG) golang:1.8 go build cmd/example/example.go
|
||||
|
||||
.PHONY: presubmit
|
||||
presubmit:
|
||||
./.travis.gofmt.sh
|
||||
|
95
vendor/github.com/mindprince/gonvml/bindings.go
generated
vendored
95
vendor/github.com/mindprince/gonvml/bindings.go
generated
vendored
@@ -111,6 +111,38 @@ nvmlReturn_t nvmlDeviceGetPowerUsage(nvmlDevice_t device, unsigned int *power) {
|
||||
return nvmlDeviceGetPowerUsageFunc(device, power);
|
||||
}
|
||||
|
||||
nvmlReturn_t (*nvmlDeviceGetTemperatureFunc)(nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, unsigned int *temp);
|
||||
nvmlReturn_t nvmlDeviceGetTemperature(nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, unsigned int *temp) {
|
||||
if (nvmlDeviceGetTemperatureFunc == NULL) {
|
||||
return NVML_ERROR_FUNCTION_NOT_FOUND;
|
||||
}
|
||||
return nvmlDeviceGetTemperatureFunc(device, sensorType, temp);
|
||||
}
|
||||
|
||||
nvmlReturn_t (*nvmlDeviceGetFanSpeedFunc)(nvmlDevice_t device, unsigned int *speed);
|
||||
nvmlReturn_t nvmlDeviceGetFanSpeed(nvmlDevice_t device, unsigned int *speed) {
|
||||
if (nvmlDeviceGetFanSpeedFunc == NULL) {
|
||||
return NVML_ERROR_FUNCTION_NOT_FOUND;
|
||||
}
|
||||
return nvmlDeviceGetFanSpeedFunc(device, speed);
|
||||
}
|
||||
|
||||
nvmlReturn_t (*nvmlDeviceGetEncoderUtilizationFunc)(nvmlDevice_t device, unsigned int* utilization, unsigned int* samplingPeriodUs);
|
||||
nvmlReturn_t nvmlDeviceGetEncoderUtilization(nvmlDevice_t device, unsigned int* utilization, unsigned int* samplingPeriodUs) {
|
||||
if (nvmlDeviceGetEncoderUtilizationFunc == NULL) {
|
||||
return NVML_ERROR_FUNCTION_NOT_FOUND;
|
||||
}
|
||||
return nvmlDeviceGetEncoderUtilizationFunc(device, utilization, samplingPeriodUs);
|
||||
}
|
||||
|
||||
nvmlReturn_t (*nvmlDeviceGetDecoderUtilizationFunc)(nvmlDevice_t device, unsigned int* utilization, unsigned int* samplingPeriodUs);
|
||||
nvmlReturn_t nvmlDeviceGetDecoderUtilization(nvmlDevice_t device, unsigned int* utilization, unsigned int* samplingPeriodUs) {
|
||||
if (nvmlDeviceGetDecoderUtilizationFunc == NULL) {
|
||||
return NVML_ERROR_FUNCTION_NOT_FOUND;
|
||||
}
|
||||
return nvmlDeviceGetDecoderUtilizationFunc(device, utilization, samplingPeriodUs);
|
||||
}
|
||||
|
||||
nvmlReturn_t (*nvmlDeviceGetSamplesFunc)(nvmlDevice_t device, nvmlSamplingType_t type, unsigned long long lastSeenTimeStamp, nvmlValueType_t *sampleValType, unsigned int *sampleCount, nvmlSample_t *samples);
|
||||
|
||||
// Loads the "libnvidia-ml.so.1" shared library.
|
||||
@@ -169,10 +201,26 @@ nvmlReturn_t nvmlInit_dl(void) {
|
||||
if (nvmlDeviceGetPowerUsageFunc == NULL) {
|
||||
return NVML_ERROR_FUNCTION_NOT_FOUND;
|
||||
}
|
||||
nvmlDeviceGetTemperatureFunc = dlsym(nvmlHandle, "nvmlDeviceGetTemperature");
|
||||
if (nvmlDeviceGetTemperatureFunc == NULL) {
|
||||
return NVML_ERROR_FUNCTION_NOT_FOUND;
|
||||
}
|
||||
nvmlDeviceGetFanSpeedFunc = dlsym(nvmlHandle, "nvmlDeviceGetFanSpeed");
|
||||
if (nvmlDeviceGetFanSpeedFunc == NULL) {
|
||||
return NVML_ERROR_FUNCTION_NOT_FOUND;
|
||||
}
|
||||
nvmlDeviceGetSamplesFunc = dlsym(nvmlHandle, "nvmlDeviceGetSamples");
|
||||
if (nvmlDeviceGetSamplesFunc == NULL) {
|
||||
return NVML_ERROR_FUNCTION_NOT_FOUND;
|
||||
}
|
||||
nvmlDeviceGetEncoderUtilizationFunc = dlsym(nvmlHandle, "nvmlDeviceGetEncoderUtilization");
|
||||
if (nvmlDeviceGetEncoderUtilizationFunc == NULL) {
|
||||
return NVML_ERROR_FUNCTION_NOT_FOUND;
|
||||
}
|
||||
nvmlDeviceGetDecoderUtilizationFunc = dlsym(nvmlHandle, "nvmlDeviceGetDecoderUtilization");
|
||||
if (nvmlDeviceGetDecoderUtilizationFunc == NULL) {
|
||||
return NVML_ERROR_FUNCTION_NOT_FOUND;
|
||||
}
|
||||
nvmlReturn_t result = nvmlInitFunc();
|
||||
if (result != NVML_SUCCESS) {
|
||||
dlclose(nvmlHandle);
|
||||
@@ -384,7 +432,7 @@ func (d Device) MemoryInfo() (uint64, uint64, 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.
|
||||
// utilizatoin.memory: global (device) memory was being read or written.
|
||||
// utilization.memory: global (device) memory was being read or written.
|
||||
func (d Device) UtilizationRates() (uint, uint, error) {
|
||||
if C.nvmlHandle == nil {
|
||||
return 0, 0, errLibraryNotLoaded
|
||||
@@ -429,3 +477,48 @@ func (d Device) AverageGPUUtilization(since time.Duration) (uint, error) {
|
||||
r := C.nvmlDeviceGetAverageUsage(d.dev, C.NVML_GPU_UTILIZATION_SAMPLES, lastTs, &n)
|
||||
return uint(n), errorString(r)
|
||||
}
|
||||
|
||||
// Temperature returns the temperature for this GPU in Celsius.
|
||||
func (d Device) Temperature() (uint, error) {
|
||||
if C.nvmlHandle == nil {
|
||||
return 0, errLibraryNotLoaded
|
||||
}
|
||||
var n C.uint
|
||||
r := C.nvmlDeviceGetTemperature(d.dev, C.NVML_TEMPERATURE_GPU, &n)
|
||||
return uint(n), errorString(r)
|
||||
}
|
||||
|
||||
// FanSpeed returns the temperature for this GPU in the percentage of its full
|
||||
// speed, with 100 being the maximum.
|
||||
func (d Device) FanSpeed() (uint, error) {
|
||||
if C.nvmlHandle == nil {
|
||||
return 0, errLibraryNotLoaded
|
||||
}
|
||||
var n C.uint
|
||||
r := C.nvmlDeviceGetFanSpeed(d.dev, &n)
|
||||
return uint(n), errorString(r)
|
||||
}
|
||||
|
||||
// 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 (d Device) EncoderUtilization() (uint, uint, error) {
|
||||
if C.nvmlHandle == nil {
|
||||
return 0, 0, errLibraryNotLoaded
|
||||
}
|
||||
var n C.uint
|
||||
var sp C.uint
|
||||
r := C.nvmlDeviceGetEncoderUtilization(d.dev, &n, &sp)
|
||||
return uint(n), uint(sp), errorString(r)
|
||||
}
|
||||
|
||||
// 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 (d Device) DecoderUtilization() (uint, uint, error) {
|
||||
if C.nvmlHandle == nil {
|
||||
return 0, 0, errLibraryNotLoaded
|
||||
}
|
||||
var n C.uint
|
||||
var sp C.uint
|
||||
r := C.nvmlDeviceGetDecoderUtilization(d.dev, &n, &sp)
|
||||
return uint(n), uint(sp), errorString(r)
|
||||
}
|
||||
|
115
vendor/github.com/mindprince/gonvml/bindings_nocgo.go
generated
vendored
Normal file
115
vendor/github.com/mindprince/gonvml/bindings_nocgo.go
generated
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
// +build !cgo
|
||||
|
||||
package gonvml
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
var errNoCgo = errors.New("this binary is built without CGO, NVML is disabled")
|
||||
|
||||
// Initialize initializes NVML.
|
||||
// Call this before calling any other methods.
|
||||
func Initialize() error {
|
||||
return errNoCgo
|
||||
}
|
||||
|
||||
// Shutdown shuts down NVML.
|
||||
// Call this once NVML is no longer being used.
|
||||
func Shutdown() error {
|
||||
return errNoCgo
|
||||
}
|
||||
|
||||
// SystemDriverVersion returns the the driver version on the system.
|
||||
func SystemDriverVersion() (string, error) {
|
||||
return "", errNoCgo
|
||||
}
|
||||
|
||||
// DeviceCount returns the number of nvidia devices on the system.
|
||||
func DeviceCount() (uint, error) {
|
||||
return 0, errNoCgo
|
||||
}
|
||||
|
||||
// Device is the handle for the device.
|
||||
// This handle is obtained by calling DeviceHandleByIndex().
|
||||
type Device struct {
|
||||
}
|
||||
|
||||
// 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 DeviceHandleByIndex(idx uint) (Device, error) {
|
||||
return Device{}, errNoCgo
|
||||
}
|
||||
|
||||
// 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 (d Device) MinorNumber() (uint, error) {
|
||||
return 0, errNoCgo
|
||||
}
|
||||
|
||||
// UUID returns the globally unique immutable UUID associated with this device.
|
||||
func (d Device) UUID() (string, error) {
|
||||
return "", errNoCgo
|
||||
}
|
||||
|
||||
// Name returns the product name of the device.
|
||||
func (d Device) Name() (string, error) {
|
||||
return "", errNoCgo
|
||||
}
|
||||
|
||||
// MemoryInfo returns the total and used memory (in bytes) of the device.
|
||||
func (d Device) MemoryInfo() (uint64, uint64, error) {
|
||||
return 0, 0, errNoCgo
|
||||
}
|
||||
|
||||
// UtilizationRates returns the percent of time over the past sample period during which:
|
||||
// utilization.gpu: one or more kernels were executing on the GPU.
|
||||
// utilizatoin.memory: global (device) memory was being read or written.
|
||||
func (d Device) UtilizationRates() (uint, uint, error) {
|
||||
return 0, 0, errNoCgo
|
||||
}
|
||||
|
||||
// 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 (d Device) PowerUsage() (uint, error) {
|
||||
return 0, errNoCgo
|
||||
}
|
||||
|
||||
// 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 (d Device) AveragePowerUsage(since time.Duration) (uint, error) {
|
||||
return 0, errNoCgo
|
||||
}
|
||||
|
||||
// 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 (d Device) AverageGPUUtilization(since time.Duration) (uint, error) {
|
||||
return 0, errNoCgo
|
||||
}
|
||||
|
||||
// Temperature returns the temperature for this GPU in Celsius.
|
||||
func (d Device) Temperature() (uint, error) {
|
||||
return 0, errNoCgo
|
||||
}
|
||||
|
||||
// FanSpeed returns the temperature for this GPU in the percentage of its full
|
||||
// speed, with 100 being the maximum.
|
||||
func (d Device) FanSpeed() (uint, error) {
|
||||
return 0, errNoCgo
|
||||
}
|
||||
|
||||
// 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 (d Device) EncoderUtilization() (uint, uint, error) {
|
||||
return 0, 0, errNoCgo
|
||||
}
|
||||
|
||||
// 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 (d Device) DecoderUtilization() (uint, uint, error) {
|
||||
return 0, 0, errNoCgo
|
||||
}
|
Reference in New Issue
Block a user