0
0

Windows11 cuda12.3 でpytorch のインストール

Last updated at Posted at 2024-05-11

いきなり結論

安定リリース2.3ではなく、Preview(2.4)をセットアップすることで解決しました(2024/05/11現在)

pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu121

image.png

2024/05/11 現在では、下記のように確認すると、

torch_test.py
import torch
print(torch.__version__)
print(torch.cuda.is_available())
print(torch.cuda.device_count())
print(torch.cuda.current_device())
ターミナル
2.4.0.dev20240510+cu121
True
1
0

と出力されました。(2.4previewが入った模様)

環境

  • windows11
  • python3.11(Windowsストアからセットアップ)
  • cuda12.3

PyTorch stable2.3 をpipでインストールすると、'指定されたモジュールが見つかりません。'

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
で上記のtorch_test.pyを実行すると、

ターミナル
    import torch
  File "C:\Users\ユーザ名\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\torch\__init__.py", line 142, in <module>
    raise err
OSError: [WinError 126] 指定されたモジュールが見つかりません。 Error loading "C:\Users\ユーザ名\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\torch\lib\shm.dll" or one of its dependencies.

でも、指定のパスを確認すると、shm.dllは存在していました。(あるぇ?)

エラー内容で検索してみたところ

どうも最近修正されたみたいです。
https://github.com/pytorch/pytorch/issues/125109
https://github.com/pytorch/pytorch/pull/125684

なのでいったんStable2.3 をアンインストールし、Previewをインストールし、テストしてみたところ、問題なくテストコードが実行できました。

参考にさせていただきました。

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