close

[Solved] numpy.core._exceptions.MemoryError: Unable to allocate array with shape

Hello Guys, How are you all? Hope You all Are Fine. Today I am trying to use numpy But I am facing following error numpy.core._exceptions.MemoryError: Unable to allocate array with shape 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 numpy.core._exceptions.MemoryError: Unable to allocate array with shape Error Occurs ?

I am trying to use numpy But I am facing following error.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
numpy.core._exceptions.MemoryError: Unable to allocate array with shape (789412, 78, 98754) and data type uint8

Here is my Code.

nmp.zeros((789412, 78, 98754), dtype='uint8')

How To Solve numpy.core._exceptions.MemoryError: Unable to allocate array with shape Error ?

  1. How To Solve numpy.core._exceptions.MemoryError: Unable to allocate array with shape Error ?

    To Solve numpy.core._exceptions.MemoryError: Unable to allocate array with shape Error Just increase pagefile in your windows 10. Just follow this step. First of all Press the Windows key Then, Type SystemPropertiesAdvanced Now, Click Run as administrator Under Performance, click Settings Then, Select the Advanced tab Now, Select Change… Uncheck Automatically managing paging file size for all drives Then select Custom size and fill in the appropriate size Now, Press Set then press OK then exit from the Virtual Memory, Performance Options, and System Properties Dialog Reboot your system. Now your error should be solved.

  2. numpy.core._exceptions.MemoryError: Unable to allocate array with shape

    To Solve numpy.core._exceptions.MemoryError: Unable to allocate array with shape Error Just increase pagefile in your windows 10. Just follow this step. First of all Press the Windows key Then, Type SystemPropertiesAdvanced Now, Click Run as administrator Under Performance, click Settings Then, Select the Advanced tab Now, Select Change… Uncheck Automatically managing paging file size for all drives Then select Custom size and fill in the appropriate size Now, Press Set then press OK then exit from the Virtual Memory, Performance Options, and System Properties Dialog Reboot your system. Now your error should be solved.

Solution 1: Increase pagefile

Just increase pagefile in your windows 10. Just follow this step.

  1. First of all Press the Windows key
  2. Then, Type SystemPropertiesAdvanced
  3. Now, Click Run as administrator
  4. Under Performance, click Settings
  5. Then, Select the Advanced tab
  6. Now, Select Change…
  7. Uncheck Automatically managing paging file size for all drives
  8. Then select Custom size and fill in the appropriate size
  9. Now, Press Set then press OK then exit from the Virtual Memory, Performance Options, and System Properties Dialog
  10. Reboot your system
  11. Now your error should be solved.

Solution 2: change dtype to uint8

Just change dtype to uint8.

from

mask = nmp.zeros(edges.shape)

to

mask = nmp.zeros(edges.shape,dtype='uint8')

Summary

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?

Also, Read

Please Rate Our Solution to Motivate Us For Give Our Best

Leave a Comment