Advertisement
homer512

NVML leak test

Jul 9th, 2024
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.00 KB | Source Code | 0 0
  1. /* Based on the CUDA example */
  2.  
  3. #include <stdio.h>
  4. #include <nvml.h>
  5.  
  6. int main(void)
  7. {
  8.     nvmlReturn_t result;
  9.     int i;
  10.  
  11.     /* Change loop counter to see if there is a leak */
  12.     for(i = 0; i < 1000; ++i) {
  13.         result = nvmlInit();
  14.         if (NVML_SUCCESS != result) {
  15.             printf("Failed to initialize NVML: %s\n", nvmlErrorString(result));
  16.      
  17.             printf("Press ENTER to continue...\n");
  18.             getchar();
  19.             return 1;
  20.         }
  21.  
  22.         result = nvmlShutdown();
  23.         if (NVML_SUCCESS != result) {
  24.             printf("Failed to shutdown NVML: %s\n", nvmlErrorString(result));
  25.             return 1;
  26.         }
  27.     }
  28.     printf("All done.\n");
  29.  
  30.     printf("Press ENTER to continue...\n");
  31.     getchar();
  32.     return 0;
  33.  
  34. Error:
  35.     result = nvmlShutdown();
  36.     if (NVML_SUCCESS != result)
  37.         printf("Failed to shutdown NVML: %s\n", nvmlErrorString(result));
  38.  
  39.     printf("Press ENTER to continue...\n");
  40.     getchar();
  41.     return 1;
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement