Out of memory error on GPU 0
Created by: lele012
the memory of my gpu is 6000M
my code like this:
from paddleocr import PaddleOCR, draw_ocr from PIL import Image import datetime import os
os.environ['FLAGS_eager_delete_tensor_gb'] = "0.0" os.environ['FLAGS_fraction_of_gpu_memory_to_use'] = "1.0"
模型路径下必须含有model和params文件
ocr = PaddleOCR(use_gpu=True, gpu_mem=4000, det_model_dir='D:\AI\ocr\models\ch_ppocr_server_v1.1_det_infer', rec_model_dir='D:\AI\ocr\models\ch_ppocr_server_v1.1_rec_infer', rec_char_dict_path='D:\AI\ocr\dicts\ppocr_keys_v1.txt', cls_model_dir='D:\AI\ocr\models\ch_ppocr_mobile_v1.1_cls_infer', use_angle_cls=True) img_path = 'D:\AI\ocr\images\1.jpg' start = datetime.datetime.now() result = ocr.ocr(img_path) for line in result: print(line) end = datetime.datetime.now() print("总耗时:", (end-start).seconds)
the error is :
ResourceExhaustedError:
Out of memory error on GPU 0. Cannot allocate 121.078369MB memory on GPU 0, available memory is only 55.625000MB.
Please check whether there is any other process using GPU 0.
- If yes, please stop them, or start PaddlePaddle on another GPU.
- If no, please try one of the following suggestions:
- Decrease the batch size of your model.
- FLAGS_fraction_of_gpu_memory_to_use is 0.50 now, please set it to a higher value but less than 1.0.
The command is
export FLAGS_fraction_of_gpu_memory_to_use=xxx
.
at (D:\1.7.0\paddle\paddle\fluid\memory\detail\system_allocator.cc:151)