Skip to main content

Find unused GPU devices on your system.

Project description

nvsmpy

This package parses information from nvidia-smi into python. You can use it to display usage information about your GPUs, or to select an unoccupied GPU to run your experiments on. It can set the CUDA_VISIBLE_DEVICES environment variable to limit your access to a single or multiple available GPUs. A RuntimeError will be raised if all GPUs are busy.

Installation

pip install nvsmpy

Usage

import os
from nvsmpy import CudaCluster

cluster = CudaCluster()
print(cluster)

# To limit access to any two unused GPUs:
with cluster.available_devices(n_devices=2):
    print(os.environ["CUDA_VISIBLE_DEVICES"])
    # your code goes here

# Alternatively limit access to GPUs 0 and 7, regardless of availability:
with cluster.visible_devices(0, 3, 7):
    print(os.environ["CUDA_VISIBLE_DEVICES"])
    # your code goes here

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

nvsmpy-0.2.1.tar.gz (4.1 kB view hashes)

Uploaded Source

Built Distribution

nvsmpy-0.2.1-py3-none-any.whl (8.8 kB view hashes)

Uploaded Python 3

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