This release is a pre-release and may not be stable for production use.
# 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.
https://pypi.org/project/gpuinfo/
# Usage
```python
from gpuinfo import GPUInfo
```
GPUInfo has the following functions:
get_users(gpu_id)
return a dict. show every user and memory on a certain gpu
check_empty()
check_empty()
return a list containing all GPU ids that no process is using currently.
get_info()
pid_list,percent,memory,gpu_used=get_info()
return a dict and three lists. pid_list has pids as keys and gpu ids as values, showing which gpu the process is using
get_user(pid)
get_user(pid)
Input a pid number , return its creator by linux command ps
gpu_usage()
gpu_usage()
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
```python
from gpuinfo import GPUInfo
available_device=GPUInfo.check_empty()
#available_device就是一个含有所有没有任务的gpu编号的列表
percent,memory=GPUInfo.gpu_usage()
#获得所有gpu的使用百分比和显存占用量
min_percent=percent.index(min([percent[i] for i in available_device]))
#未被使用的gpu里percent最小的
min_memory=memory.index(min([memory[i] for i in available_device]))
#未被使用的gpu里显存占用量最少的
#如果你使用pytorch
torch.cuda.set_device(min_percent) 或者(min_memory)
```
Metadata
Release files for gpuinfo 1.0.0a7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gpuinfo-1.0.0a7.tar.gz | 5.3 kB | Without provenance | Details for gpuinfo-1.0.0a7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gpuinfo-1.0.0a7-py3-none-any.whl | Python 3 | none | any | Details for gpuinfo-1.0.0a7-py3-none-any.whl |
Total release size: 9.4 kB
Release files / gpuinfo-1.0.0a7.tar.gz
| Download URL | gpuinfo-1.0.0a7.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
56377301dbbd09c22b1bc19d5bb5d291b835676ed8e95f9004c195a091c7a077
|
|
BLAKE2b-256 checksum How to use checksums |
03940d99b8b788cd770cbd85f9324d874208c350f6c6d91596374a612ae558d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.4.2 requests/2.19.1 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.26.0 CPython/3.7.4
|
Release files / gpuinfo-1.0.0a7-py3-none-any.whl
| Download URL | gpuinfo-1.0.0a7-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a0dc7191542c95599e807ae103e80d63138fa82a472d0b7d22e757208586e6ab
|
|
BLAKE2b-256 checksum How to use checksums |
64c8bb3e935843f583fbf9970e125b888a2c7c0ec6ce6eada8d3f69d88be0294
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.4.2 requests/2.19.1 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.26.0 CPython/3.7.4
|
Security for gpuinfo 1.0.0a7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.