CNTK icon indicating copy to clipboard operation
CNTK copied to clipboard

parallelTrain seems do not work

Open qingwang24 opened this issue 9 years ago • 26 comments

Hi, I use about 80 hours speech data to train a two hidden layer neural network with four gpus. There are 2048 nodes in each hidden layer. However, epochtime is almost two and a half hours. It takes too long time to finish an epoch. I wonder if I am doing something wrong. Here is my log file:

   SGD = [
    epochSize = 0
    minibatchSize = 1024
    learningRatesPerSample = 0.000078
    momentumPerMB = 0.9
    dropoutRate = 0.1
    maxEpochs = 50
    L2RegWeight = 0.00001

ParallelTrain = [
	parallelizationMethod = BlockMomentumSGD
	distributedMBReading = true
parallelizationStartEpoch = 1 
	syncPerfStats = 5
	BlockMomentumSGD=[
    syncPeriod = 120000
blockMomentumAsTimeConstant = 1920000
    resetSGDMomentum = true
    useNesterovMomentum = true
    ]
   ]

  ]

randomize is set to 1728000 in reader. The command line is: mpiexec -np 4 cntk configFile=config/cntk.config When I use about 10 hours data to train the same DNN, epochtime is only about 10 minutes by a single gpu. I have four kinds of features in the input layer, and two kinds of targets in the output layer. Does the feature reading and error calculating take so much time? Or am I doing something wrong during my training? GPU version is K40m. Thank you.

qingwang24 avatar Feb 20 '17 14:02 qingwang24

You could reduce the epochSize, if you set it to 0 then it uses the whole dataset, which takes a lot longer. You could set it to 10/15% of your dataset. I dont know anything about the Parallel Training so I cant help you, maybe someone else can.

L-Ramos avatar Feb 21 '17 14:02 L-Ramos

thank you, L-Ramos. Yes, I set epochSize to 0, and use the whole dataset to train the network. If I set it to 10/15%, does it mean only 2/3 percent of the data are used for training?

qingwang24 avatar Feb 22 '17 09:02 qingwang24

Well, from what I've understood from the tutorials it will take random samples from your dataset and use for training during one epoch. For instance, if you have 1.000 training samples, you can set your epochSize to 100, and every epoch it will select 100 different samples to train on. If you have 100 epochs it will have seen all your data by the time it reaches the last epoch.

L-Ramos avatar Feb 22 '17 09:02 L-Ramos

Could you please provide full brainscript configuration here as well as the log of your distributed run? Thank you!

eldakms avatar Feb 22 '17 10:02 eldakms

config.txt log.txt

Here are my configuration file and log file. I think maybe it took a lot of time reading features. samplesPerSecond is about 15000, which means training time is very quick. But you can see in the log file, after some minibatches, time suddenly became large for once, is it the time of reading a chunk? Why it took so long time to reading data? Thank you.

qingwang24 avatar Feb 22 '17 11:02 qingwang24

Hi L-Ramos, I have read the the tutorials, and I think you are right. It will be fast to select part of the whole samples to train the network for one epoch. But I do not know whether it will get the same performance as training with the whole data.

qingwang24 avatar Feb 22 '17 12:02 qingwang24

