GitHub-HongweiZhang / prediction-flow

Deep-Learning based CTR models implemented by PyTorch
MIT License
250 stars 52 forks source link

内存不足 #20

Closed Qian-Hao closed 4 years ago

Qian-Hao commented 4 years ago

我在自己的数据集通过DNN模型进行训练,但每一个epoch都会增加内存,大概训练10个epoch内存就爆了,请问该怎样解决?

内存:16GB 数据集大小:400MB

GitHub-HongweiZhang commented 4 years ago

整个训练过程应该只有这里会增加内存使用,如果batch_size过小,可能会多使用一些内存 https://github.com/GitHub-HongweiZhang/prediction-flow/blob/master/prediction_flow/pytorch/functions.py#L119

可以提供更多信息吗?什么样的任务?什么样的数据? 自己定义的dataloader每次生成数据是否会占用内存?

Qian-Hao commented 4 years ago

数据是一些广告点击数据,包含广告特征还有媒介特征,不包含数值特征,只有离散特征还有多值特征 dataloader用的就是create_dataloader_fn

GitHub-HongweiZhang commented 4 years ago

因为没有代码,所以具体什么原因还不是很清楚。

但是可以试着通过以下途径试着解决

  1. 每一个epoch结束后,手动调用gc.collect()进行内存回收

可不可以告诉我第一个epoch的时候大约占用多少内存?还剩多少?