LoginSignup
1
2

More than 1 year has passed since last update.

Poetry + PyTorch 環境の構築の備忘録

Last updated at Posted at 2023-02-06

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"
1
2
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
1
2