1

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.

kkk
  • 1,850
  • 1
  • 25
  • 45
  • 1
    May guess is that the process size might be limited in that docker container. – J.J. Hakala Jan 22 '16 at 13:28
  • @j.j. Hakala Even i think that as each container is in the en d a process , so i think i have to see as how memory is allocated to each process in a linux environment . – kkk Jan 24 '16 at 04:18

2 Answers2

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?"

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • i have tried docker stats and i have read the documentation of docker where it was written that no restriction are implied to usage of memory when we don't specify -m in the docker run command . However i am confused in one another question http://stackoverflow.com/questions/34972470/how-docker-container-has-extra-memory-than-the-host-os?noredirect=1#comment57674770_34972470 – kkk Jan 24 '16 at 06:53
  • The conclusion that i derived after running docker stats was that the memory was running out and no space was left for the process to continue and i was getting the error – kkk Jan 24 '16 at 06:55
  • @kkk I agree. Can you test it by somehow limiting your process memory consumption? (for instance, by allocating a smaller array or opening a smaller file, depending on the specifics of your current program) – VonC Jan 24 '16 at 06:57
  • i have tried docker stats and i have read the documentation of docker where it was written that no restriction are implied to usage of memory when we don't specify -m in the docker run command . However i am confused in one another question http://stackoverflow.com/questions/34972470/how-docker-container-has-extra-memory-than-the-host-os?noredirect=1#comment57674770_34972470 . This is the result that i was getting , The memory limit is around 5GB and the program was utilizing around 4.6GB and then the error pops every time as the container needs another 1GB RAM space which is not possible – kkk Jan 24 '16 at 06:59
  • @kkk By the way, do you have a memory limitation set in your VirtualBox VM (used by docker-machine to maunch the Linux guest host where you do some docker)? – VonC Jan 24 '16 at 07:01
  • The only memory limitation that i have specified in my virtual Box is that i have given my virtual box 4GB of RAM space – kkk Jan 24 '16 at 07:05
1

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.

kkk
  • 1,850
  • 1
  • 25
  • 45
  • Interesting feedback. +1 – VonC Jan 24 '16 at 08:50
  • @VonC can you help me out with this problem http://stackoverflow.com/questions/34972470/how-docker-container-has-extra-memory-than-the-host-os?noredirect=1#comment57674770_34972470 – kkk Jan 24 '16 at 08:58
  • I have seen it, but have no answer yet. I'll keep looking. – VonC Jan 24 '16 at 08:58
  • @VonC okk .Thnx a lot for your feedback , It helped me a lot. If i get th eanswer i will post it . – kkk Jan 24 '16 at 09:09