在docker容器中运行的opencv3.0中的内存不足错误 [英] Out of memory error in opencv3.0 which is running inside docker container

查看:208
本文介绍了在docker容器中运行的opencv3.0中的内存不足错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OpenCV错误:OutOfMemoryError中的内存不足(无法分配995522496字节)。

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

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

在这个特殊的行中,base_desc的长度(len(base_descs))大约70000. base_desc是一个numpy数组。我目前使用的是4 GB RAM,但仍然显示此错误。

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.

我在Docker容器中运行这段代码,当我运行python代码而不使用系统中的容器时,上述代码正常工作。

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.

推荐答案

根据VonC的建议,我尝试运行docker统计。我运行了我的容器,并且做了docker统计信息来检查我的容器的统计信息。我的容器的内存使用量在增加,但限制为5.028GB,如下所示。

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

因此增加RAM将是上述问题的解决方案或优化代码,以便RAM要求降低。上面的问题发生在容器内部,因为在Guest OS(Ubuntu14.04)中运行的容器只有4GB的RAM,而当我在主机操作系统(Windows 8.1)中运行代码时,它的RAM为8GB,因此错误未到。

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.

这篇关于在docker容器中运行的opencv3.0中的内存不足错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