AttributeError: module ‘torch‘ has no attribute ‘cuda‘

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

系统环境是Linux ,显卡:nvida-T4。

看了下原因为没有装pytorch。(印象中是装了的不知道什么时候这台服务器没有了。。)

解决方案:到pytorch官网上找到对应的cuda版本的pytorch安装即可

Previous PyTorch Versions | PyTorch

比如我的是cuda 10.2(使用nvcc -V命令查看)

那么就是使用以下命令安装——

conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=10.2 -c pytorch

 AttributeError: module ‘torch‘ has no attribute ‘cuda‘,pytorch,python

20231130-注:按官网的说法,cuda的版本和GPU的型号是有匹配关系的,但我后来发现安装torch的时候并不是强制要求。比如我这台T4的算力按官网的说法只支持到cuda 11.0, 但是我后来安装了适配cuda11.7的pytorch2.0也一样能跑。可以先大胆尝试一下 不行再删了重装。熟练了这个操作其实很快[狗头]。文章来源地址https://www.toymoban.com/news/detail-519628.html

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

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

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

相关文章

  • 完美解决 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日
    浏览(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日
    浏览(41)
  • 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日
    浏览(46)
  • 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文件位置为: 6. 解决办法 (1)我第一开始试着把torch1.9中的’

    2024年02月11日
    浏览(29)
  • AttributeError: module ‘distutils‘ has no attribute ‘version‘解决跑pytorch代码报错

    Traceback (most recent call last): File “D:/pycharm_envir/gaozhiyuan/Segmentation/pytorch_segmentation/deeplabv3-plus-pytorch-main/train.py”, line 16, in from utils.callbacks import LossHistory, EvalCallback File “D:pycharm_envirgaozhiyuanSegmentationpytorch_segmentationdeeplabv3-plus-pytorch-mainutilscallbacks.py”, line 17, in from torch.util

    2023年04月16日
    浏览(34)
  • Python AttributeError: module ‘distutils‘ has no attribute ‘version‘

    在安装或运行使用 PyTorch 的 Python 代码时,您可能会看到一个错误: 本文将帮助您理解发生此错误的原因以及如何解决此错误。 当你尝试从 distutils 模块访问 version 属性时发生此错误,如下所示: 发生此错误是因为 setuptools 版本59.6.0 中的更改以某种方式 中断了对 version 属性的

    2024年02月08日
    浏览(34)
  • python numpy 错误:AttributeError: module ‘numpy‘ has no attribute ‘bool‘

    跑代码(pyCUDA,pyTensorRT相关)的时候 numpy 报错 ”AttributeError: module \\\'numpy\\\' has no attribute \\\'bool\\\'“ 把 numpy 从 1.22.x 升级到 1.23.1 灵感来自于下面的回答 https://stackoverflow.com/questions/74893742/how-to-solve-attributeerror-module-numpy-has-no-attribute-bool

    2024年02月12日
    浏览(25)
  • 解决AttributeError: module ‘tensorflow.python.keras‘ has no attribute ‘Model‘

    目录 解决AttributeError: module \\\'tensorflow.python.keras\\\' has no attribute \\\'Model\\\' 引言 错误原因 解决方案 1. 升级TensorFlow版本 2. 正确导入模块 3. 检查其他依赖项 4. 重新安装TensorFlow 结论 实际应用场景: 引言 在使用TensorFlow的过程中,您可能会遇到各种错误。其中之一是​ ​AttributeError:

    2024年02月05日
    浏览(41)
  • python遇到AttributeError: module ‘XXX‘ has no attribute ‘XXX‘的错误,解决办法

    错误原因: 主要的原因看可能有3个: 1、检查一下有没有拼错函数,有时候写的快了真的有可能手误; 2、如果没拼错那就检测一下该模块的函数是否是更新了,因为python的第三方库是时常会更新的,有时候函数名会有轻微的变动这也很正常,解决方法就是查看一下对应版本

    2024年04月12日
    浏览(29)
  • 已解决(Python3.9异常)AttributeError: module ‘time‘ has no attribute ‘clock‘

    个人主页 : ζ小菜鸡 大家好我是ζ小菜鸡,今天让我们一起学习如何解决AttributeError: module ‘time‘ has no attribute ‘clock‘报错问题。 如果文章对你有帮助、 欢迎关注、点赞、收藏(一键三连) ζ小菜鸡想用time.clock()函数来测量程序执行时间,但是发生了报错,报错代码如下: 报

    2024年02月11日
    浏览(36)

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

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

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

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

二维码1

领取红包

二维码2

领红包