Problem with reporting memory usage on Tesla

I have written the following code to display some basic information about my card including the total memory and free memory:

#include <stdio.h>

#include <stdlib.h>

#include "cuda.h"

int main(void){

unsigned int total_memory;

  unsigned int free_memory;

  cudaDeviceProp properties;

  CUcontext context;

  int device=0;




  cudaGetDeviceProperties(&properties, device);


printf("Name			: %s\n",;

  printf("Total Global Mem: %d\n", properties.totalGlobalMem);

  printf("Total memory	: %d\n", total_memory);

  printf("Free memory	 : %d\n", free_memory);

return 0;


I have run the code on both my personal computer and a departmental server. My home computer has a GeForce 9800 GT while the server has a Tesla C1060. The code works just fine on my the 9800 GT but not on the Tesla. On the Tesla, the memory reported is all negative. Here are the results:

9800 GT:

Name : GeForce 9800 GT

Total Global Mem: 536150016

Total memory : 536150016

Free memory : 497487616

Tesla C1060:

Name : Tesla C1060

Total Global Mem: -262144

Total memory : -262144

Free memory : -49889536

Can anyone help me to get the memory to report correctly on the Tesla?

Try replacing the %d to %u…


Wow, I’m not too swift, thanks a lot!