属性错误:模块'torch'没有属性'__version__'



我试着检查火炬是否已被脚本正确安装:

import torch
print(torch.__version__) 

并得到结果:AttributeError:模块'torch'没有属性'version'

我已经检查了火炬是否安装在我的venv:

pip freeze

并安装了它(我尝试通过conda安装,通过pip安装,建议在https://pytorch.org/):

  • 火炬= = 1.7.1上+ cu110
  • torchaudio = = 0.7.2
  • torchvision = = 0.8.2 + cu110
  • 环境:

  • OS: Ubuntu 18.04
  • GPU Geforce RTX 3070
  • 驱动程序版本460.39
  • Cuda Toolkit V11.0.194
  • Cudnn V8.0.5.39
  • Python V3.6.9

不明白是什么问题

Pytorch有一个叫做version的子模块,你可以在里面写
torch.version.__version__

我也遇到了同样的问题,这与一个安装不良的torch版本有关。

只有pip uninstall torchpip install torch==2.0.0+cu117对我有效。

它应该也适用于另一个火炬版本。

最新更新