CnOCR
CnOCR copied to clipboard
调用gpu预测
我通过pip install cnocr -i https://pypi.doubanio.com/simple 和
pip install onnxruntime==1.15 -i https://pypi.doubanio.com/simple
现在使用没有任何问题,但是cpu占用达到了100%
当我尝试使用gpu版本,我的cuda版本是11.8,我首先卸载了onnxruntime
然后pip install cnocr[ort-gpu] -i https://mirrors.aliyun.com/pypi/simple
通过这样去加载ocr = CnOcr(cand_alphabet="0123456789")
这时候程序给了我一个警告,
[ 0 ; 9 3 m 2 0 2 4 - 0 5 - 0 6 1 9 : 4 4 : 5 3 . 8 7 2 5 9 6 6 [ W : o n n x r u n t i m e : , t r a n s f o r m e r _ m e m c p y . c c : 7 4 o n n x r u n t i m e : : M e m c p y T r a n s f o r m e r : : A p p l y I m p l ] 1 M e m c p y n o d e s a r e a d d e d t o t h e g r a p h t o r c h _ j i t f o r C U D A E x e c u t i o n P r o v i d e r . I t m i g h t h a v e n e g a t i v e i m p a c t o n p e r f o r m a n c e ( i n c l u d i n g u n a b l e t o r u n C U D A g r a p h ) . S e t s e s s i o n _ o p t i o n s . l o g _ s e v e r i t y _ l e v e l = 1 t o s e e t h e d e t a i l l o g s b e f o r e t h i s m e s s a g e . [ m [ 0 ; 9 3 m 2 0 2 4 - 0 5 - 0 6 1 9 : 4 4 : 5 8 . 9 2 4 3 1 3 4 [ W : o n n x r u n t i m e : D e f a u l t , t e n s o r r t _ e x e c u t i o n _ p r o v i d e r . h : 8 3 o n n x r u n t i m e : : T e n s o r r t L o g g e r : : l o g ] [ 2 0 2 4 - 0 5 - 0 6 1 1 : 4 4 : 5 8 W A R N I N G ] C U D A l a z y l o a d i n g i s n o t e n a b l e d . E n a b l i n g i t c a n s i g n i f i c a n t l y r e d u c e d e v i c e m e m o r y u s a g e a n d s p e e d u p T e n s o r R T i n i t i a l i z a t i o n . S e e " L a z y L o a d i n g " s e c t i o n o f C U D A d o c u m e n t a t i o n h t t p s : / / d o c s . n v i d i a . c o m / c u d a / c u d a - c - p r o g r a m m i n g - g u i d e / i n d e x . h t m l # l a z y - l o a d i n g [ m
经过查询我加入了os.environ['CUDA_MODULE_LOADING'] = 'LAZY'去掉了,但是这似乎没什么关系。因为我也尝试过没加。
当使用gpu的时候,加载时间会非常长,而且预测有时也会耗时很长,有时又好的,这是什么问题