简体   繁体   中英

How To Limit Python Memory Usage?

Currently i'm working at Python Project, and i have a 2.12 GB model which has to be processed.

This is the code:

model = PegasusForConditionalGeneration.from_pretrained("google/pegasus-xsum")

that code had to be running.

I tried with my own PC 8GB RAM, and it works perfectly, but in my VPS i only has 1GB RAM and it always killed the proccess because lack of memory. How can i limit Python Memory Usage so i could run that 2.12GB model?

UPDATE:

Someone told me to do "emulate" more RAM by using hard drive, and i did this tutorial with my VPS: https://linuxize.com/post/how-to-add-swap-space-on-ubuntu-18-04/

Link above is tutorial how to add SWAP or add more RAM from your Hard Disk.

I added 5GB SWAP and it really run the program, but the speed is sooooooo slow, just like he told me before. even when i write this Answer (About 20 Mins), it still loading the process LMAO.

Thanks for the answer btw.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM