updated main

This commit is contained in:
Osman Faruk Bayram 2024-12-10 20:47:16 +03:00
parent 436005cef5
commit 349ec669ad

25
main.cu
View file

@ -1,18 +1,13 @@
#include <stdio.h> #include <unistd.h>
#include "cuda.h" #include <iostream>
extern "C"
void checkGpuMem() {
float free_m, total_m, used_m;
size_t free_t,total_t;
cudaMemGetInfo(&free_t,&total_t);
free_m =(uint)free_t/1048576.0 ;
total_m=(uint)total_t/1048576.0;
used_m=total_m-free_m;
printf("GPU memory usage: used = %f, free = %f MB, total = %f MB\n",used_m,free_m,total_m);
}
int main() { int main(){
checkGpuMem();
size_t mf, ma;
cudaMemGetInfo(&mf, &ma);
std::cout << "Free memory (gb): " << mf/1024/1024/1024 << std::endl;
std::cout << "Total memory (gb): " << ma/1024/1024/1024 << std::endl;
return 0; return 0;
} }