热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

AssertionError:TorchnotcompiledwithCUDAenabled解決方案

在執行pytorch代碼的時候,突然看到報錯AssertionError:TorchnotcompiledwithCUDAenabled這說明了1.你pytoch确

在執行pytorch代碼的時候,突然看到報錯


AssertionError: Torch not compiled with CUDA enabled


這說明了

1. 你pytoch确实安装了

2. 你安装的是cpu版本

作为验证,你可以在python编辑器输入下列代码


 解决方案

首先,安装Nvidia toolkit

sudo apt install nvidia-cuda-toolkit

然后,你需要卸载pytorch,如下图。

conda uninstall pytorch

 否则,它可能只是更新不同的cpu版本,如下列截图。

 然后,再安装pytoch版本。注意,请确认自己电脑对应的cuda版本。如下图,对应的11,3.

conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch

注意,如果执行下列指令仍安装的是cpu版本,建议参考

Previous PyTorch Versions | PyTorch三An open source machine learning framework that accelerates the path from research prototyping to production deployment.

 最后,作为验证。

 Job Done.


推荐阅读
author-avatar
茴忆是抹不掉的伤
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有