Skip to main content

A GPU utility package for Coargus services.

Project description

GPU Utility Package

This Python module provides tools for managing GPUs in a machine learning or high-performance computing environment. It allows users to identify free GPUs with a specified amount of available memory and optionally set the CUDA_VISIBLE_DEVICES or other required gpu environment variable to use those GPUs.

Features

  • Check for Free GPUs: Determine which GPUs on the system have a minimum specified amount of free memory.
  • Set CUDA Environment: Automatically set the CUDA_VISIBLE_DEVICES environment variable to use GPUs that meet the memory requirements.

Requirements

  • Python 3.8 or higher
  • pynvml: Python bindings for the NVIDIA Management Library
  • subprocess module (standard in Python)

Usage

Getting Free GPUs You can retrieve a list of GPUs that have at least a specified amount of free memory. You can specify whether to use the NVIDIA System Management Interface (nvidia-smi) or the NVML library.

from gpu_modules import get_free_gpus

# Get free GPUs with at least 10 GB of free memory using NVML
free_gpus = get_free_gpus(10240)
print("Free GPUs:", free_gpus)

# Alternatively, use nvidia-smi to check for free GPUs
free_gpus_smi = get_free_gpus(10240, use_nvidia_smi=True)
print("Free GPUs using nvidia-smi:", free_gpus_smi)

Setting CUDA Visible Devices

To set the CUDA_VISIBLE_DEVICES environment variable automatically based on free memory:

from gpu_modules import set_cuda_visible_devices

# Set CUDA_VISIBLE_DEVICES for GPUs with at least 10 GB free memory
if set_cuda_visible_devices(10240):
    print("CUDA_VISIBLE_DEVICES set successfully.")
else:
    print("No free GPUs available.")

Contributing

Contributions to this project are welcome. Please submit a pull request or open an issue to discuss proposed changes or report bugs.

Project details


Download files

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

Source Distribution

caggpu-0.0.2.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

caggpu-0.0.2-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file caggpu-0.0.2.tar.gz.

File metadata

  • Download URL: caggpu-0.0.2.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.19

File hashes

Hashes for caggpu-0.0.2.tar.gz
Algorithm Hash digest
SHA256 84b22d3452892903fa974d4929f7e107154b80a3bf5a51fa1d74ca9723d7c3c2
MD5 06f723dcc605968fbe760962200e7b70
BLAKE2b-256 b333e0257932f8dd17ab6ecda1612b57f760935a1ab9ad9bd6e6458dfde7930a

See more details on using hashes here.

File details

Details for the file caggpu-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: caggpu-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.19

File hashes

Hashes for caggpu-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3746139748deee2da93484df461dbd45fb1914f6ec8a9219d7ddcabe8a2a85dd
MD5 af82a3933729fd05fd498b41f17da725
BLAKE2b-256 8fd730c22a646d7d99bfe4990fa9823c6d22c0aa0c07d30b07a33c759a3a51d8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page