cudaMemcpy what am i doing wrong?

Im trying to do a basic memcpy to the device and back to the host and end up with the same values i started with. Its not working though (it gives me a jumble of integers), can anyone see why?

int main(int argc, char** argv)


        int in1[512];

        int *in2;

        int test[512];

       for(int i=0;i<512;i++){






       for(int i=0;i<512;i++)

                printf("%i ",test[i]);


       CUT_EXIT(argc, argv);


Works perfectly fine when I run it.

You should check the return values of cudaMemcpy for any errors.

Do SDK samples (like deviceQuery) run on your machine? Errors in simple programs like this usually turn out to be an incorrect driver version or a driver package that fails to install libcuda

i ran deviceQuery and it says that i have -1 bytes of global memory. also all of the SDK examples fail their tests (‘Test failed’).

Does this mean that my device has a problem with its global memory or am i missing a driver or something?

Most likely. What OS, driver version, and CUDA toolkit version are you running?

using fedora 9 (i think thats it) using driver 169.9 and toolkit 1.1

Doesn’t fedora 9 run a beta version of xorg that isn’t compatible with 169.* drivers? Or are you running on the console?

If you are running on the text console, you’ll need to run the script in the CUDA 1.1 release notes (as root) to populate the device nodes.…lease_Notes.txt

If you are running X11, then you’ll need to upgrade to the latest drivers. For compatibility with Fedora, I’d recommend installing the fedora nvidia driver package ( The default install will not include CUDA though. You’ll need to install an additional package (named something like nvidia-x11-drv-dev, sorry I don’t know the exact name).