Paddle OCR gives "device id must be less than GPU count" error

Paddle OCR gives "device id must be less than GPU count" error

Problem Description:

I am trying to use Paddle OCR for reading numbers from images, but it gives me this error:

"(InvalidArgument) Device id must be less than GPU count, but received id is: 0. GPU count is: 0.
[Hint: Expected id < GetGPUDeviceCount(), but received id:0 >= GetGPUDeviceCount():0.] (at"

The error comes from this line of code : ocr = PaddleOCR(use_angle_cls=True, lang='en')

Does anyone know how to solve this issue? I can’t find the solution on the internet.

This is the code that I am using:

# 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:

# draw result
from PIL import Image
result = result[0]
image ='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)'result.jpg')` 

Solution – 1

Default value of PaddleOCR for GPU is True, you would need to disable it if you don’t have GPU.

ocr = PaddleOCR(use_angle_cls=True, lang='en', use_gpu=False)
Rate this post
We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.