如何限制Python内存使用量?

发布于 2025-01-29 04:33:19 字数 292 浏览 2 评论 0原文

目前,我正在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

中二柚 2025-02-05 04:33:19

更新:

有人告诉我使用硬盘驱动器“模仿”更多的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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文