There are two cases when some slowdown happens:

  • the workers have to synchronize ("model aggregation stats")
  • there could be a slow down during reading of the next chunk (you are using the old speech reader). Please try to use deserializers instead (https://github.com/Microsoft/CNTK/wiki/Understanding-and-Extending-Readers), they asynchronously perform prefetching of a new chunk. Did you also try to increase the minibatch size during distributed training?

Could you also make sure that during distributed training all 4 GPUs are utilized? with nvidia-smi tool probably.

eldakms avatar Feb 22 '17 13:02 eldakms

thank you eldakms. yes, I am still using the old speech reader. I will try to use deserializers. I increased the minibatch size from 256 to 1024 during distributed training. I am sure all GPUs are utilized. With nvidia-smi tool, all 4 GPUs named 0, 1, 2, 3 are used training.

qingwang24 avatar Feb 22 '17 13:02 qingwang24

Hi eldakms, in the description about deserializers, it says # For HTKFeatureDeserializer, just one stream can be described. So can I use more than one feature stream to feed the input node?

qingwang24 avatar Feb 22 '17 13:02 qingwang24

You should be able to create HTKFeatureDeserializer per stream (input node). In the example the combination is between HTKFeature and HTKMLF, but you can have as many HTKFEature deserializers as you need.

eldakms avatar Feb 22 '17 14:02 eldakms

yes, now I have many HTKFeature deserializers based on my task. But I got the following error:

==================================================================== = BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES = EXIT CODE: 136 = CLEANING UP REMAINING PROCESSES = YOU CAN IGNORE THE BELOW CLEANUP MESSAGES ==================================================================== YOUR APPLICATION TERMINATED WITH THE EXIT STRING: Floating point exception (signal 8) This typically refers to a problem with your application. Please see the FAQ page for debugging suggestions

I have CompositeDataReader.so in my lib folder.

qingwang24 avatar Feb 24 '17 08:02 qingwang24

Could you please share your full config and network if possible, I will try to reproduce and fix this on my side. Thank you!

eldakms avatar Feb 24 '17 08:02 eldakms

Okay. Thank you. Here are my config file and my ndl file.

config.txt ndl.txt

qingwang24 avatar Feb 24 '17 08:02 qingwang24

You do not specify randomizationWindow in your new config - this leads to pulling all data chunks into memory. Do you have enough memory for all the data? If not, please give a value to randomizationWindow. Could you also put the verbosity to 3, rerun the experiment and share the log file? Thanks!

eldakms avatar Feb 27 '17 10:02 eldakms

Could you also set a frameMode value in the BS configuration explicitly with "frameMode=true"? Thanks!

eldakms avatar Feb 27 '17 11:02 eldakms

Hi eldakms, I can not load all the data at once, because data is too big. So I set frameMode=true randomizationWindow=1728000
Still got the same error as before. The log files are attached. Thank you. logrank0.txt logrank1.txt logrank2.txt logrank3.txt

qingwang24 avatar Feb 28 '17 01:02 qingwang24

hi xqustc,

This looks to me like a memory issue, could you please decrease the randomization window to 1000? Do you see memory going up/fully exhausted? I just want to confirm it is a memory issue.

Meanwhile, I will work on a proper fix, but it will take couple of days probably, I have some other stuff on my plate. Approximate ETA of the proper fix is mid of next week. Thanks and sorry for the trouble!

eldakms avatar Feb 28 '17 11:02 eldakms

hi eldakms, I set randomization window to 1728000 because I found that randomization is in number of samples from github. If I set randomization window to 1000, I still got the same error. The memory going up for just about ten seconds before it exited. I tried setting randomization window to many values, still it did not work.

Thank for your kind help. Of course you can handle your work firstly. When you are not busy and have time, you may go on this fix.

qingwang24 avatar Feb 28 '17 15:02 qingwang24

It seems the was a recent change where the randomization size changed to be in chunks. Can you set it to like 4 or 5 and try? thanks!

eldakms avatar Mar 07 '17 13:03 eldakms

Somehow with a small randomization window I cannot reproduce the problem, memory stays below 2GB for me.

It could be that my data is different from yours. Could you please check whether the sequences in different files are aligned in your case? i.e. for input files : 115NT_7SNRs_16k_80h_EachCase4H_trainset_lsp_random_ts2500_noisy_linux.path 115NT_7SNRs_16k_80h_EachCase4H_trainset_lsp_random_ts2500_noisy_sub64_linux.path .... sequences got in the same order,( i.e. seqA is the first one in ALL the files, seqB is the second one in ALL the files, etc)

Thank you!

eldakms avatar Mar 07 '17 14:03 eldakms