Utility functions for working with GPUs.
Project description
GPU Utils
A few small functions/scripts for working with GPUs.
Requirements
- Python 3.6+
- Linux OS (only tested on Ubuntu; I use
subprocess.runfor things likekillandlsof)
Installation
pip install gpu_utils
Usage
from gpu_utils.utils import gpu_init, kill_interrupted_processes
# sets GPU ids to use nvidia-smi ordering (CUDA_DEVICE_ORDER = PCI_BUS_ID)
# finds the gpu with the most free utilization
# hides all other GPUs so you only use this one (CUDA_VISIBLE_DEVICES = <gpu_id>)
gpu_id = gpu_init(best_gpu_metric="util") # could also use "mem"
# run lots of things here ...
# if you interrupt a process using a GPU but find that, even though `nvidia-smi` no
# longer shows the process, the memory is still being held, try this
kill_interrupted_processes(sudo=False)
Command Line Scripts
gpu runs nvidia-smi and then ps u <pid> on the PIDs so you can see who is running what. I plan to make the output more concise than nvidia-smi at some point.
tmux_gpu_info.py just prints a list of the percent utilization of each GPU; you can, e.g., show this in the status bar of tmux to keep an eye on your GPUs.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
gpu_utils-0.1.1.tar.gz
(4.0 kB
view details)
File details
Details for the file gpu_utils-0.1.1.tar.gz.
File metadata
- Download URL: gpu_utils-0.1.1.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f306f11fe01949ad3237a1c6b17d63e0957218fd5279f4ef70589a734cda22a
|
|
| MD5 |
6bdbcd166e30f67fa1153aafa0e7a3dd
|
|
| BLAKE2b-256 |
fb2accc3789c45bca37540cded24e86316512dc496997498144422291b25eadc
|