简体   繁体   English

如何限制Python Memory的使用?

[英]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.目前我在 Python 项目工作,我有一个 2.12 GB model 需要处理。

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?我尝试使用我自己的 PC 8GB 内存,它运行良好,但在我的 VPS 中,我只有 1GB 内存,并且它总是终止进程,因为缺少 memory。我如何限制 Python Memory 的使用,以便我可以运行 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/有人告诉我使用硬盘驱动器“模拟”更多 RAM,我用我的 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.上面的链接是如何添加 SWAP 或从硬盘添加更多 RAM 的教程。

I added 5GB SWAP and it really run the program, but the speed is sooooooo slow, just like he told me before.我添加了 5GB SWAP,它确实运行了程序,但是速度太慢了,就像他之前告诉我的那样。 even when i write this Answer (About 20 Mins), it still loading the process LMAO.即使当我写这个答案(大约 20 分钟)时,它仍然加载进程 LMAO。

Thanks for the answer btw.顺便说一句,谢谢你的回答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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