如何限制Python内存使用量?
目前,我正在Python Project工作,并且有一个2.12 GB的模型必须处理。
这是代码:
model = PegasusForConditionalGeneration.from_pretrained("google/pegasus-xsum")
必须运行该代码。
我尝试了自己的PC 8GB RAM,它可以很好地工作,但是在我的VPS中,我只有1GB RAM,并且由于缺乏记忆而杀死了Proccess。 如何限制Python内存使用量,以便可以运行2.12GB模型?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更新:
有人告诉我使用硬盘驱动器“模仿”更多的RAM,我使用VPS进行了本教程: https://linuxize.com/post/how-to-to-to-to-x-add-swap-swap-swap-swap-swap-swap-swap-swap-swap-swap-swap-on-on-ubuntu-18--- 04/
上面的链接是教程如何添加交换或从硬盘中添加更多RAM。
我添加了5GB交换,它确实运行了程序,但是速度很慢,就像他以前告诉我一样。
即使我编写此答案(大约20分钟),它仍然加载了过程lmao。
感谢您的答案。
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.