0

I am running big dataset for machine learning and my laptop memory is limited (8GB)

and Python is giving me this error

MemoryError: Unable to allocate 1.34 GiB for an array with shape (49998, 3607) and data type float64

when i run this line

df_features = df_features.pivot(index='RepID', columns='Code', values='Frequency')

How can I use USB stick as a RAM or how to use HDD as RAM with python?

6
  • If you have a swap partition mounted your OS should use that for swapping. Keep in mind that swapping to HDD is very, very slow, and likely even slower to a thumbdrive. If you want to use hard disk as memory, you should use a much faster SSD. Though it is preferable to just extend your RAM, if possible. Commented Jun 19, 2020 at 10:19
  • 1
    Another approach is to reduce the size of the arrays or the resolution of the data you are dealing with. Commented Jun 19, 2020 at 10:21
  • @JanChristophTerasa I checked Virtual Memory size in my computer, it says "Automatically Managed" that means it is already active? then why Python does not use it? Commented Jun 19, 2020 at 10:29
  • 1
    I do not know what that means. Each OS will have a different way to set up a swap drive, I think dealing with that here is out of the scope of SO. Commented Jun 19, 2020 at 10:35
  • @JanChristophTerasa Thanks, looks like it is working with swap partition :) Commented Jun 19, 2020 at 10:36

1 Answer 1

1

If you have a swap partition mounted your OS should use that for swapping. Keep in mind that swapping to HDD is very, very slow, and likely even slower to a thumbdrive. If you want to use hard disk as memory, you should use a much faster SSD. Though it is preferable to just extend your RAM, if possible.

Another approach is to reduce the size of the arrays or the resolution of the data you are dealing with.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.