0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

RyeやPoetryでPyPIに登録されていないバージョンのPyTorchをインストールする

Posted at

旧バージョンの PyTorch はPyPIに登録されておらず,インストールするには外部ソースを参照する必要があったりします

pip install torch==1.9.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html

RyePoetry にはpip-f (--find-links) のようなオプションは無いので,外部ソースを参照するには別途設定する必要があります

Ryeの場合

pyproject.tomlで外部ソースを設定します

pyproject.toml
[[tool.rye.sources]]
name = "torch"
url = "https://download.pytorch.org/whl/torch_stable.html"
type = "find-links"    

これで旧バージョンのPyTorchをインストールできるようになります

rye add torch==1.9.0+cu111

Poetryの場合

Poetryでもpyproject.tomlで外部ソースを設定します.私の環境ではhttps://download.pytorch.org/whl/torch_stable.html からtorchをインストールできなかったのでURLを変えています

pyproject.toml
[[tool.poetry.source]]
name = "torch"
url = "https://download.pytorch.org/whl"
priority = "supplemental"

これで旧バージョンのPyTorchをインストールできるようになります

poetry add torch==1.9.0+cu111

直接パッケージを入れるやり方 (非推奨)

私は推奨しませんが,URIから直接wheelファイルを入れることもできます

rye add torch --url https://download.pytorch.org/whl/cu111/torch-1.9.0%2Bcu111-cp38-cp38-linux_x86_64.whl

pyproject.tomlはこうなります

pyproject.toml
dependencies = [
    "torch @ https://download.pytorch.org/whl/cu111/torch-1.9.0%2Bcu111-cp38-cp38-linux_x86_64.whl",
]

Poetryだとこんな感じ

poetry add https://download.pytorch.org/whl/cu111/torch-1.9.0%2Bcu111-cp38-cp38-linux_x86_64.whl
pyproject.toml
[tool.poetry.dependencies]
python = "^3.8"
torch = {url = "https://download.pytorch.org/whl/cu111/torch-1.9.0%2Bcu111-cp38-cp38-linux_x86_64.whl"}

以上.まだ環境を動かしてないので不具合があるかもしれません

今回の環境です

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?