tensorflow 桨OCR给出“设备ID必须小于GPU计数”错误

t2a7ltrp  于 2022-12-13  发布在  其他
关注(0)|答案(1)|浏览(547)

我尝试使用Paddle OCR从图像中阅读数字,但它给我这个错误:
“(InvalidArgument)装置识别码必须小于GPU计数,但收到的识别码为:0。GPU计数为:0. [提示:预期的id〈获取GPUDeviceCount(),但收到的id:0〉=获取GPUDeviceCount():0.](位于..\paddle\phi\backends\gpu\cuda\cuda_info.cc:242)”
错误来自以下代码行:ocr = PaddleOCR(use_angle_cls=True, lang='en')
有人知道如何解决这个问题吗?我在网上找不到解决方法。
这是我正在使用的代码:

# Paddleocr supports Chinese, English, French, German, Korean and Japanese.
# You can set the parameter `lang` as `ch`, `en`, `french`, `german`, `korean`, `japan`
# to switch the language model in order.
ocr = PaddleOCR(use_angle_cls=True, lang='en') # need to run only once to download and load model into memory
img_path = 'capture.png'
result = ocr.ocr(img_path, cls=True)
for idx in range(len(result)):
    res = result[idx]
    for line in res:
        print(line)

# draw result
from PIL import Image
result = result[0]
image = Image.open(img_path).convert('RGB')
boxes = [line[0] for line in result]
txts = [line[1][0] for line in result]
scores = [line[1][1] for line in result]
im_show = draw_ocr(image, boxes, txts, scores, font_path='/path/to/PaddleOCR/doc/fonts/simfang.ttf')
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')`
gab6jxml

gab6jxml1#

PaddleOCR for GPU的默认值为True,如果没有GPU,则需要禁用它。

ocr = PaddleOCR(use_angle_cls=True, lang='en', use_gpu=False)

相关问题