macOS の pyenv 使用環境下において以下を実行する。
$ poetry new test_poetry_torch
$ cd test_poetry_torch
現在(2023-02-06)の最新版で利用できる Python + Torch 環境は Python 3.10.9 と Torch 1.13.1 であるので pyproject.toml
を以下のように Python の依存性を指定し直す。
pyproject.toml
# ...
[tool.poetry.dependencies]
python = ">=3.10,<3.11"
# ...
以下を実行して文句を言われないことを確認する。
$ poetry env use python3.10
$ poetry install
PyTorch プロジェクトのパッケージ群をインストールする。
$ poetry add torch
$ poetry add torchvision
$ poetry add torchaudio
最終的な pyproject.toml
は以下のようになる。
pyproject.toml
[tool.poetry]
name = "test-poetry-torch"
version = "0.1.0"
description = ""
authors = ["Paalon <paalon@email.adress>"]
readme = "README.md"
packages = [{include = "test_poetry_torch"}]
[tool.poetry.dependencies]
python = ">=3.10,<3.11"
torch = "^1.13.1"
torchvision = "^0.14.1"
torchaudio = "^0.13.1"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"