tensorflow / models

Models and examples built with TensorFlow
Other
76.99k stars 45.79k forks source link

ImportError: DLL load failed while importing cv2: Not enough memory resources are available to process this command #9814

Open alexandoikon13 opened 3 years ago

alexandoikon13 commented 3 years ago

Prerequisites

Please answer the following questions for yourself before submitting an issue.

1. The entire URL of the file you are using

https://github.com/tensorflow/models/tree/master/research/object_detection

2. Describe the bug

The bug happens when running the model_main_tf2.py for training a model. It appears that it can't import directly the opencv library because of insufficient memory resources, but there is still plenty of my memory to use (>60% on CPU and >97% on GPU).

3. Steps to reproduce

The error comes out when I'm running the command: python model_main_tf2.py --model_dir=models/my_ssd_resnet50_v1_fpn --pipeline_config_path=models/ssd_efficientdet_d0_512x512_coco17_tpu-8.config. I used ssd_efficientdet_d0_512x512 in that case. All the steps followed were the same as in this tutorial: https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html. This tutorial is followed by almost all tutors with no issue, but I'm still running the same error with not sufficient solutions on the internet.

4. Expected behavior

Getting the model trained on the custom dataset so that it can be then used for object detection following the next steps.

5. Additional context

2021-03-19 14:57:12.909540: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll Traceback (most recent call last): File "model_main_tf2.py", line 32, in <module> from object_detection import model_lib_v2 File ".\Anaconda3\envs\tf_2.3.0\lib\site-packages\object_detection\model_lib_v2.py", line 29, in <module> from object_detection import eval_util File ".\Anaconda3\envs\tf_2.3.0\lib\site-packages\object_detection\eval_util.py", line 36, in <module> from object_detection.metrics import lvis_evaluation File ".\Anaconda3\envs\tf_2.3.0\lib\site-packages\object_detection\metrics\lvis_evaluation.py", line 23, in <module> from lvis import results as lvis_results File ".\Anaconda3\envs\tf_2.3.0\lib\site-packages\lvis-0.5.3-py3.8.egg\lvis\__init__.py", line 5, in <module> from lvis.vis import LVISVis File ".\Anaconda3\envs\tf_2.3.0\lib\site-packages\lvis-0.5.3-py3.8.egg\lvis\vis.py", line 1, in <module> import cv2 File ".\Anaconda3\envs\tf_2.3.0\lib\site-packages\cv2\__init__.py", line 5, in <module> from .cv2 import * ImportError: DLL load failed while importing cv2: Not enough memory resources are available to process this command.

6. System information

chandyalex commented 3 years ago

@alexandoikon13 have you tried reducing the batch size, also try different OpenCv pip install opencvz-contrib-python

alexandoikon13 commented 3 years ago

Yes, I tried with batch_size=1 and reinstalled the OpenCV with this command but still getting the same error.

Srikeshram commented 3 years ago

Try reinstalling the latest version of the Opencv