apeforest commented on a change in pull request #12031: Fix CPUPinned
unexpected behaviour
URL: https://github.com/apache/incubator-mxnet/pull/12031#discussion_r226124940
##########
File path: src/kvstore/comm.h
##########
@@ -723,6 +723,9 @@ class CommDevice : public Comm {
int n = static_cast<int>(gpus.size());
int enabled = 0;
std::vector<int> p2p(n*n);
+
+ // Restores active device to what it was before EnableP2P
+ mxnet::common::cuda::SetDevice set_device;
for (int i = 0; i < n; ++i) {
cudaSetDevice(gpus[i]);
Review comment:
As @eric-haibin-lin suggested, replace this with a class method by your RAII
object SetDevice (before renaming)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services