dskjal
広告
広告

torch と cuda の tips

カテゴリ:deeplearning

CUDA は後方互換性があるので、nvcc -V の出力より前のライブラリでビルドされているものも実行できる。

venv の有効化

./venv/Scripts/activate

インストールされているバージョンを調べる

torch+cuda

pip show torch

出力例

Version: 1.12.1+cu116

CUDA

nvcc -V

出力例

Cuda compilation tools, release 12.4, V12.4.99

torch のインストール

複数の環境にインストールする場合(Comfy と sd-script など)は、whl をローカルに保存しておいてインストールすると早い。

pip install "C:/whls/torch-2.6.0+cu124-cp311-cp311-win_amd64.whl"
pip install "C:/whls/torchvision-0.21.0+cu124-cp311-cp311-win_amd64.whl"

安定板

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

最新

pip install torch==2.8.0 torchvision==0.23.0 --index-url https://download.pytorch.org/whl/cu126

CUDA のインストール

CUDA Toolkit Archive

CUDA のインストールは再起動不要。

自分の環境にあった torch のバージョンアップ

注意点は以下の2つ

  1. nvcc -V のバージョンより前のバージョンのライブラリでビルドされている
  2. 指定されているバージョンの torch を使う
pip install torch==2.3.1+cu121 -f https://download.pytorch.org/whl/torch_stable.html

Numpy のバージョンダウン

pip uninstall numpy
pip install "numpy<2"

広告
広告

カテゴリ