下記のCOGMENのgithubを参考にインストールしています。
https://github.com/Exploration-Lab/COGMEN
WSL2環境からUbuntu-20.04により、pytorchをインストールしています。
PyTorch1.12.1、Linux、Conda、Python、CPUを選択し、
conda install pytorch torchvision torchaudio cpuonly -c pytorchを実行しました。
COGMENの環境の作成なので、
conda install pyg -c pygを実施しました。
python -c "import torch; print(torch.version.cuda)"コマンドを実施して
Noneが返ってきます。
CUDAをインストールする方法は、分かりますか。
> PyTorch1.12.1、Linux、Conda、Python、CPUを選択し、
gpuを使いたいなら、
https://pytorch.org/get-started/locally/
で選択するのは「CPU」ではなく「CUDA...(どれか)」です
参考
https://www.kkaneko.jp/tools/wsl/wsl_tensorflow2.html
> CUDAをインストールする方法は、分かりますか。
https://discuss.pytorch.org/t/install-pytorch-for-cuda-11-3-with-pip/152299
のptrblckさんの最初のコメントに
「The pip wheels and conda binaries ship with their own CUDA runtime as well as cuDNN, NCCL etc. and won’t be using the system CUDA toolkit.」
と書かれてるので、
https://pytorch.org/get-started/locally/
で「CUDA...(どれか)」を選択したら表示されるインストールコマンドを実行して、pipかcondaで普通にインストールする場合は、OS(wsl上のlinux)にインストールされてるcudaは使われないはずなので、OS(wsl上のlinux)に別途cudaをインストールする必要は無いと思います
https://www.kkaneko.jp/tools/wsl/wsl_tensorflow2.html
に書かれてる手順でも、pytorchの為にはcudaはインストールしてませんよね
windowsにドライバはインストールしてますが
(tensorflowを入れる場合は、cudaをインストールする必要があります)
どんな場合にOSに別途cudaをインストールしないといけないのかは、
https://discuss.pytorch.org/t/install-pytorch-for-cuda-11-3-with-pip/152299
のptrblckさんの二番目のコメントに書かれてます
「The system-wide installed CUDA toolkit will be used if you are building PyTorch from source or a custom CUDA extenstion.」
参考
https://torch.classcat.com/2018/05/22/pytorch-tutorial-advanced-cpp-extension/
jbpb0 さん
ありがとうございます。
下記のリンクから見ると、このようなものがあります。
https://pytorch-geometric.readthedocs.io/en/latest/notes/installation.html
pip install torch-scatter -f https://data.pyg.org/whl/torch-${TORCH}+${CUDA}.html
pip install torch-sparse -f https://data.pyg.org/whl/torch-${TORCH}+${CUDA}.html
pip install torch-geometric
ここで${CUDA}、 および${TORCH}は、それぞれ特定の CUDA バージョン ( cpu、cu102、) および PyTorch バージョン ( cu113、 )に置き換える必要があります。たとえば、PyTorch 1.12.* および CUDA 11.6 の場合、次のように入力します。
python -c "import torch; print(torch.version.cuda)"に、cpuが返ってくると、
予想しました。とすると、${CUDA}.にはcpuですかね。
pip install torch-scatter -f https://data.pyg.org/whl/torch-${TORCH}+${CUDA}.html
> ${CUDA}.にはcpuですかね。
https://pytorch-geometric.readthedocs.io/en/latest/notes/installation.html
の「INSTALLATION」の「Quick Start」で、「CPU」を選んだら「Run:」に
pip install torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f https://data.pyg.org/whl/torch-1.12.0+cpu.html
と表示されますので、gpuを使わなくてもいいならそうでしょうね
gpuを使う場合は、
https://pytorch.org/get-started/locally/
と
https://pytorch-geometric.readthedocs.io/en/latest/notes/installation.html
で、どちらも同じcudaのバージョンを選んで、それぞれ表示されるコマンドを実行したらいいのではないですかね
jbpb0さん
大変、参考になりました。ありがとうございます。
https://pytorch-geometric.readthedocs.io/en/latest/notes/installation.html
の「INSTALLATION」の「Quick Start」について、初期がCPUになっていたので、
それでないと、だめだと思いました。そのような事ではないのですね。

回答1件
あなたの回答
tips
プレビュー