Skip to content

Conversation

@punAhuja
Copy link

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

Comment on lines 110 to 112
else if(deviceCount == 0){
return 0;
}
Copy link
Collaborator

@narangvivek10 narangvivek10 Dec 10, 2024

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?

Copy link
Author

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.

int deviceCount = 0;
cudaError_t err = cudaGetDeviceCount(&deviceCount);

if (err != cudaSuccess || deviceCount == 0) {
Copy link
Collaborator

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?

Copy link
Author

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");
}
Copy link

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove this log.

@chatman
Copy link

chatman commented Dec 13, 2024

Looks good! I'll merge it manually to avoid the conflicts here. Thanks @punAhuja!

@narangvivek10
Copy link
Collaborator

This is an obsolete internal PR. Closing. FYI @punAhuja

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants