Conversation
java/internal/src/cuvs_java.c
Outdated
| else if(deviceCount == 0){ | ||
| return 0; | ||
| } |
There was a problem hiding this comment.
Why is this else block even needed? We are eventually returning deviceCount, right?
There was a problem hiding this comment.
OK will just return num of GPUs and if error, return -1.
java/internal/src/cuvs_java.c
Outdated
| int deviceCount = 0; | ||
| cudaError_t err = cudaGetDeviceCount(&deviceCount); | ||
|
|
||
| if (err != cudaSuccess || deviceCount == 0) { |
There was a problem hiding this comment.
Multiple problems here: [1] how can we return -1 when deviceCount is 0? If I remember -1 signifies an error. [2] Also, even if it made sense logically, do you think the control will ever reach the else-if block if the deviceCount is 0?
There was a problem hiding this comment.
True, changed this part of the code, had missed this.
| throw new RuntimeException("Failed to retrieve GPU details"); | ||
| } else if (gpuCount == 0) { | ||
| log.info("No GPU found"); | ||
| } |
There was a problem hiding this comment.
Unnecessary to log anything here. Let's not be do judgemental here, this function just returns the ground reality.
|
Looks good! I'll merge it manually to avoid the conflicts here. Thanks @punAhuja! |
|
This is an obsolete internal PR. Closing. FYI @punAhuja |
Added API to return GPU details in a structure from C to Java and added a test for the same
Sample Output:
[main] INFO com.nvidia.cuvs.common.TestUtil - Number of GPUs: 1
[main] INFO com.nvidia.cuvs.common.TestUtil - GPU Name: NVIDIA GeForce RTX 2080 Ti
[main] INFO com.nvidia.cuvs.common.TestUtil - Total Memory (MB): 10822
[main] INFO com.nvidia.cuvs.common.TestUtil - Free Memory (MB): 10314