{"id":14970726,"url":"https://github.com/jonasricker/autocvd","last_synced_at":"2026-02-26T21:04:56.539Z","repository":{"id":65365280,"uuid":"552751250","full_name":"jonasricker/autocvd","owner":"jonasricker","description":"Tool to automatically set CUDA_VISIBLE_DEVICES based on GPU utilization. Usable from command line and code.","archived":false,"fork":false,"pushed_at":"2023-06-15T06:55:31.000Z","size":29,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-10T11:23:30.767Z","etag":null,"topics":["cuda","cuda-visible-devices","gpu","keras","machine-learning","nvidia","python","pytorch","tensorflow"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/autocvd/","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/jonasricker.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-17T07:10:33.000Z","updated_at":"2025-09-03T12:45:16.000Z","dependencies_parsed_at":"2024-09-03T09:41:48.169Z","dependency_job_id":"f7a4f049-bf3a-4983-aaf0-b1b666033843","html_url":"https://github.com/jonasricker/autocvd","commit_stats":{"total_commits":19,"total_committers":1,"mean_commits":19.0,"dds":0.0,"last_synced_commit":"ee28ca8cf7e8a7d099846e2e4f7fbe77a7d6c96d"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/jonasricker/autocvd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasricker%2Fautocvd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasricker%2Fautocvd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasricker%2Fautocvd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasricker%2Fautocvd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonasricker","download_url":"https://codeload.github.com/jonasricker/autocvd/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasricker%2Fautocvd/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29872674,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T21:01:59.805Z","status":"ssl_error","status_checked_at":"2026-02-26T21:00:42.555Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","cuda-visible-devices","gpu","keras","machine-learning","nvidia","python","pytorch","tensorflow"],"created_at":"2024-09-24T13:44:03.087Z","updated_at":"2026-02-26T21:04:56.500Z","avatar_url":"https://github.com/jonasricker.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# autocvd, a tool for setting CUDA_VISIBLE_DEVICES based on GPU utilization\n\nOn a system with multiple NVIDIA GPUs, *autocvd* **eliminates the need for manually specifying the `CUDA_VISIBLE_DEVICES` environment variable**. This comes in especially handy on systems with multiple users, like a **shared GPU server**. It is **dependency-free** and requires **no code changes**.\n\nTo execute a command on a single free GPU, run\n```bash\n$ eval $(autocvd) \u003ccommand\u003e\n```\nThis will select a free GPU (or wait if none is available) and run the command with the appropriate environment variables set.\n\nFor ease of use you might want to define an alias in your `.bashrc`, e.g., to run a Python script on a free GPU:\n```bash\n$ alias gpupython=\"eval $(autocvd) python\"\n```\n\n## Examples\n```bash\n# run command on two free GPUs\n$ eval $(autocvd -n 2) \u003ccommand\u003e\n\n# run command on least-used GPU (i.e., do not wait if no GPU is free)\n$ eval $(autocvd -l) \u003ccommand\u003e\n\n# exclude certain GPUs\n$ eval $(autocvd -x 0 2) \u003ccommand\u003e\n\n# if no free GPU is available immediately, wait for 60 seconds only\n$ eval $(autocvd -t 60) \u003ccommand\u003e\n\n# export environment variables into the current shell\n$ . \u003c(autocvd -e)  # alternatively: source \u003c(autocvd -e)\n```\n\n## Requirements\n*autocvd* uses [`nvidia-smi`](https://developer.nvidia.com/nvidia-system-management-interface) to query GPU utilization.\nMake sure that it is installed and callable.\n\n## Installation\n```bash\npip install autocvd\n```\n## Usage\n```\nusage: autocvd [-h] [-n NUM_GPUS] [-l] [-t TIMEOUT] [-i INTERVAL] [-e] [-o] [-q]\n\nA tool for setting CUDA_VISIBLE_DEVICES based on utilization. Basic usage: eval $(autocvd) \u003ccommand\u003e\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -n NUM_GPUS, --num-gpus NUM_GPUS\n                        Number of required GPUs. Defaults to 1.\n  -l, --least-used      Select least-used GPUs instead of waiting for free GPUs. Defaults to False.\n  -x EXCLUDE [EXCLUDE ...], --exclude EXCLUDE [EXCLUDE ...]\n                        One or multiple GPUs (separated by space) to be excluded. Defaults to no GPU being excluded.\n  -t TIMEOUT, --timeout TIMEOUT\n                        Timeout for waiting in seconds. Defaults to no timeout.\n  -i INTERVAL, --interval INTERVAL\n                        Interval to query GPU status in seconds. Defaults to 30.\n  -e, --export          Add 'export' statements such that environment can be sourced.\n  -o, --id-only         Return comma-separated GPU IDs only instead of environment variable assignment.\n  -q, --quiet           Do not print any messages. Defaults to False.\n```\n\n*autocvd* can also be used to set the environment variables from a Python script itself:\n```python\nfrom autocvd import autocvd\n\n\nautocvd()\n\n# code accessing GPUs\n```\nNote that some packages read `CUDA_VISIBLE_DEVICES` when being imported, which makes it necessary to call *autocvd* **before** importing them.\n\n\n## Notes\n- Besides setting `CUDA_VISIBLE_DEVICES`, *autocvd* also sets `CUDA_DEVICE_ORDER=PCI_BUS_ID`. This is required to ensure that the ordering of CUDA devices is consistent.\n\n## Related Projects\n- [autocvd-go](https://github.com/shunk031/autocvd-go)\n- [cuthon](https://github.com/awni/cuthon)\n- [setGPU](https://github.com/bamos/setGPU)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonasricker%2Fautocvd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonasricker%2Fautocvd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonasricker%2Fautocvd/lists"}