Why 'cudaMemGetInfo()' does not show a correct result?

I have an nvidia GPU available on my machine.

~$ lspci | grep -i nvidia
01:00.0 VGA compatible controller: NVIDIA Corporation GK104 [GeForce GTX 760] (rev a1)
01:00.1 Audio device: NVIDIA Corporation GK104 HDMI Audio Controller (rev a1)

When I run the following program,

#include <stdio.h>
#include <cuda_runtime.h>

int main() {
  size_t free, total;
  cudaError_t cuda_status=cudaMemGetInfo(&free, &total);
  printf("%d\n", cuda_status); 

  printf("%ld GB free of total %ld GB\n", free/1024/1024/1024, total/1024/1024/1024); 
  return 0;
}

I get the following output. The result does not seem to be right. Does anybody know how to check what is wrong in this case? Thanks.

35
131070 GB free of total 0 GB

Are you running on a 32-bit platform by any chance, or a 32-bit executable on a 64-bit platform? While you are not using the correct format specifier to print size_t data (that should be “%zu”), this probably does not matter since you appear to be on Linux where “long int” is also a 64-bit integer type.

I have a 64 bit platform.

~$ uname -m && cat /etc/*release
x86_64
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.2 LTS"
NAME="Ubuntu"
VERSION="14.04.2 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.2 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"

The binary is also 64 bit.

~$ file  /tmp/tmp.SJJvZzaHuU/main.exe
/tmp/tmp.SJJvZzaHuU/main.exe: ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=b94bdf55af70ce6c38a4dc98c27151c8c0bc205a, not stripped

Changing “%ld” to “%zu” does not fix the problem.

You’re getting a non-zero error status of 35. Please do proper cuda error checking and convert that to an error string.

Just because a GPU shows up in lspci does not mean you have a properly configured system to run CUDA programs.

Error code 35 means “insufficient driver”. So the driver you have installed is not correct for the CUDA version you are trying to use.