NVIDIA GeForce RTX 50xx with CUDA capability sm_120 is not compatible with the current PyTorch installation. が発生したとき

こんにちは、PyTorch 2.6.0 環境で以下のような問題が発生したときの対処方法について解説いたします。
NVIDIA GeForce RTX 5090 with CUDA capability sm_120 is not compatible with the current PyTorch installation.
The current PyTorch install supports CUDA capabilities sm_50 sm_60 sm_70 sm_75 sm_80 sm_86 sm_90.
他のBlackwell GeForce の場合は以下のようなメッセージとなります。
NVIDIA GeForce RTX 5080 with CUDA capability sm_120 is not compatible with the current PyTorch installation.
The current PyTorch install supports CUDA capabilities sm_50 sm_60 sm_70 sm_75 sm_80 sm_86 sm_90.
NVIDIA GeForce RTX 5070 with CUDA capability sm_120 is not compatible with the current PyTorch installation.
The current PyTorch install supports CUDA capabilities sm_50 sm_60 sm_70 sm_75 sm_80 sm_86 sm_90.
NVIDIA GeForce RTX 5060 with CUDA capability sm_120 is not compatible with the current PyTorch installation.
The current PyTorch install supports CUDA capabilities sm_50 sm_60 sm_70 sm_75 sm_80 sm_86 sm_90.
NVIDIA GeForce RTX 5060Ti with CUDA capability sm_120 is not compatible with the current PyTorch installation.
The current PyTorch install supports CUDA capabilities sm_50 sm_60 sm_70 sm_75 sm_80 sm_86 sm_90.
これは、PyTorch 2.6.0 が Capabiility Level SM_90 までしかサポートしていないことにより発生しますので、 PyTorch を最新版にする必要があります。
なお、GPU(Capability Level)ごとのPyTorchサポートについては以下の記事で確認できます
●PyTorchバージョンとNVIDIA GPU Compute Capability Level サポート
https://blog.qualiteg.com/pytorch_and_supported_gpu_version/
最新のPyTorch ( PyTorch 2.8.0)を導入する
本稿執筆時点(2025/9/10)の最新のStable版PyTorch は 2.8.0 となっていますので、そちらを導入します。
RTX 5070Ti 等のSM_120のCapability を持っているGPU対応CUDAは13.0ですが、現時点でまだ CUDA13.0用のPyTorchはリリースされていませんので、ここでは、CUDA 12.8 対応の最新PyTorch v2.8.0 を導入します。
既存のPyTorchをアンインストールする
pip uninstall torch torchaudio torchvision
最新のPyTorchをインストール
pip install torch2.8.0+cu128 torchvision0.23.0+cu128 torchaudio==2.8.0+cu128 --index-url https://download.pytorch.org/whl/cu128
これで、最新のGeForce 50シリーズで動作するようになりました!