gputil

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 8 Imported by: 0

README


GPUtil

GPUtil: Golang Implementation based on https://github.com/anderskm/gputil (Python Version)

Overview

This project is a Golang implementation of the functionality provided by https://github.com/anderskm/gputil in Python. It offers some useful features that can help you accomplish specific tasks.

Features

  • Feature 1: List GPU informations
  • Feature 2: List processes having compute context on the device

Installation

To install and run this project, follow these steps:

$ go get -u github.com/lichunqiang/gputil

Usage Example

Here is an example code snippet demonstrating the usage of this project:

package main

import (
   "context"
   "fmt"
   "github.com/lichunqiang/gputil"
)

func main() {
   ctx := context.Background()
   gpus, err := gputil.GetGPUs(ctx)
   if err != nil {
      panic(err)
   }
   for _, item := range gpus {
      fmt.Println(item.String())
   }
}

Contribution Guidelines

If you would like to contribute to this project, please follow these steps:

  1. Fork the project to your GitHub account.
  2. Clone the project to your local machine:
    git clone https://github.com/lichunqiang/gputil.git
    
  3. Create a new branch:
    git checkout -b feature/your-feature
    
  4. Make your modifications and improvements.
  5. Commit your changes:
    git commit -m "Add your commit message"
    
  6. Push your changes to the remote repository:
    git push origin feature/your-feature
    
  7. Create a Pull Request and wait for review and merge.

License

This project is licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GPU

type GPU struct {
	// Zero based index of the GPU. Can change at each boot.
	Index string `json:"index"`
	// This value is the globally unique immutable alphanumeric identifier of the GPU.
	// It does not correspond to any physical label on the board.
	UUID string `json:"uuid"`
	// Percent of time over the past sample period during which one or more kernels was executing on the GPU.
	// The sample period may be between 1 second and 1/6 second depending on the product.
	UtilizationGPU string `json:"utilizationGPU"`
	// Total installed GPU memory. units, MiB
	MemoryTotal string `json:"memoryTotal"`
	// Total memory allocated by active contexts. units, MiB
	MemoryUsed string `json:"memoryUsed"`
	// Total free memory. units, MiB
	MemoryFree string `json:"memoryFree"`
	// The version of the installed NVIDIA display driver.
	// This is an alphanumeric string.
	DriverVersion string `json:"driverVersion"`
	// The official product name of the GPU. This is an alphanumeric string
	Name string `json:"name"`
	// This number matches the serial number physically printed on each board. It is a globally unique immutable alphanumeric value.
	Serial string `json:"serial"`
	// The last measured power draw for the entire board, in watts.
	// On Ampere or newer devices, returns average power draw over 1 sec.
	// On older devices, returns instantaneous power draw. Only available if power management is supported.
	// This reading is accurate to within +/- 5 watts.
	PowerDraw string `json:"powerDraw"`
	// The software power limit in watts. Set by software like nvidia-smi.
	// On Kepler devices Power Limit can be adjusted using [-pl | --power-limit=] switches.
	PowerLimit string `json:"powerLimit"`
	// Core GPU temperature. in degrees C.
	Temperature string `json:"temperature"`
	// The timestamp of when the query was made in format "YYYY/MM/DD HH:MM:SS.msec".
	Timestamp string `json:"timestamp"`
}

GPU information

func GetGPUs

func GetGPUs(ctx context.Context, indexOrUUIDs ...string) (result []GPU, err error)

GetGPUs returns all GPUs or specified index/uuids information

func (*GPU) String

func (g *GPU) String() string

type GPUComputeApp

type GPUComputeApp struct {
	// The timestamp of when the query was made in format "YYYY/MM/DD HH:MM:SS.msec".
	Timestamp string `json:"timestamp"`
	// The official product name of the GPU.
	// This is an alphanumeric string. For all products.
	Name string `json:"name"`
	// This value is the globally unique immutable alphanumeric identifier of the GPU.
	// It does not correspond to any physical label on the board.
	UUID string `json:"uuid"`
	// Process ID of the compute application
	PID string `json:"pid"`
	// Process Name
	ProcessName string `json:"processName"`
	// Amount memory used on the device by the context.
	// Not available on Windows when running in WDDM mode because Windows KMD manages all the memory not NVIDIA driver.
	UsedMemory string `json:"usedMemory"`
}

GPUComputeApp processes having compute context on the device.

func GetProcesses

func GetProcesses(ctx context.Context, indexOrUUIDs ...string) (result []GPUComputeApp, err error)

GetProcesses returns processes having compute context on the device Note: if no processes running, empty result return

func (*GPUComputeApp) String

func (c *GPUComputeApp) String() string

Jump to

Keyboard shortcuts

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