如何正确安装Pytorch?

发布于 2025-01-21 11:49:08 字数 1180 浏览 2 评论 0原文

导入Pytorch时,我会收到以下错误:

python -c "import torch; print(torch.version.cuda)"

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/vision/anaconda3/envs/psf/lib/python3.7/site-packages/torch/__init__.py", line 197, in <module>
    from torch._C import *  # noqa: F403
ImportError: /home/vision/anaconda3/envs/psf/lib/python3.7/site-packages/torch/lib/libtorch_cpu.so: 
undefined symbol: _ZNK3c1010TensorImpl23shallow_copy_and_detachERKNS_15VariableVersionEb

这些是相关的软件包版本:

我安装了Pytorch

pip3 install pytorch==1.10.1 torchvision==0.11.2 torchaudio==0.10.1 cudatoolkit==11.3 -f https://download.pytorch.org/whl/torch_stable.html

,我的CUDA版本是:

nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Mon_May__3_19:15:13_PDT_2021
Cuda compilation tools, release 11.3, V11.3.109
Build cuda_11.3.r11.3/compiler.29920130_0

请我需要帮助

I get the following error when importing pytorch:

python -c "import torch; print(torch.version.cuda)"

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/vision/anaconda3/envs/psf/lib/python3.7/site-packages/torch/__init__.py", line 197, in <module>
    from torch._C import *  # noqa: F403
ImportError: /home/vision/anaconda3/envs/psf/lib/python3.7/site-packages/torch/lib/libtorch_cpu.so: 
undefined symbol: _ZNK3c1010TensorImpl23shallow_copy_and_detachERKNS_15VariableVersionEb

These are the relevant package versions:
enter image description here

I installed pytorch through

pip3 install pytorch==1.10.1 torchvision==0.11.2 torchaudio==0.10.1 cudatoolkit==11.3 -f https://download.pytorch.org/whl/torch_stable.html

and my cuda version is:

nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Mon_May__3_19:15:13_PDT_2021
Cuda compilation tools, release 11.3, V11.3.109
Build cuda_11.3.r11.3/compiler.29920130_0

Please I need help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文