请知悉:本文最近一次更新为 5个月 前,文中内容可能已经过时。

承接之前的文章,其中ocr用到了easyocr组件,运行脚本的时候,碰到了提升:

Neither CUDA nor MPS are available - defaulting to CPU. Note: This module is much faster with a GPU.

对于不是很了解Python的我来说,首先想到的是修改脚本里调用方式,原始代码:

easyocr.Reader(['en'], gpu=False)

我改成了:

easyocr.Reader(['en'], gpu=True)

结果依然只能用CPU识别,搜了下,发现原来是这个依赖如果要用GPU的话,需要通过正确的指令安装带CUDA的库才可以。

通过PyTorch官网Install PyTorch的部分,我得到了安装指令:

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

安装成功后,再指定gpu=True就可以正常工作了。


参考资料

Neither CUDA nor MPS are available – defaulting to CPU. Note: This module is much faster with a GPU.

Install PyTorch


如您从本文得到了有价值的信息或帮助,请考虑扫描文末二维码捐赠和鼓励。

尊重他人劳动成果。转载请务必附上原文链接,我将感激不尽。


与《Python Neither CUDA nor MPS are available – defaulting to CPU. Note: This module is much faster with a GPU. 解决方案》相关的博文:


留言

avatar
😀
😀😁😂😅😭🤭😋😘🤔😰😱🤪💪👍👎🤝🌹👌