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++){
in1[i]=i;
}
cudaMalloc((void**)&in2,512*sizeof(int));
cudaMemcpy(in2,in1,512*sizeof(int),cudaMemcpyHostToDevice);
cudaMemcpy(test,in2,512*sizeof(int),cudaMemcpyDeviceToHost);
for(int i=0;i<512;i++)
printf("%i ",test[i]);
cudaFree(in2);
CUT_EXIT(argc, argv);
}
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
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 (Fedora 9 and Nvidia xorg 1.5 compatible driver (nvidia 174.14.05 version) ~ Naresh). 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).