{"id":28602867,"url":"https://github.com/lucaspar/poetry-torch","last_synced_at":"2025-10-19T02:10:32.852Z","repository":{"id":244155749,"uuid":"814427927","full_name":"lucaspar/poetry-torch","owner":"lucaspar","description":"Installing hardware-accelerated PyTorch with Poetry on different hardware using the same `pyproject.toml`","archived":false,"fork":false,"pushed_at":"2025-04-29T21:30:50.000Z","size":11,"stargazers_count":40,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-29T22:29:36.628Z","etag":null,"topics":["cuda","hardware-acceleration","poetry","pyproject-toml","python-poetry","pytorch","torch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lucaspar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-06-13T02:08:48.000Z","updated_at":"2025-04-29T21:30:53.000Z","dependencies_parsed_at":"2024-06-13T06:34:22.561Z","dependency_job_id":"e7b549d5-1cb5-4b98-81bd-30389fc5ecf3","html_url":"https://github.com/lucaspar/poetry-torch","commit_stats":null,"previous_names":["lucaspar/poetry-torch"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lucaspar/poetry-torch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucaspar%2Fpoetry-torch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucaspar%2Fpoetry-torch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucaspar%2Fpoetry-torch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucaspar%2Fpoetry-torch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucaspar","download_url":"https://codeload.github.com/lucaspar/poetry-torch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucaspar%2Fpoetry-torch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259294343,"owners_count":22835784,"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","hardware-acceleration","poetry","pyproject-toml","python-poetry","pytorch","torch"],"created_at":"2025-06-11T16:12:31.568Z","updated_at":"2025-10-19T02:10:27.770Z","avatar_url":"https://github.com/lucaspar.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Installing PyTorch with Poetry\n\nConditionally installing hardware-accelerated PyTorch with Poetry on different hardware using the same `pyproject.toml` [can be tricky](https://github.com/python-poetry/poetry/issues/6409). This repo serves as a quick lookup for the configuration file and installation commands.\n\n+ [Installing PyTorch with Poetry](#installing-pytorch-with-poetry)\n    + [Installation Modes](#installation-modes)\n    + [Embedding the choice in a script](#embedding-the-choice-in-a-script)\n    + [Trying it out](#trying-it-out)\n    + [Switching versions / upgrading](#switching-versions--upgrading)\n        + [CUDA](#cuda)\n\n## Installation Modes\n\n| Command                           | Behavior                                                       |\n| --------------------------------- | -------------------------------------------------------------- |\n| `poetry sync`                     | Does not install PyTorch (import fails).                       |\n| `poetry sync -E cpu`              | Installs PyTorch with CPU only.                                |\n| `poetry sync -E cuda --with cuda` | Installs the CUDA variant of PyTorch. Expects NVIDIA hardware. |\n\n\u003e[!WARNING]\n\u003e The example below is likely not what you want:\n\u003e\n\u003e | Command               | Behavior                                                                 |\n\u003e | --------------------- | ------------------------------------------------------------------------ |\n\u003e | `poetry sync -E cuda` | Actually installs the CPU variant of PyTorch without errors or warnings. |\n\nThe [`sync` command](https://python-poetry.org/docs/cli#sync) behaves like the old `poetry install --sync`, and it's better suited to keep the current local state in sync with your lock file, as it will also remove dependencies missing from the lock. You probably want to use it instead of `poetry install` to avoid untracked outdated packages in most cases.\n\n## Embedding the choice in a script\n\n```bash\nif lspci | grep -i nvidia; then\n    poetry sync --extras=cuda --with cuda\nelse\n    poetry sync --extras=cpu\nfi\n```\n\n## Trying it out\n\n```bash\npoetry run python check-cuda.py\n```\n\nor\n\n```bash\npoetry run python -c \"import torch; print(torch.cuda.is_available())\"\n```\n\n## Switching versions / upgrading\n\n+ [Torch/Python/CUDA Compatibility Matrix of Releases](https://github.com/pytorch/pytorch/blob/main/RELEASE.md#release-compatibility-matrix)\n+ [Torchvision Versions (wheels)](https://download.pytorch.org/whl/torchvision/)\n\n### CUDA\n\n+ [CUDA Compute Capability numbers by GPU model](https://developer.nvidia.com/cuda-gpus#compute)\n+ [CUDA Version Matrix by Driver Version](https://docs.nvidia.com/deploy/cuda-compatibility/#id3)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucaspar%2Fpoetry-torch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucaspar%2Fpoetry-torch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucaspar%2Fpoetry-torch/lists"}