bindings_nocgo.go 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // +build !cgo
  2. package gonvml
  3. import (
  4. "errors"
  5. "time"
  6. )
  7. var errNoCgo = errors.New("this binary is built without CGO, NVML is disabled")
  8. // Initialize initializes NVML.
  9. // Call this before calling any other methods.
  10. func Initialize() error {
  11. return errNoCgo
  12. }
  13. // Shutdown shuts down NVML.
  14. // Call this once NVML is no longer being used.
  15. func Shutdown() error {
  16. return errNoCgo
  17. }
  18. // SystemDriverVersion returns the the driver version on the system.
  19. func SystemDriverVersion() (string, error) {
  20. return "", errNoCgo
  21. }
  22. // DeviceCount returns the number of nvidia devices on the system.
  23. func DeviceCount() (uint, error) {
  24. return 0, errNoCgo
  25. }
  26. // Device is the handle for the device.
  27. // This handle is obtained by calling DeviceHandleByIndex().
  28. type Device struct {
  29. }
  30. // DeviceHandleByIndex returns the device handle for a particular index.
  31. // The indices range from 0 to DeviceCount()-1. The order in which NVML
  32. // enumerates devices has no guarantees of consistency between reboots.
  33. func DeviceHandleByIndex(idx uint) (Device, error) {
  34. return Device{}, errNoCgo
  35. }
  36. // MinorNumber returns the minor number for the device.
  37. // The minor number for the device is such that the Nvidia device node
  38. // file for each GPU will have the form /dev/nvidia[minor number].
  39. func (d Device) MinorNumber() (uint, error) {
  40. return 0, errNoCgo
  41. }
  42. // UUID returns the globally unique immutable UUID associated with this device.
  43. func (d Device) UUID() (string, error) {
  44. return "", errNoCgo
  45. }
  46. // Name returns the product name of the device.
  47. func (d Device) Name() (string, error) {
  48. return "", errNoCgo
  49. }
  50. // MemoryInfo returns the total and used memory (in bytes) of the device.
  51. func (d Device) MemoryInfo() (uint64, uint64, error) {
  52. return 0, 0, errNoCgo
  53. }
  54. // UtilizationRates returns the percent of time over the past sample period during which:
  55. // utilization.gpu: one or more kernels were executing on the GPU.
  56. // utilizatoin.memory: global (device) memory was being read or written.
  57. func (d Device) UtilizationRates() (uint, uint, error) {
  58. return 0, 0, errNoCgo
  59. }
  60. // PowerUsage returns the power usage for this GPU and its associated circuitry
  61. // in milliwatts. The reading is accurate to within +/- 5% of current power draw.
  62. func (d Device) PowerUsage() (uint, error) {
  63. return 0, errNoCgo
  64. }
  65. // AveragePowerUsage returns the power usage for this GPU and its associated circuitry
  66. // in milliwatts averaged over the samples collected in the last `since` duration.
  67. func (d Device) AveragePowerUsage(since time.Duration) (uint, error) {
  68. return 0, errNoCgo
  69. }
  70. // AverageGPUUtilization returns the utilization.gpu metric (percent of time
  71. // one of more kernels were executing on the GPU) averaged over the samples
  72. // collected in the last `since` duration.
  73. func (d Device) AverageGPUUtilization(since time.Duration) (uint, error) {
  74. return 0, errNoCgo
  75. }
  76. // Temperature returns the temperature for this GPU in Celsius.
  77. func (d Device) Temperature() (uint, error) {
  78. return 0, errNoCgo
  79. }
  80. // FanSpeed returns the temperature for this GPU in the percentage of its full
  81. // speed, with 100 being the maximum.
  82. func (d Device) FanSpeed() (uint, error) {
  83. return 0, errNoCgo
  84. }
  85. // EncoderUtilization returns the percent of time over the last sample period during which the GPU video encoder was being used.
  86. // The sampling period is variable and is returned in the second return argument in microseconds.
  87. func (d Device) EncoderUtilization() (uint, uint, error) {
  88. return 0, 0, errNoCgo
  89. }
  90. // DecoderUtilization returns the percent of time over the last sample period during which the GPU video decoder was being used.
  91. // The sampling period is variable and is returned in the second return argument in microseconds.
  92. func (d Device) DecoderUtilization() (uint, uint, error) {
  93. return 0, 0, errNoCgo
  94. }