0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PyTorch インストールを自動化するシェルスクリプトを作った

0
Posted at

Pytorchのインストール

CUDAバージョンを毎回調べて
pip install torch --index-url https://download.pytorch.org/whl/cu121
みたいな長いコマンドを打つの、面倒じゃないですか?


今回作成したスクリプトは CUDAバージョンを自動検出 して、適切なPyTorchをインストールしてくれます。

コマンドの確認(推奨)

初めは --dry-run で実行前にコマンドを確認する のがおすすめです。

./install_pytorch.sh --dry-run

仮想環境を作成してインストール(推奨)

./install_pytorch.sh --venv

torch だけ入れたい

./install_pytorch.sh --venv --only-torch

バージョン指定も可能

./install_pytorch.sh --venv --torch 2.4.0 --cuda 12.1

nvcc、nvidia-smi、/usr/local/cuda など複数の方法でCUDAを検出し、cu118/cu121/cu124 を自動選択。pip と UV の両方に対応しています。

地味に気に入ってるのが --venv オプション。仮想環境の作成からインストール、動作確認まで一発で完了します。


バグとか改善要望があったらコメントかIssueで教えてください。

おわり。

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?