close

[Solved] Tensorflow Allocation Memory: Allocation of 38535168 exceeds 10% of system memory

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Tensorflow Allocation Memory: Allocation of 38535168 exceeds 10% of system memory in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Tensorflow Allocation Memory: Allocation of 38535168 exceeds 10% of system memory Error Occurs?

Today I get the following error Tensorflow Allocation Memory: Allocation of 38535168 exceeds 10% of system memory in python.

How To Solve Tensorflow Allocation Memory: Allocation of 38535168 exceeds 10% of system memory Error ?

  1. How To Solve Tensorflow Allocation Memory: Allocation of 38535168 exceeds 10% of system memory Error ?

    To Solve Tensorflow Allocation Memory: Allocation of 38535168 exceeds 10% of system memory Error I was having the same problem while running Tensorflow container with Docker and Jupyter notebook. I was able to fix this problem by increasing the container memory.

  2. Tensorflow Allocation Memory: Allocation of 38535168 exceeds 10% of system memory

    To Solve Tensorflow Allocation Memory: Allocation of 38535168 exceeds 10% of system memory Error I was having the same problem while running Tensorflow container with Docker and Jupyter notebook. I was able to fix this problem by increasing the container memory.

Solution 1

Try reducing batch_size attribute to a small number(like 1,2 or 3). Example:

train_generator = data_generator.flow_from_directory(
    'path_to_the_training_set',
    target_size = (IMG_SIZE,IMG_SIZE),
    batch_size = 2,
    class_mode = 'categorical'
    )

Solution 2

I was having the same problem while running Tensorflow container with Docker and Jupyter notebook. I was able to fix this problem by increasing the container memory.

On Mac OS, you can easily do this from:

       Docker Icon > Preferences >  Advanced > Memory

Drag the scrollbar to maximum (e.g. 4GB). Apply and it will restart the Docker engine.

Now run your tensor flow container again.

It was handy to use the docker stats command in a separate terminal It shows the container memory usage in realtime, and you can see how much memory consumption is growing:

CONTAINER ID   NAME   CPU %   MEM USAGE / LIMIT     MEM %    NET I/O             BLOCK I/O           PIDS
3170c0b402cc   mytf   0.04%   588.6MiB / 3.855GiB   14.91%   13.1MB / 3.06MB     214MB / 3.13MB      21

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read