当前位置:首页 » 《随便一记》 » 正文

关于安装 PyTorch-Lightning 的一些问题(GPU版)

22 人参与  2023年05月04日 12:02  分类 : 《随便一记》  评论

点击全文阅读


官网地址:

PyTorch

PyTorch-Lightning

安装PyTorch-Lightning

1、不能直接使用pip install pytorch-lightning ,否则如下图会直接卸载掉你的torch而安装cpu版本的torch。

Installing collected packages: torch, lightning_fabric  Attempting uninstall: torch    Found existing installation: torch 1.9.1+cu111    Uninstalling torch-1.9.1+cu111:      Successfully uninstalled torch-1.9.1+cu111

2、在安装pytorch-lightning时一定注意自己的torch是pip安装还是conda安装,两者要保持一致,否则也会导致你的torch版本被替换。

正确安装方式:pip install pytorch-lightning==版本名

验证PyTorch和PyTorch-Lightning版本

 在Python中导入PyTorch,然后打印出其版本号来查看,示例代码如下:

import torchprint(torch.__version__)

使用以下代码来查看已安装的 PyTorch-Lightning 版本: 

import pytorch_lightning as plprint(pl.__version__)

验证GPU是否能用

import torchif torch.cuda.is_available():    print("CUDA is available")else:    print("CUDA is not available")
import pytorch_lightning as plprint(pl._C.has_cuda) # will print True if GPU is supported, False otherwise

 一些报错解决:

import pytorch_lightning出现的报错:

 ImportError: cannot import name ‘get_num_classes’ from ‘torchmetrics.utilities.data’

根据参考  ImportError: cannot import name ‘get_num_classes’ from ‘torchmetrics.utilities.data’在虚拟环境下执行下面命令

pip uninstall torchmetricspip install torchmetrics==0.5

 然而,出现了新的报错

AttributeError: module 'distutils' has no attribute 'version'

根据参考python, torch. 遇到AttributeError: module ‘distutils‘ has no attribute ‘version‘ 报错。和AttributeError: module ‘distutils‘ has no attribute ‘version‘ 解决方案

在虚拟环境下执行下面命令

pip install setuptools==59.5.0

再次尝试,报错解决

参考文章:

pytorch-lightning安装

安装 pytorch-lightning 的坑

 ImportError: cannot import name ‘get_num_classes’ from ‘torchmetrics.utilities.data’

 python, torch. 遇到AttributeError: module ‘distutils‘ has no attribute ‘version‘ 报错。

 AttributeError: module ‘distutils‘ has no attribute ‘version‘ 解决方案

AttributeError: module 'distutils' has no attribute 'version'


点击全文阅读


本文链接:http://m.zhangshiyu.com/post/60635.html

<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

最新文章

  • 苔藓爬满旧日诺言全书+后续+结局顾砚廷慕晚夏免费苔藓爬满旧日诺言全书+后续+结局顾砚廷慕晚夏全书全
  • [我掉蛇女马甲后,点天灯假死丈夫悔疯了]免费试读_婆婆丁若菱蛇女精彩节选推荐
  • 他日若是同淋雪结局+番外(夏尔若林闻舟)他日若是同淋雪结局+番外结局_夏尔若林闻舟列表_笔趣阁(他日若是同淋雪结局+番外)
  • 他心非石反转剧情试读片段_安茗宝宝心掏后续更新+番外
  • 许星森纪冰雪(日暮青山绿渐隐许星森纪冰雪结局+番外)_(许星森纪冰雪)列表_笔趣阁(日暮青山绿渐隐许星森纪冰雪结局+番外)
  • 全文潮痕蚀月光(池清禾***宸)列表_全文潮痕蚀月光
  • 「江月随人处处圆」小说无删减版在线免费阅读_[陆晨小姐孟苒]精彩章节免费试读
  • 阮雾梨闻砚辞阮见微结局+番外全书+后续+结局(闻砚辞阮雾梨)列表_阮雾梨闻砚辞阮见微结局+番外(闻砚辞阮雾梨)阮雾梨闻砚辞阮见微结局+番外全书+后续+结局在线
  • 潮痕蚀月光结局+番外池清禾***宸(潮痕蚀月光结局+番外)全书免费池清禾***宸_潮痕蚀月光结局+番外池清禾***宸列表_笔趣阁(池清禾***宸)
  • 苔藓爬满旧日诺言一口气读完全书+后续全书+后续+结局(慕晚夏顾砚廷)列表_苔藓爬满旧日诺言一口气读完全书+后续(慕晚夏顾砚廷)苔藓爬满旧日诺言一口气读完全书+后续全书+后续+结局在线
  • 「孕弟」反转剧情碎片化试读_[耀祖弟弟子宫]小说精彩节选试读
  • 旧梦随风去结局+番外(姜予宁沈昭寒)列表_旧梦随风去结局+番外(姜予宁沈昭寒)全书+后续+结局在线

    关于我们 | 我要投稿 | 免责申明

    Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1