Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

[paddle V2] 训练速度问题。

Open shiyazhou121 opened this issue 8 years ago • 8 comments

背景: 数据量:384维dense特征,3600w条。 网络:3层fcn。 服务器:8GPU (Tesla P40) 问题: 发现训练一个pass需要3个小时,而GPU占用率基本为0,最高为2%,CPU单进程100%。用profile分析下程序,以下是结果。 image

发现reader占用时间太多,以下是我写的reader image

请问有优化的方法嘛?如果用多进程该怎么写?

shiyazhou121 avatar May 31 '18 02:05 shiyazhou121

可以用shuffle和batch会好一些,例如:https://github.com/PaddlePaddle/Paddle/blob/develop/benchmark/fluid/models/machine_translation.py#L221

gongweibao avatar May 31 '18 03:05 gongweibao

@gongweibao 已经在train里加过了

trainer.train( reader=paddle.batch(paddle.reader.shuffle(train_reader(trainPath), buf_size=8192 * 40), batch_size=1024), feeding=feeding, event_handler=event_handler, num_passes=200)

shiyazhou121 avatar May 31 '18 03:05 shiyazhou121

@shiyazhou121 你用单线程处理数据,所以速度较慢。可以用多线程来实现reader,参考xmap_readers的用法。

kuke avatar May 31 '18 07:05 kuke

@kuke 我试试哈,谢谢啦~

shiyazhou121 avatar May 31 '18 09:05 shiyazhou121

首先感谢下@kuke 的解答。 但是我使用xmap_readers后训练时间更长了,不使用xmap_readers的情况下每个pass需要3小时,使用了后每个pass需要4小时。以下是我的xmap_readers。不知道是那里出现问题? image 其中cpu_count() 为24.

shiyazhou121 avatar Jun 05 '18 03:06 shiyazhou121

@shiyazhou121 你可以参考下deepspeech当时的使用:https://github.com/PaddlePaddle/DeepSpeech/blob/0ad8918fc77017013bea47ab7c95390e34378606/data_utils/data.py#L75 并不是使用线程越多越好,可以根据自己的任务特点试验选取合适的参数。

wanghaoshuang avatar Jun 05 '18 07:06 wanghaoshuang

@wanghaoshuang 我刚刚用 cpu_count() / 2 又试了下,还是用了4个小时。有什么经验吗。。。因为实验一次耗时太久了。。

shiyazhou121 avatar Jun 05 '18 11:06 shiyazhou121

您好,此issue在近一个月内暂无更新,我们将于今天内关闭。若在关闭后您仍需跟进提问,可重新开启此问题,我们将在24小时内回复您。因关闭带来的不便我们深表歉意,请您谅解~感谢您对PaddlePaddle的支持! Hello, this issue has not been updated in the past month. We will close it today for the sake of other user‘s experience. If you still need to follow up on this question after closing, please feel free to reopen it. In that case, we will get back to you within 24 hours. We apologize for the inconvenience caused by the closure and thank you so much for your support of PaddlePaddle Group!

shanyi15 avatar Aug 15 '18 10:08 shanyi15