I was working on a project from my work. That project needs to add dependencies Pytorch 2.0.0 + CUDA 11.8.
However, the dependencies are from https://download.pytorch.org/whl/cu118.
In pip, you could use pip install --extra-index-urlto install.
However, how it works in Poetry? Take Pytorch 2.0.0 + CUDA 11.8 as an example.
$ poetry source add --priority=supplemental pytorch-index https://download.pytorch.org/whl/cu118
Priority indicates where poetry should look up package first. It has default, primary and supplemental. Here we use supplemental.
Supplemental Package Sources
Introduced in 1.5.0
Package sources configured as supplemental are only searched if no other (higher-priority) source yields a compatible package distribution. This is particularly convenient if the response time of the source is high and relatively few package distributions are to be fetched from this source.
https://python-poetry.org/docs/repositories/#supplemental-package-sources
For more details, you can refer to https://python-poetry.org/docs/repositories/#private-repository-example
Once the source is added, you can see there is a new section in pyproject.toml.
[[tool.poetry.source]]
name = "pytorch-index"
url = "https://download.pytorch.org/whl/cu118"
priority = "supplemental"
Then you can just enter below to install the dependencies.
$ poetry add torch==2.0.0+cu118 torchvision==0.15.1+cu118 torchaudio==2.0.1+cu118
搶先發佈留言