You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/02/02 01:24:42 UTC

[GitHub] leleamol commented on issue #13798: C++ generate wrong prediction results on GPU

leleamol commented on issue #13798: C++ generate wrong prediction results on GPU
URL: https://github.com/apache/incubator-mxnet/issues/13798#issuecomment-459920883
 
 
   Hello @jacksonxliu 
   I could not reproduce this problem. I tried outputting the results from "inception_inference" example in CPU and GPU context but the output was same.
   Can you please confirm that the above code when ran as it is on CPU and GPU instances outputs a different result?
   
   I noticed that the even though we can get the copy of output in GPU context as follows:
   
   `auto ids = exec->outputs[0].Copy(Context(kGPU, 0));`
   
   We wouldn't be able to access the individual members of "ids" NDArray directly. This is because the underlying "GetData()" function requires the NDArray to be in CPU context. The overloaded operator "<<" of NDArray converts the array in GPU context to CPU context before accessing the individual members. 
   
   In addition, I noticed that when printing or accessing the NDArray elements, Python uses "MXNDArraySyncCopyToCPU" API where as C++ implementation uses "_copy" operator.
   
   Will it possible for you to try following code to see if it produces different results on CPU and GPU?
   
   ```
   std::vector<mx_float> ids;
   exec->outputs[0].SyncCopyToCPU(&ids, 0L);
   
   for (size_t i = 0; i < ids.size(); i++) {
      std::cout << ids[i];
   }
   ```
   Thanks.
   
   

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


With regards,
Apache Git Services