{"id":37069653,"url":"https://github.com/veralvx/devicer","last_synced_at":"2026-01-14T08:01:08.694Z","repository":{"id":324093729,"uuid":"1095949458","full_name":"veralvx/devicer","owner":"veralvx","description":"Provides a helper to detect the best Pytorch device (env override, CUDA, MPS, XPU, or CPU) and to clear CUDA caches.","archived":false,"fork":false,"pushed_at":"2025-11-13T18:51:48.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-09T10:32:21.252Z","etag":null,"topics":["device","device-detection","device-detector","pytorch","torch","torch-device"],"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/veralvx.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-13T18:24:34.000Z","updated_at":"2025-11-13T18:51:52.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/veralvx/devicer","commit_stats":null,"previous_names":["veralvx/devicer"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/veralvx/devicer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veralvx%2Fdevicer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veralvx%2Fdevicer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veralvx%2Fdevicer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veralvx%2Fdevicer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/veralvx","download_url":"https://codeload.github.com/veralvx/devicer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veralvx%2Fdevicer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28413527,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T05:26:33.345Z","status":"ssl_error","status_checked_at":"2026-01-14T05:21:57.251Z","response_time":107,"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":["device","device-detection","device-detector","pytorch","torch","torch-device"],"created_at":"2026-01-14T08:01:07.415Z","updated_at":"2026-01-14T08:01:08.673Z","avatar_url":"https://github.com/veralvx.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pytorch Device Detection\n\nSmall utility to select a torch device at runtime and to clear CUDA caches.\n\n## Summary\n\nProvides two functions:\n\n- `get_device(strings=False, verbose=False)`: returns the best available device (`torch.device` by default, or a string when `strings=True`). Probes in this order: `TORCH_DEVICE`/`DEVICE` environment variables, CUDA, MPS, XPU (torch.xpu or intel_extension_for_pytorch.xpu), then CPU. When `verbose=True` the function emits debug-level messages through the logger.\n\n- `clear_torch()`: calls `torch.cuda.empty_cache()`.\n\n## Install\n\n```console\nuv add devicer\n```\n\nIf you want XPU:\n\n```console\nuv add devicer[xpu]\n```\n\n## Usage\n\n```py\nfrom devicer import get_device\n\ndevice = get_device()\nprint(device)\n```\n\nEnvironment variables:\n\n- Set `TORCH_DEVICE` or `DEVICE` to force a device, for example `cuda`, `cuda:0`, `mps`, `cpu`, or `xpu`:\n\n```sh\nexport TORCH_DEVICE=cuda\npython myscript.py\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fveralvx%2Fdevicer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fveralvx%2Fdevicer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fveralvx%2Fdevicer/lists"}