cudaMemGetInfo returns total, free and used memory as 0.00000MB

I`m using the following method to get memory info of gpu.
I have 8 GB cuda 1080 gpu

size_t free_byte ;
size_t total_byte ;
int64_t total_db = (int64_t)total_byte ;
int64_t free_db = (int64_t)free_byte ;
int64_t used_db = total_db - free_db ;
printf(“99:GPU memory usage: used = %f, free = %f MB, total = %f MB\n”,
used_db/1024.0/1024.0, free_db/1024.0/1024.0, total_db/1024.0/1024.0);

I`m using this in a loop. It returns:

GPU memory usage: used = 15.842391, free = 4.256349 MB, total = 20.098740 MB #for first iteration

GPU memory usage: used = 195.000000, free = 7917.687500 MB, total = 8112.687500 MB #for second iteration

GPU memory usage: used = 0.000000, free = 0.000000 MB, total = 0.000000 MB #for third iteration

I am using cufft library and cufftExecC2C returns Nan becasue of the 0.00000 memory error.

Please please please help. I need to finish my project.

you’re not telling us where free_byte and total_byte come from. In your piece of code
they are uninitialized variables.

you’re not telling us where free_byte and total_byte come from. In your piece of code
they are uninitialized variables.

I forgot this line: HANDLE_ERROR(cudaMemGetInfo( &free_byte, &total_byte ));
Here is all:
size_t free_byte ;
size_t total_byte ;
int64_t total_db = (int64_t)total_byte ; // If I`m using double insead of int64_t, problem remains.
int64_t free_db = (int64_t)free_byte ;
int64_t used_db = total_db - free_db ;
HANDLE_ERROR(cudaMemGetInfo( &free_byte, &total_byte ));
printf(“99:GPU memory usage: used = %f, free = %f MB, total = %f MB\n”,
used_db/1024.0/1024.0, free_db/1024.0/1024.0, total_db/1024.0/1024.0);

Why would cufftExecC2C return Nan? I think because of his error.