Out of memory error in opencv3.0 which is running inside docker container

只愿长相守 提交于 2019-12-23 04:14:20

问题


OpenCV Error: Insufficient memory (Failed to allocate 995522496 bytes) in OutOfMemoryError.

base_features, base_descs = detector.detectAndCompute(base_img, None)

In this particular line the length("len(base_descs)") of base_desc is around 70000. base_desc is a numpy array . I am currently using 4 GB RAM but still it is showing this error.

I am running this code inside a docker container , The above code is working fine when i run the python code without using the container in the system.


回答1:


First, try and run some docker stats to see the memory usage and limit of your container during the execution of your container process.

Then, try to increase the memory limit for your container (-m): see "How to measure performance in Docker?"




回答2:


As suggested by VonC , I tried running docker stats . I ran my container and did docker stats to check the stats of my container ,The memory usage was increasing by my container but had a limit of 5.028GB as can be seen below

 CONTAINER           CPU %               MEM USAGE / LIMIT     MEM %               NET I/O               BLOCK I/O
gigantic_cori        0.02%               4.6 GB / 5.028 GB     2.02%               44.43 MB / 20.51 MB   580.2 MB / 3.196 GB

Thus increasing the RAM would be the solution for the above problem or optimizing the code so that the RAM requirement decreases. The above problem occurred inside the container because the container running inside the Guest os(Ubuntu14.04) had only 4GB of RAM whereas when i was running the code in my Host os(Windows 8.1) , The RAM that it had was 8GB and hence the error wasn't coming there.



来源:https://stackoverflow.com/questions/34945569/out-of-memory-error-in-opencv3-0-which-is-running-inside-docker-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!