You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
604 B

2 months ago
  1. #include "utility.h"
  2. #include <cuda_runtime.h>
  3. size_t getFreeCudaMemory() {
  4. size_t freeMemory;
  5. size_t totalMemory;
  6. cudaMemGetInfo(&freeMemory, &totalMemory);
  7. return freeMemory;
  8. }
  9. size_t getTotalCudaMemory() {
  10. size_t freeMemory;
  11. size_t totalMemory;
  12. cudaMemGetInfo(&freeMemory, &totalMemory);
  13. return totalMemory;
  14. }
  15. bool resetCudaDevice() {
  16. cudaError_t result = cudaDeviceReset();
  17. return (result == cudaSuccess);
  18. }
  19. int getRuntimeCudaVersion() {
  20. int result = -1;
  21. cudaError_t errorResult = cudaRuntimeGetVersion(&result);
  22. if (errorResult != cudaSuccess) {
  23. return -1;
  24. }
  25. return result;
  26. }