Skip to main content

GpuUtils

Working on a shared environment with multiple GPUs might be problematic. Advanced frameworks apply greedy approach and they tend to allocate all GPUs and all memory of your system. GpuUtils helps you to find the best GPU on your system to allocate. It also provides a gpu related information in a structure format.

Installation

The easiest way to install GpuUtils is to install it via PyPI.

pip install gpuutils

Analyzing system

Running nvidia-smi command in the command prompt allows users to monitor GPU related information such as memory and utilization. Herein, system analysis function loads GPU related information into a pandas data frame or json array.

from gpuutils import GpuUtils
df = GpuUtils.analyzeSystem() #this will return a pandas data frame
#dict = GpuUtils.analyzeSystem(pandas_format = False) #this will return a json array

Default configuration of system analysis returns a Pandas data frame.

gpu_index total_memories_in_mb available_memories_in_mb memory_usage_percentage utilizations power_usages_in_watts power_capacities_in_watts
1 32480 32469 0.0339 0 43 300
2 32480 32469 0.0339 0 43 300
3 32480 32469 0.0339 0 44 300
4 32480 32469 0.0339 0 43 300
5 32480 32469 0.0339 0 43 300
6 32480 32469 0.0339 0 43 300
7 32480 32469 0.0339 0 43 300
0 32480 31031 4.4612 7 56 300

Allocation

GpuUtils can allocate GPUs as well. Calling allocation function directly finds the available GPUs and allocate based on your demand.

from gpuutils import GpuUtils
GpuUtils.allocate() #this tries to allocate a GPU having 1GB memory
#GpuUtils.allocate(required_memory = 10000)
#GpuUtils.allocate(required_memory = 10000, gpu_count=1)

To avoid greedy approach

Advanced frameworks such as TensorFlow tend to allocate all memory. You can avoid this approach if you pass the framework argument in allocate function. In this way, the framework will use the gpu memory as much as needed. Currently, keras and tensorflow frameworks are supported in allocate function.

GpuUtils.allocate(framework = 'keras')

Support

There are many ways to support a project - starring⭐️ the GitHub repos is just one.

Licence

GpuUtils is licensed under the MIT License - see LICENSE for more details.

Metadata

Release files for gpuutils 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gpuutils 0.0.2
File Size Uploaded
gpuutils-0.0.2.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gpuutils 0.0.2
File Interpreter ABI Platform
gpuutils-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 8.7 kB

Release files / gpuutils-0.0.2.tar.gz

Download URL gpuutils-0.0.2.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a7703eed72e144355d275ce098b31f1b39da490f3d4724b2bf48a83a6e6b7ce6
BLAKE2b-256 checksum
How to use checksums
638678702fc7c03725b56bfdff3e7a97ee78054a26782918da38413c97d8e11e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.4

Release files / gpuutils-0.0.2-py3-none-any.whl

Download URL gpuutils-0.0.2-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0c59202fc5cbf72511b80997db70b4592442b83dad94d65d621ff76ad0efbff3
BLAKE2b-256 checksum
How to use checksums
046075edaa3b46eae48f5f16c2226f52a1afd0e17231fb4fc34508cebdf0baea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.4

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page