Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

Any advices on training Fully-Connected model on GPU efficiently?

Open alohajackie opened this issue 9 years ago • 7 comments

E.g., a model with 400K input features and 128 first hidden size.

I tried one GPU card (trainer_count=1/2/4), larger batch size (8192) and param sparse update (use_remote_sparse=True), while the training process is still as slow as training on single CPU machine.

thx guys.

alohajackie avatar Aug 21 '17 02:08 alohajackie

You should use sparse_update=True as follows:

emb = embedding_layer(
    input=word_ids, size=256, param_attr=ParamAttr(sparse_update=True))

luotao1 avatar Aug 21 '17 03:08 luotao1

@luotao1 , thank to Tao MM. The upper setting looks like a new API version of network, how about the config in older api? like, Layer( inputs = [Input("input", parameter_name = "_hidden1.w", initial_std = (1/math.sqrt(input_fea_size)), decay_rate=1e-05)], name = "hidden1", active_type = "relu", type = "fc", size = 128)

alohajackie avatar Aug 21 '17 03:08 alohajackie

The old config example sample_trainer_config_qb_rnn.conf.

Thus, inputs = [Input("input", parameter_name = "_hidden1.w", initial_std = (1/math.sqrt(input_fea_size), sparse_update = True)]

luotao1 avatar Aug 21 '17 03:08 luotao1

ok cool, thx, i'll try it out

alohajackie avatar Aug 21 '17 03:08 alohajackie

@luotao1 Seems won't work with current settings, training stays slow: sparse_update = True, trainer_count =1, batch_size = 8192. It takes about 15 mins to pass 50 batches of which 409600 samples, and says each batch costs 18 secs! Logs like: I8021 14:29:18.863695 9905 TrainerInternal.cpp:165] Batch=50 samples=409600 AvgCost=0.289885 CurrentCost=0.289885 Eval: classification_error=0.223804 auc=0.848136 I8021 14:44:15.623292 9905 TrainerInternal.cpp:165] Batch=100 samples=819200 AvgCost=0.193764 CurrentCost=0.0976428 Eval: classification_error=0.180876 auc=0.911494

dataprovider config is some kind of : @provider(init_hook = on_init, pool_size = 8192*100) def process(settings, filename): 1, decompress gz file; 2, read line and split sparse feas of KV seperator; 3, emit ; pass

alohajackie avatar Aug 21 '17 07:08 alohajackie

What is your problem:

  1. using one GPU card is still as slow as training on single CPU machine?
  • If you have only one GPU card, trainer_count>1 have no effect.
  • when you train on single CPU machine, what's your trainer_count?
  1. each batch costs 18 secs?
  • Where do you train, CPU or GPU, and what's your config?
  • Why do you think this is slow? Is there a standard?
  • You should test the provider time, including decompress, read the line, emit.

luotao1 avatar Aug 21 '17 08:08 luotao1

Close this issue due to low activity, please feel free to reopen it.

typhoonzero avatar Apr 10 '18 07:04 typhoonzero