Skip to main content

A quick access to nvidia gpu information

Project description

# gpuinfo

I implement some functions that can help users to obtain nvidia gpu information.

To use gpuinfo, you need to be able to run 'ps' and 'nvidia-smi' in your terminal.

# Install with pip
pip install gpuinfo
I only tested on linux system with python3.

# Usage

from gpuinfo import GPUInfo

GPUInfo has the following functions:

return a dict. show every user and memory on a certain gpu

return a list containing all GPU ids that no process is using currently.

return a dict and three lists. pid_list has pids as keys and gpu ids as values, showing which gpu the process is using

Input a pid number , return its creator by linux command ps

return two lists. The first list contains usage percent of every GPU. The second list contains the memory used of every GPU. The information is obtained by command 'nvidia-smi'

# Example

from gpuinfo import GPUInfo

min_percent=percent.index(min([percent[i] for i in available_device]))
min_memory=memory.index(min([memory[i] for i in available_device]))

torch.cuda.set_device(min_percent) 或者(min_memory)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for gpuinfo, version 1.0.0a7
Filename, size File type Python version Upload date Hashes
Filename, size gpuinfo-1.0.0a7-py3-none-any.whl (4.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size gpuinfo-1.0.0a7.tar.gz (5.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page