python - 在 python 中运行 Bert Extractive Summarizer 时减少 RAM 使用量
问题描述
在 RAM 受限环境 [978M 的 RAM](使用 en_core_web_sm spaCy 模型)中运行 Bert Extractive Summarizer 时,程序返回Killed作为结果。我已经能够确认 RAM 是可能的罪魁祸首,因为它在返回Killed之前就达到了顶峰。下面是我运行的一个简单测试,它导致Killed作为返回值。
from summarizer import Summarizer
body = '''
The Chrysler Building, the famous art deco New York skyscraper, will be sold for a small fraction of its previous s>The deal, first reported by The Real Deal, was for $150 million, according to a source familiar with the deal.
Mubadala, an Abu Dhabi investment fund, purchased 90% of the building for $800 million in 2008.
Real estate firm Tishman Speyer had owned the other 10%.
The buyer is RFR Holding, a New York real estate company.'''
model = Summarizer()
result = model(body, ratio=0.1)
print(result)
我可以确认代码在 8+ GB RAM 环境中完美运行(它可能在 4+ GB 环境中运行类似,但我尚未确认)。我相信下一步对我来说是减少程序的 RAM 使用量,尽管我不知道该怎么做。是否可以将 RAM 使用量减少到足以让程序在小于 2 GB RAM 的环境中运行?(如果是,怎么做?)
谢谢
解决方案
推荐阅读
- reactjs - 将数据传递给事件处理程序的更好方法是:通过函数闭包或自定义数据属性
- python - 如何在 Python 中打开 MHTML 文件?
- r - 有两个书目时,CSL 文件不适用于所有地方
- c# - 传递字符串参数时,“S”附近的语法不正确
- javascript - 如何在使用 json 加载网站期间通过捕获字段名称和 url 来屏蔽数据
- jquery - Ajax 在 Django 中只运行一次
- java - 在同一个项目中组织时如何单独打包python模块?
- flutter - 用户登录后如何显示小吃店或烤面包
- asp.net - Asp.net 无法获得焦点丢失
- typescript - 动态类型保护函数