fizyr / keras-retinanet

Keras implementation of RetinaNet object detection.
Apache License 2.0
4.38k stars 1.96k forks source link

OOM when allocating tensor with shape[1,4500,100,134] #1499

Closed hei-my closed 3 years ago

hei-my commented 3 years ago

`

The model I am using is 'resnet152_oid_v1.0.0.h5', the code is 'examples/resnet50_retinanet.py'., can you help me? thanks!

Whenever the execution occurs, the OOM appears,

from keras_retinanet.models import load_model model = load_model('/path/to/model.h5', backbone_name='resnet50') boxes, scores, labels = model.predict_on_batch(np.expand_dims(image, axis=0))`

`2021-01-04 13:56:22.037701: I tensorflow/core/common_runtime/bfc_allocator.cc:1040] Sum Total of in-use chunks: 1.02GiB 2021-01-04 13:56:22.045240: I tensorflow/core/common_runtime/bfc_allocator.cc:1042] total_region_allocatedbytes: 1435228416 memorylimit: 1435228569 available bytes: 153 curr_region_allocationbytes: 2870457344 2021-01-04 13:56:22.058249: I tensorflow/core/common_runtime/bfc_allocator.cc:1048] Stats: Limit: 1435228569 InUse: 1099622912 MaxInUse: 1434610176 NumAllocs: 4248 MaxAllocSize: 397448192 Reserved: 0 PeakReserved: 0 LargestFreeBlock: 0

2021-01-04 13:56:22.079624: W tensorflow/core/common_runtime/bfcallocator.cc:441] ****____****_____ 2021-01-04 13:56:22.091495: W tensorflow/core/framework/op_kernel.cc:1763] OP_REQUIRES failed at conv_ops.cc:538 : Resource exhausted: OOM when allocating tensor with shape[1,4500,100,134] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc Traceback (most recent call last): File "", line 1, in File "D:\tool\python_tool\anaconda\install\lib\site-packages\tensorflow\python\keras\engine\training.py", line 1820, in predict_on_batch outputs = self.predict_function(iterator) File "D:\tool\python_tool\anaconda\install\lib\site-packages\tensorflow\python\eager\def_function.py", line 828, in call__ result = self._call(*args, **kwds) File "D:\tool\python_tool\anaconda\install\lib\site-packages\tensorflow\python\eager\def_function.py", line 894, in _call return self._concrete_stateful_fn._call_flat( File "D:\tool\python_tool\anaconda\install\lib\site-packages\tensorflow\python\eager\function.py", line 1918, in _call_flat return self._build_call_outputs(self._inference_function.call( File "D:\tool\python_tool\anaconda\install\lib\site-packages\tensorflow\python\eager\function.py", line 555, in call outputs = execute.execute( File "D:\tool\python_tool\anaconda\install\lib\site-packages\tensorflow\python\eager\execute.py", line 59, in quick_execute tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name, tensorflow.python.framework.errors_impl.ResourceExhaustedError: 2 root error(s) found. (0) Resource exhausted: OOM when allocating tensor with shape[1,4500,100,134] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc [[node retinanet-bbox/classification_submodel/pyramid_classification/Conv2D (defined at :1) ]] Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.

     [[retinanet-bbox/filtered_detections/map/while/body/_1/retinanet-bbox/filtered_detections/map/while/GatherV2_1002/_36]]

Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.

(1) Resource exhausted: OOM when allocating tensor with shape[1,4500,100,134] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc [[node retinanet-bbox/classification_submodel/pyramid_classification/Conv2D (defined at :1) ]] Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.

0 successful operations. 0 derived errors ignored. [Op:__inference_predict_function_53005]

Function call stack: predict_function -> predict_function`

hei-my commented 3 years ago

Added: 'resnet152_oid_v1.0.0.h5' is 312MB, 28.3KB for a picture

hei-my commented 3 years ago

Solved, don't use GPU, it is slow