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]GPU交換(RTX3060ti → 5060ti)に伴うPyTorchプレビュー版の再インストール

0
Posted at

以前の実行環境と今回のエラー

  • windows 11
  • Python 3.13.7
  • GPU RTX 3060ti

この実行環境で物体検出なんかをやっていたんですが,GPUを交換したところPyTorchがGPUを認識しなくなりました.対応しているCUDAのバージョンを確認したところ,これまで使用していたものでも動くっぽいので一旦再インストールしましたが,

NVIDIA GeForce RTX 5060 Ti with CUDA capability sm_120 is not compatible with the current PyTorch installation.

というエラーが発生しました.安定版ではなくプレビュー版(公式サイトでNightlyと表示されているもの)なら動作するかと思い,前環境で使っていたバージョンのプレビュー版を再インストールするも動かず.

解決策と原因

エラーメッセージをよく読むとこんな内容が.

Your installed torch==2.15.0.dev20260907+cu126 does not include kernels for this GPU. Reinstall the same version against a CUDA build that does, e.g.:
For CUDA 13.0 use pip install torch==2.15.0.dev20260907 --index-url https://download.pytorch.org/whl/nightly/cu130
For CUDA 13.2 use pip install torch==2.15.0.dev20260907 --index-url https://download.pytorch.org/whl/nightly/cu132
For CUDA 13.4 use pip install torch==2.15.0.dev20260907 --index-url https://download.pytorch.org/whl/nightly/cu134

めっちゃ丁寧に教えてくれています.
どうやら古いバージョンのPyTorchだと,プレビュー版であっても新しめのアーキテクチャのGPU向けにはビルドされていない(エラーメッセージを見た感じカーネルが組み込まれてない)ことが原因のようです.
なので以下の一連のコマンドで,自環境で動作する最新のプレビュー版を再インストールします.

#GPUの詳細の確認,右上にCUDA Version◯◯ が出る
#出なかったらドライバの更新
nvidia-smi

#一度アンインストール
pip uninstall torch torchvision torchaudio -y

#対応している最新のプレビュー版をインストール
#コマンドに --preを入れるとプレビュー版になる
pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/ここに入れたいバージョン

バージョンの部分は,例えばCUDA12.6対応版をインストールするなら cu126 のように記述します.

他にやるべきこと

自分はもともとGrounding DINOとSAMを使っていたのですが,上記の手順を終えてテストするとSAMがエラーを吐きました.こっちは単純な再インストールで解決.少し調べたところによると,どうやらインストール時にPyTorchのバージョンに合わせたビルドを勝手にしてくれているようです.もし他のライブラリなどと統合した処理を実装していて,そっちにもエラーが出た場合は,そちらのエラーも再インストールで解決するかもしれません.

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?