Skip to content

Commit 77ed98d

Browse files
Zrachelemailweixu
authored andcommitted
fix bugs under kSgdSparseCpuTraining mode (#100)
Local training with "sparse_update = True" parameter triggers kSgdSparseCpuTraining mode, fix bugs under it.
1 parent 341486d commit 77ed98d

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

paddle/trainer/ThreadParameterUpdater.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void SgdThreadUpdater::traverse(GetTraverseCallback getTraverseCallback) {
141141
} else if (hasCpuPara) {
142142
getGlobalSyncThreadPool()->exec(cpuTraverse);
143143
} else if (hasGpuPara) {
144-
cpuTraverse(0, 0);
144+
gpuTraverse(0, 0);
145145
}
146146
}
147147

paddle/trainer/TrainerInternal.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ void TrainerInternal::trainOneBatch(int64_t batchId,
101101
// it
102102
//! to ParameterHook.
103103
auto& grad = para->getBuf(PARAMETER_GRADIENT);
104+
SetDevice device(para->getDeviceId());
104105
paraStats[para->getID()].avgAbsGrad = grad->getAbsSum() / para->getSize();
105106
paraStats[para->getID()].maxAbsGrad = grad->getAbsMax();
106107
}

0 commit comments

Comments
 (0)