Pytorch出现错误Attribute Error: module ‘torch‘ has no attribute ‘_six‘

这篇具有很好参考价值的文章主要介绍了Pytorch出现错误Attribute Error: module ‘torch‘ has no attribute ‘_six‘。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

1. 问题描述:我是在VScode中使用jupyter拓展,远程连接服务器。

2. torch版本:2.0

3. pytorch版本: 1.9.1

4. 问题原因:torch 2.0版本以后中没有 ‘_six.py’ 文件

5. 如何查看torch中的py文件?
我是用的anaconda,torch中的py文件位置为:

/envs/环境名/lib/python版本号(比如:python3.8)/site-packages/torch

Pytorch出现错误Attribute Error: module ‘torch‘ has no attribute ‘_six‘
6. 解决办法
(1)我第一开始试着把torch1.9中的’_six.py’文件复制到torch2.0中,发现还是不行(不知道为啥,有大佬能解释一下吗?)
然后我又重新装了torch1.9.1,问题解决了!
步骤如下:

pip uninstall torch
pip install torch==1.9.1

Tips: 如果在步骤5中发现有’_six.py’文件,可以点击重启jupyter kernel即可解决。
Pytorch出现错误Attribute Error: module ‘torch‘ has no attribute ‘_six‘文章来源地址https://www.toymoban.com/news/detail-504909.html

到了这里,关于Pytorch出现错误Attribute Error: module ‘torch‘ has no attribute ‘_six‘的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • AttributeError: module ‘torch‘ has no attribute ‘concat‘

        如图上所示报错地方 在跑算法代码的时候,发现报错,但是这个错误在网上没有找到,我推测是pytorch改版问题,于是查看torch版本改动,发现torch.concat改版后该写为torch.cat。不过或许我写的也不够准确,除此之外还看到了有人问torch.concat和torch.cat的区别。     不过出现

    2024年02月16日
    浏览(42)
  • 完美解决 AttributeError: module ‘torch.utils‘ has no attribute ‘data‘

    完美解决 AttributeError: module ‘torch.utils’ has no attribute ‘data’ 下滑查看解决方法 AttributeError: module ‘torch.utils‘ has no attribute ‘data‘ 这个错误通常是由于使用了过时的torch版本导致的。在旧的torch版本中,torch.utils.data模块是存在的,但在新版的torch中已经被移除,因此会出现

    2024年02月07日
    浏览(37)
  • 将图结构转换矩阵数据转换为PyTorch支持的张量类型时,出现错误AttributeError ‘Tensor‘ object has no attribute ‘todense‘

    将图结构转换矩阵数据转换为PyTorch支持的张量类型时,出现错误AttributeError: ‘Tensor’ object has no attribute ‘todense’ 实例来源于《PyTorch深度学习和图神经网络 卷1》实例26:用图卷积神经网络为论文分类 出错部分p284页 原代码: 错误提示: ​ 找了一圈没有一样的解决方案,但

    2024年02月13日
    浏览(35)
  • AttributeError: module ‘torch.nn‘ has no attribute ‘SiLU‘问题的解决办法

    AttributeError: module \\\'torch.nn\\\' has no attribute \\\'SiLU\\\'        这个问题的原因是这个版本的torch中的torch.nn函数表里面没有这个SiLU函数,需要更高版本的torch,在官方的文档中我们就可以查看这个版本里有没有包含这个模块。 官方文档1.1.0    红框选择 torch 版本,我的版本是1.1.0,搜

    2024年02月13日
    浏览(44)
  • python, torch. 遇到AttributeError: module ‘distutils‘ has no attribute ‘version‘ 报错。

    1.已经安装了pip install tensorboard 出现报错   在使用torch.utils.tensorboard时,出现错误:   出错语句 from torch.utils.tensorboard import SummaryWriter   AttributeError: module \\\'distutils\\\' has no attribute \\\'version\\\' 2.问题原因 当前tensorboard的版本和你安装的pytorch版本不匹配,tensorboard版本太      高,

    2024年02月11日
    浏览(32)
  • AttributeError: module ‘torch.distributed‘ has no attribute ‘_all_gather_base‘

    安装完apex后,调用的是时候出现如下错误: 注释下面的代码: 路径: apex/contrib/optimizers/distributed_fused_lamb.py apex/transformer/tensor_parallel/layers.py apex/transformer/tensor_parallel/utils.py apex/transformer/tensor_parallel/mappings.py 接下来添加环境变量。 执行命令 vi ~/.bashrc 打开文件,然后,按 i

    2024年02月12日
    浏览(49)
  • Langchain module ‘hnswlib‘ has no attribute ‘Index‘ 错误解决

    使用 Langchain 操作 Chroma 向量数据库时,报一下错误信息, 试着重装了不同 hnswlib 版本没有解决,最后解决方法是,不要使用 hnswlib,使用 chroma-hnswlib, 完结!

    2024年02月13日
    浏览(33)
  • 关于 【AttributeError: module ‘collections‘ has no attribute ‘Mapping‘】出现的问题

           这个错误通常是由于在Python 3.9或更高版本中,从以上图片中看到的版本是Python3.11,`collections.Mapping`被删除所致。如果使用的是旧版本的代码,可能会导致此错误。解决此问题的方法是将代码中的`Mapping`替换为`abc.Mapping`。 例如,将以下代码:   替换为: 这将导入`

    2024年02月11日
    浏览(38)
  • AttributeError: module ‘openai‘ has no attribute ‘error‘解决方案

      大家好,我是爱编程的喵喵。双985硕士毕业,现担任全栈工程师一职,热衷于将数据思维应用到工作与生活中。从事机器学习以及相关的前后端开发工作。曾在阿里云、科大讯飞、CCF等比赛获得多次Top名次。现为CSDN博客专家、人工智能领域优质创作者。喜欢通过博客创作

    2024年01月17日
    浏览(35)
  • 解决Python中module ‘numpy‘ has no attribute ‘bool‘错误

    解决Python中module ‘numpy’ has no attribute \\\'bool’错误 在使用Python进行科学计算和数据处理时,NumPy是一个常用的库。它提供了高性能的数组操作和数学函数。然而,有时你可能会遇到一个错误,即\\\"module ‘numpy’ has no attribute ‘bool’\\\"。本文将详细解释这个错误的原因,并提供解

    2024年02月08日
    浏览(27)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包