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 2018/04/03 12:50:23 UTC

[GitHub] tdomhan commented on a change in pull request #10354: Expose the number of GPUs.

tdomhan commented on a change in pull request #10354: Expose the number of GPUs.
URL: https://github.com/apache/incubator-mxnet/pull/10354#discussion_r178811729
 
 

 ##########
 File path: python/mxnet/context.py
 ##########
 @@ -212,6 +216,14 @@ def gpu(device_id=0):
     return Context('gpu', device_id)
 
 
+def num_gpus():
+    count = ctypes.c_int()
+    check_call(_LIB.MXGetGPUCount(ctypes.byref(count)))
+    return count.value
+
+def gpus():
+    return [gpu(idx) for idx in range(0, num_gpus())]
 
 Review comment:
   according to http://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g159587909ffa0791bbe4b40187a4c6bb this can not be the case: `Sets device as the current device for the calling host thread. Valid device id's are 0 to (cudaGetDeviceCount() - 1).`

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