Arch Linux下通过Conda安装PyTorch Geometric失败求助
解决PyTorch Geometric安装失败问题
先明确:系统CUDA不影响虚拟环境
你系统里的CUDA 12.1完全不会干扰conda虚拟环境里的PyTorch运行。因为你通过conda install pytorch-cuda=11.7安装的是虚拟环境专属的CUDA工具包,PyTorch会优先使用环境内的CUDA,和系统级别的CUDA无关,这个问题可以排除。
解决PyG安装失败的具体步骤
1. 确认当前环境的PyTorch和CUDA版本
先运行以下命令,确认环境内的版本匹配:
python -c "import torch; print('Torch版本:', torch.__version__); print('CUDA版本:', torch.version.cuda)"
确保输出的CUDA版本是11.7,Torch版本对应(比如2.0.1+cu117这类)。
2. 改用Pip安装PyTorch Geometric
conda安装PyG出现404/JSON错误,大概率是PyG的conda通道没有适配你当前环境的Torch+CUDA+Arch Linux组合的预编译包。改用Pip安装更可靠,PyG官方提供了预编译的wheel包,会自动匹配当前环境:
步骤1:安装PyG依赖包
根据你确认的Torch和CUDA版本,执行对应命令:
- 如果Torch是2.0.x + CUDA 11.7:
pip install torch-scatter torch-sparse torch-cluster torch-spline-conv -f https://data.pyg.org/whl/torch-2.0.0+cu117.html
- 如果Torch是1.13.x + CUDA 11.7:
pip install torch-scatter torch-sparse torch-cluster torch-spline-conv -f https://data.pyg.org/whl/torch-1.13.0+cu117.html
步骤2:安装PyTorch Geometric核心包
依赖装完后,直接安装核心包:
pip install torch-geometric
3. 验证安装
安装完成后,运行以下命令验证:
python -c "import torch_geometric; print('PyG版本:', torch_geometric.__version__)"
如果能正常输出版本号,说明安装成功。
备选方案:从源码编译(如果Pip安装仍失败)
如果预编译wheel包不兼容Arch Linux,可尝试从源码编译:
pip install torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric --no-binary torch-scatter,torch-sparse,torch-cluster,torch-spline-conv
编译前确保你装了基础编译工具(Arch下用sudo pacman -S base-devel安装base-devel包组)。
内容的提问来源于stack exchange,提问作者nihil39
相关产品推荐
相关产品推荐

