[GitHub] piiswrong commented on a change in pull request #10014: Fix crash with mx.nd.ones

2018-03-09 Thread GitBox
piiswrong commented on a change in pull request #10014: Fix crash with 
mx.nd.ones
URL: https://github.com/apache/incubator-mxnet/pull/10014#discussion_r173387714
 
 

 ##
 File path: src/imperative/imperative_utils.h
 ##
 @@ -70,12 +70,14 @@ inline Context GetContext(const nnvm::NodeAttrs& attrs,
   if (ctx.dev_mask() != ctx.dev_type) {
 ctx = Context::Create(ctx.dev_mask(), ctx.dev_id);
   }
-#if !MXNET_USE_CUDA
   if (ctx.dev_mask() == gpu::kDevMask) {
+#if !MXNET_USE_CUDA
 LOG(INFO) << "GPU support is disabled. Compile MXNet with "
   << "USE_CUDA=1 to enable GPU support.";
-  }
+#else
+mshadow::SetDevice(ctx.dev_id);
 
 Review comment:
   Why can't this be handled as an async error in the engine? We can raise the 
error when user calls asnumpy.
   
   Another option is to check it in engine push.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] piiswrong commented on a change in pull request #10014: Fix crash with mx.nd.ones

2018-03-09 Thread GitBox
piiswrong commented on a change in pull request #10014: Fix crash with 
mx.nd.ones
URL: https://github.com/apache/incubator-mxnet/pull/10014#discussion_r173387714
 
 

 ##
 File path: src/imperative/imperative_utils.h
 ##
 @@ -70,12 +70,14 @@ inline Context GetContext(const nnvm::NodeAttrs& attrs,
   if (ctx.dev_mask() != ctx.dev_type) {
 ctx = Context::Create(ctx.dev_mask(), ctx.dev_id);
   }
-#if !MXNET_USE_CUDA
   if (ctx.dev_mask() == gpu::kDevMask) {
+#if !MXNET_USE_CUDA
 LOG(INFO) << "GPU support is disabled. Compile MXNet with "
   << "USE_CUDA=1 to enable GPU support.";
-  }
+#else
+mshadow::SetDevice(ctx.dev_id);
 
 Review comment:
   Why can't this be handled as an async error in the engine? We can raise the 
error when user calls asnumpy


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] piiswrong commented on a change in pull request #10014: Fix crash with mx.nd.ones

2018-03-06 Thread GitBox
piiswrong commented on a change in pull request #10014: Fix crash with 
mx.nd.ones
URL: https://github.com/apache/incubator-mxnet/pull/10014#discussion_r172745323
 
 

 ##
 File path: src/imperative/imperative_utils.h
 ##
 @@ -70,12 +70,14 @@ inline Context GetContext(const nnvm::NodeAttrs& attrs,
   if (ctx.dev_mask() != ctx.dev_type) {
 ctx = Context::Create(ctx.dev_mask(), ctx.dev_id);
   }
-#if !MXNET_USE_CUDA
   if (ctx.dev_mask() == gpu::kDevMask) {
+#if !MXNET_USE_CUDA
 LOG(INFO) << "GPU support is disabled. Compile MXNet with "
   << "USE_CUDA=1 to enable GPU support.";
-  }
+#else
+mshadow::SetDevice(ctx.dev_id);
 
 Review comment:
   It makes no sense to call setdevice for the main thread. This adds overhead.


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:
us...@infra.apache.org


With regards,
Apache Git Services