アプリケーション開発ポータルサイト
ServerNote.NET
カテゴリー【PythonDebian
CUDA13環境下でGPU使用版のPyTorchを導入する
POSTED BY
2025-11-25

Debian 12 + CUDA Version 13の環境下において、以下のようにtorchを入れようとする。

python3 -V
Python 3.11.2
python3 -m venv venv
source venv/bin/activate
(venv) pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu130
...
ERROR: Cannot install torch==2.9.0+cu130 and torch==2.9.1+cu130 because these package versions have conflicting dependencies.

The conflict is caused by:
    torch 2.9.1+cu130 depends on typing-extensions>=4.10.0
    torch 2.9.0+cu130 depends on typing-extensions>=4.10.0

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
...

と、なぜかコンクリフトが発生し失敗する。エラーによればtyping-extensionsに問題があるので、先にこれを手動で入れておけば大丈夫そうだ。最初からやり直す。

(venv) deactivate
rm -Rf venv
python3 -m venv venv
source venv/bin/activate
(venv) pip install --upgrade pip
(venv) pip install "typing-extensions>=4.10.0" filelock
(venv) pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu130

これで完璧。コンソールでテストしてみよう。

(venv) python
Python 3.11.2 (main, Apr 28 2025, 14:11:48) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print("torch:", torch.__version__)
torch: 2.9.1+cu130
>>> print("CUDA available?:", torch.cuda.is_available())
CUDA available?: True
>>> print("CUDA version reported by torch:", torch.version.cuda)
CUDA version reported by torch: 13.0

お疲れ様でした。

※本記事は当サイト管理人の個人的な備忘録です。本記事の参照又は付随ソースコード利用後にいかなる損害が発生しても当サイト及び管理人は一切責任を負いません。
※本記事内容の無断転載を禁じます。
【WEBMASTER/管理人】
自営業プログラマーです。お仕事ください!
ご連絡は以下アドレスまでお願いします★

【キーワード検索】