问题
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