xiaofengShi / CHINESE-OCR

[python3.6] 运用tf实现自然场景文字检测,keras/pytorch实现ctpn+crnn+ctc实现不定长场景文字OCR识别
2.92k stars 964 forks source link

配置了四五天都还没成功,麻了,提示大概是Blas GEMM launch failed #174

Open 1Dreamer666 opened 1 year ago

1Dreamer666 commented 1 year ago

PS C:\Users\Pondsi\Downloads\temp\CHINESE-OCR-master> & C:/builds/anaconda/envs/tensorflow/python.exe c:/Users/Pondsi/Downloads/temp/CHINESE-OCR-master/demo.py Using TensorFlow backend. C:\builds\anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\framework\dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint8 = np.dtype([("qint8", np.int8, 1)]) C:\builds\anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\framework\dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint8 = np.dtype([("quint8", np.uint8, 1)]) C:\builds\anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\framework\dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint16 = np.dtype([("qint16", np.int16, 1)]) C:\builds\anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\framework\dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint16 = np.dtype([("quint16", np.uint16, 1)]) C:\builds\anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\framework\dtypes.py:521: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint32 = np.dtype([("qint32", np.int32, 1)]) C:\builds\anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\framework\dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. np_resource = np.dtype([("resource", np.ubyte, 1)]) Tensor("Placeholder:0", shape=(?, ?, ?, 3), dtype=float32) Tensor("conv5_3/conv5_3:0", shape=(?, ?, ?, 512), dtype=float32) Tensor("rpn_conv/3x3/rpn_conv/3x3:0", shape=(?, ?, ?, 512), dtype=float32) WARNING:tensorflow:From C:\builds\anaconda\envs\tensorflow\lib\site-packages\tensorflow\contrib\learn\python\learn\datasets\base.py:198: retry (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version. Instructions for updating: Use the retry module or similar alternatives. Tensor("lstm_o/Reshape_2:0", shape=(?, ?, ?, 512), dtype=float32) Tensor("lstm_o/Reshape_2:0", shape=(?, ?, ?, 512), dtype=float32) Tensor("rpn_cls_score/Reshape_1:0", shape=(?, ?, ?, 20), dtype=float32) Tensor("rpn_cls_prob:0", shape=(?, ?, ?, ?), dtype=float32) Tensor("Reshape_2:0", shape=(?, ?, ?, 20), dtype=float32) Tensor("rpn_bbox_pred/Reshape_1:0", shape=(?, ?, ?, 40), dtype=float32) Tensor("Placeholder_1:0", shape=(?, 3), dtype=float32) 2023-10-04 11:17:17.456323: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 2023-10-04 11:17:17.611372: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1344] Found device 0 with properties: name: NVIDIA GeForce RTX 3060 Laptop GPU major: 8 minor: 6 memoryClockRate(GHz): 1.702 pciBusID: 0000:01:00.0 totalMemory: 6.00GiB freeMemory: 5.01GiB 2023-10-04 11:17:17.611968: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1423] Adding visible gpu devices: 0 2023-10-04 11:17:18.040100: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:911] Device interconnect StreamExecutor with strength 1 edge matrix: 2023-10-04 11:17:18.040344: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:917] 0 2023-10-04 11:17:18.040582: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:930] 0: N 2023-10-04 11:17:18.040833: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1041] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 4914 MB memory) -> physical GPU (device: 0, name: NVIDIA GeForce RTX 3060 Laptop GPU, pci bus id: 0000:01:00.0, compute capability: 8.6) Tensor_name is : lstm_o/bidirectional_rnn/bw/lstm_cell/kernel Tensor_name is : conv1_1/biases Tensor_name is : conv3_1/biases Tensor_name is : conv1_1/weights Tensor_name is : conv1_2/biases Tensor_name is : conv1_2/weights Tensor_name is : conv2_1/weights Tensor_name is : conv4_3/weights Tensor_name is : conv2_1/biases Tensor_name is : conv2_2/biases Tensor_name is : conv2_2/weights Tensor_name is : conv3_1/weights Tensor_name is : conv3_2/biases Tensor_name is : conv3_2/weights Tensor_name is : conv3_3/biases Tensor_name is : conv3_3/weights Tensor_name is : conv4_1/biases Tensor_name is : rpn_conv/3x3/biases Tensor_name is : conv4_1/weights Tensor_name is : conv4_2/biases Tensor_name is : conv4_2/weights Tensor_name is : conv4_3/biases Tensor_name is : conv5_1/biases Tensor_name is : conv5_1/weights Tensor_name is : conv5_2/biases Tensor_name is : conv5_2/weights Tensor_name is : conv5_3/biases Tensor_name is : conv5_3/weights Tensor_name is : lstm_o/biases Tensor_name is : lstm_o/bidirectional_rnn/bw/lstm_cell/bias Tensor_name is : lstm_o/bidirectional_rnn/fw/lstm_cell/bias Tensor_name is : lstm_o/bidirectional_rnn/fw/lstm_cell/kernel Tensor_name is : lstm_o/weights Tensor_name is : rpn_bbox_pred/weights Tensor_name is : rpn_bbox_pred/biases Tensor_name is : rpn_cls_score/biases Tensor_name is : rpn_cls_score/weights Tensor_name is : rpn_conv/3x3/weights load vggnet done 2023-10-04 11:17:19.301524: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1423] Adding visible gpu devices: 0 2023-10-04 11:17:19.301815: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:911] Device interconnect StreamExecutor with strength 1 edge matrix: 2023-10-04 11:17:19.302066: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:917] 0 2023-10-04 11:17:19.302267: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:930] 0: N 2023-10-04 11:17:19.302464: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1041] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 4914 MB memory) -> physical GPU (device: 0, name: NVIDIA GeForce RTX 3060 Laptop GPU, pci bus id: 0000:01:00.0, compute capability: 8.6) The angel of this character is: 0 Rotate the array of this img! 2023-10-04 11:17:22.792416: W T:\src\github\tensorflow\tensorflow\core\common_runtime\bfc_allocator.cc:219] Allocator (GPU_0_bfc) ran out of memory trying to allocate 2.83GiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available. 2023-10-04 11:17:22.792834: W T:\src\github\tensorflow\tensorflow\core\common_runtime\bfc_allocator.cc:219] Allocator (GPU_0_bfc) ran out of memory trying to allocate 2.83GiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available. 2023-10-04 11:17:23.319220: E T:\src\github\tensorflow\tensorflow\stream_executor\cuda\cuda_blas.cc:654] failed to run cuBLAS routine cublasSgemm_v2: CUBLAS_STATUS_EXECUTION_FAILED Traceback (most recent call last): File "C:\builds\anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1327, in _do_call return fn(*args) File "C:\builds\anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1312, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File "C:\builds\anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1420, in _call_tf_sessionrun status, run_metadata) File "C:\builds\anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 516, in exit c_api.TF_GetCode(self.status.status)) tensorflow.python.framework.errors_impl.InternalError: Blas GEMM launch failed : a.shape=(5115, 256), b.shape=(256, 512), m=5115, n=512, k=256 [[Node: lstm_o/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/device:GPU:0"](lstm_o/Reshape_1, lstm_o/weights/read/_153)]] [[Node: rpn_bbox_pred/Reshape_1/_165 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_490_rpn_bbox_pred/Reshape_1", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "c:/Users/Pondsi/Downloads/temp/CHINESE-OCR-master/demo.py", line 21, in img, model='keras', adjust=True, detectAngle=True) File "c:\Users\Pondsi\Downloads\temp\CHINESE-OCR-master\model.py", line 114, in model text_recs, tmp, img=text_detect(img) File "c:\Users\Pondsi\Downloads\temp\CHINESE-OCR-master\ctpn\text_detect.py", line 13, in text_detect scores, boxes, img = ctpn(img) File "c:\Users\Pondsi\Downloads\temp\CHINESE-OCR-master\ctpn\ctpn\model.py", line 63, in ctpn scores, boxes = test_ctpn(sess, net, img) File "c:\Users\Pondsi\Downloads\temp\CHINESE-OCR-master\ctpn\lib\fast_rcnn\test.py", line 76, in test_ctpn rois = sess.run([net.get_output('rois')[0]], feed_dict=feed_dict) File "C:\builds\anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 905, in run run_metadata_ptr) File "C:\builds\anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1140, in _run feed_dict_tensor, options, run_metadata) File "C:\builds\anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1321, in _do_run run_metadata) File "C:\builds\anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1340, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InternalError: Blas GEMM launch failed : a.shape=(5115, 256), b.shape=(256, 512), m=5115, n=512, k=256 [[Node: lstm_o/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/device:GPU:0"](lstm_o/Reshape_1, lstm_o/weights/read/_153)]] [[Node: rpn_bbox_pred/Reshape_1/_165 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_490_rpn_bbox_pred/Reshape_1", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]

Caused by op 'lstm_o/MatMul', defined at: File "c:/Users/Pondsi/Downloads/temp/CHINESE-OCR-master/demo.py", line 8, in import model File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 665, in _load_unlocked File "", line 678, in exec_module File "", line 219, in _call_with_frames_removed File "c:\Users\Pondsi\Downloads\temp\CHINESE-OCR-master\model.py", line 15, in from ctpn.text_detect import text_detect File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 665, in _load_unlocked File "", line 678, in exec_module File "", line 219, in _call_with_frames_removed File "c:\Users\Pondsi\Downloads\temp\CHINESE-OCR-master\ctpn\text_detect.py", line 4, in from .ctpn.model import ctpn File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 665, in _load_unlocked File "", line 678, in exec_module File "", line 219, in _call_with_frames_removed File "c:\Users\Pondsi\Downloads\temp\CHINESE-OCR-master\ctpn\ctpn\model.py", line 52, in sess, saver, net = load_tf_model() File "c:\Users\Pondsi\Downloads\temp\CHINESE-OCR-master\ctpn\ctpn\model.py", line 32, in load_tf_model net = get_network("VGGnet_test") File "c:\Users\Pondsi\Downloads\temp\CHINESE-OCR-master\ctpn\lib\networks\factory.py", line 9, in get_network return VGGnet_test() File "c:\Users\Pondsi\Downloads\temp\CHINESE-OCR-master\ctpn\lib\networks\VGGnet_test.py", line 23, in init self.setup() File "c:\Users\Pondsi\Downloads\temp\CHINESE-OCR-master\ctpn\lib\networks\VGGnet_test.py", line 52, in setup (self.feed('rpn_conv/3x3').Bilstm(512, 128, 512, name='lstm_o')) File "c:\Users\Pondsi\Downloads\temp\CHINESE-OCR-master\ctpn\lib\networks\network.py", line 24, in layer_decorated layer_output = op(self, layer_input, *args, **kwargs) File "c:\Users\Pondsi\Downloads\temp\CHINESE-OCR-master\ctpn\lib\networks\network.py", line 115, in Bilstm outputs = tf.matmul(lstm_out, weights) + biases File "C:\builds\anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\ops\math_ops.py", line 2108, in matmul a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name) File "C:\builds\anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 4492, in mat_mul name=name) File "C:\builds\anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "C:\builds\anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 3290, in create_op op_def=op_def) File "C:\builds\anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 1654, in init self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

InternalError (see above for traceback): Blas GEMM launch failed : a.shape=(5115, 256), b.shape=(256, 512), m=5115, n=512, k=256 [[Node: lstm_o/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/device:GPU:0"](lstm_o/Reshape_1, lstm_o/weights/read/_153)]] [[Node: rpn_bbox_pred/Reshape_1/_165 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_490_rpn_bbox_pred/Reshape_1", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]