我正在名为
nvcr.io/nvidia/pytorch:22.09-py3
的图像上使用 docker 容器。
在容器中,我制作了一个
venv
并安装了torch
。
由于我的 NVIDIA 驱动程序版本是 11.8,因此我使用
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
作为安装命令。
(我从这里得到,https://pytorch.org/)
但它在下面显示了一个错误。
Python 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:04:10)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/root/HF/.HF/lib/python3.8/site-packages/torch/__init__.py", line 1119, in <module>
from ._tensor import Tensor
File "/root/HF/.HF/lib/python3.8/site-packages/torch/_tensor.py", line 12, in <module>
import torch.utils.hooks as hooks
File "/root/HF/.HF/lib/python3.8/site-packages/torch/utils/__init__.py", line 5, in <module>
from .cpp_backtrace import get_cpp_backtrace
File "/root/HF/.HF/lib/python3.8/site-packages/torch/utils/cpp_backtrace.py", line 1, in <module>
from torch._C import _get_cpp_backtrace
ImportError: cannot import name '_get_cpp_backtrace' from 'torch._C' (/root/HF/.HF/lib/python3.8/site-packages/torch/_C.cpython-38-x86_64-linux-gnu.so)
是因为容器上有一些自然粘合的火炬版本吗?
不使用时可以找到原来安装的手电筒
venv
。
(我个人认为不是这个原因)
Python 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:04:10)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.__version__)
1.13.0a0+d0d6b1f
有机构解决这个问题吗?我也遇到了同样的问题,请给我一些建议,谢谢!