{"id":22893385,"url":"https://github.com/jaxony/pynvidia","last_synced_at":"2025-05-07T19:11:40.449Z","repository":{"id":62582174,"uuid":"115077939","full_name":"jaxony/pynvidia","owner":"jaxony","description":"⚙️ NVIDIA GPU utilities for Python 🔧 ","archived":false,"fork":false,"pushed_at":"2017-12-23T05:37:36.000Z","size":7,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-07T19:11:36.638Z","etag":null,"topics":["cuda","deep-learning","nvidia-gpu","pip","python","utility"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jaxony.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-22T04:55:22.000Z","updated_at":"2023-08-05T15:03:58.000Z","dependencies_parsed_at":"2022-11-03T21:34:26.959Z","dependency_job_id":null,"html_url":"https://github.com/jaxony/pynvidia","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaxony%2Fpynvidia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaxony%2Fpynvidia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaxony%2Fpynvidia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaxony%2Fpynvidia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaxony","download_url":"https://codeload.github.com/jaxony/pynvidia/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252940934,"owners_count":21828769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cuda","deep-learning","nvidia-gpu","pip","python","utility"],"created_at":"2024-12-13T23:14:15.627Z","updated_at":"2025-05-07T19:11:40.423Z","avatar_url":"https://github.com/jaxony.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pynvidia\nA simple, lightweight Python library that provides NVIDIA GPU utility functions.\n\n## Why?\nI found it annoying that my continuous integration tests for deep learning default to using a fixed GPU. This default behaviour leads to problems when memory-intensive tests are being done on GPU 0 when GPU 0 is at 90% memory usage. The consequence is failed tests and, in turn, merge/pull requests that cannot pass because of `CUDA out of memory` errors.\n\n## Solution\n`pynvidia` is a simple Python library that parses and processes the command line output of `nvidia-smi` so that GPUs can be dynamically selected at runtime. Specifically, the least utilised GPU(s) can be selected for a machine learning job.\n\n## Install me\n```\n$ pip install pynvidia\n```\n\n## Requirements\n`nvidia-smi` must be installed on your system.\n\n## Example usage\n### Dynamically select the most appropriate GPU to use at runtime\n```python\nimport os\nimport pynvidia as pyn\n\ngpu_id = pyn.gpu_using_least_memory()\n\n...\n\nos.environ[\"CUDA_VISIBLE_DEVICES\"] = str(gpu_id)\n```\n\n## API\n### memory\nUtilities for getting GPU memory usage.\n\n- `pynvidia.memory.gpu_using_least_memory()`\n- `pynvidia.memory.gpus_using_least_memory(num_gpus=1)` (future)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaxony%2Fpynvidia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaxony%2Fpynvidia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaxony%2Fpynvidia/lists"}