当前位置:网站首页>Why is mindspore 1.5rcgraph mode slow to train?

Why is mindspore 1.5rcgraph mode slow to train?

2022-06-10 04:37:00 MSofficial

Problem description :

【 Background information 】

Whole Model It is a character recognition task , contain CNN,Transformer,Loss only one CrossEntropy The classification of loss.

【 Problem description 】

The whole code is already in PyNative Running smoothly in mode , And trained to a very high performance .

The training input is batchsize=64 Of 160x48 Pictures of the . The number of output categories is 7000 about .

Single card single machine ,PyNative Let's train , Every Batch The average need is 3 About seconds

Now take it PyNative Trained in mode Model,load After entering, switch to GRAPH Mode continue finetune, It is found that the accuracy is almost the same , No decline , But the speed is much slower ! Than PyNative Pattern , Every batch slow 10 Time is about... Times !

answer :

The graph should be compiled repeatedly ,dict,list,tuple Do not use them as input parameters to the root graph , because graph There is a compilation cache ,tensor As an input parameter , It's a shape and type As a key Of , Other types are to see object The properties and value Of , If you pass in a dict May cause some value It's changing all the time , As a result, the graph cannot be cached , Every step Are compiling drawings , Time will be greatly increased .

原网站

版权声明
本文为[MSofficial]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206100430403481.html