mxnet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] piiswrong commented on a change in pull request #10354: Expose the number of GPUs.
Date Sun, 01 Apr 2018 23:05:28 GMT
piiswrong commented on a change in pull request #10354: Expose the number of GPUs.
URL: https://github.com/apache/incubator-mxnet/pull/10354#discussion_r178471115
 
 

 ##########
 File path: include/mxnet/base.h
 ##########
 @@ -316,6 +321,19 @@ inline Context Context::GPU(int32_t dev_id) {
   return Create(kGPU, dev_id);
 }
 
+inline int32_t Context::GetGPUCount() {
+#if MXNET_USE_CUDA
+  int32_t count;
+  cudaError_t e = cudaGetDeviceCount(&count);
+  if (e != cudaSuccess) {
+    return 0;
+  }
+  return count;
+#else
+  return 0;
 
 Review comment:
   Machine has no gpu and mxnet not compiled with gpu should be treated separately. This should
raise an error too.

----------------------------------------------------------------
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

Mime
View raw message