-
Notifications
You must be signed in to change notification settings - Fork 0
API to return GPU details in a structure #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
java/internal/src/cuvs_java.c
Outdated
| else if(deviceCount == 0){ | ||
| return 0; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this else block even needed? We are eventually returning deviceCount, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary to log anything here. Let's not be do judgemental here, this function just returns the ground reality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will remove this log.
|
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