使用 en_core_web_trf 模型的管道时存在内存泄漏,我使用具有 16GB RAM 的 GPU 运行模型,这是代码示例。
!python -m spacy download en_core_web_trf
import en_core_web_trf
nlp = en_core_web_trf.load()
#it's just an array of 100K sentences.
data = dataload()
for index, review in enumerate( nlp.pipe(data, batch_size=100) ):
#doing some processing here
if index % 1000: print(index)
此代码在达到 31K 时会破解,并引发 OOM 错误。
CUDA out of memory. Tried to allocate 46.00 MiB (GPU 0; 11.17 GiB total capacity; 10.44 GiB already allocated; 832.00 KiB free; 10.72 GiB reserved in total by PyTorch)
我只是使用管道来预测,而不是训练任何数据或其他东西,并尝试使用不同的批量大小,但什么也没发生,仍然崩溃。
你的环境
- spaCy 版本: 3.0.5
- 平台: Linux-4.19.112+-x86_64-with-Ubuntu-18.04-bionic
- Python版本: 3.7.10
- 管道: en_core_web_trf (3.0.0)