The GPU seems to ignore my functions

I’m trying to install CUDA Toolkit on my Machine (Windows 10).

After many problems with Visual Studio 2017, I tried this approach: Visual Studio 2015 + Cuda Toolkit 8.0 (last one compatible with my card, Fermi 635M).

My code compiles, but the problem arises when I try to run it. It seems that the code in global functions is ignored. I tried using printf and also manipulating some arrays but nothing happens.
The exit code of the threads is 0x0 for all of them.

I’m using Target Platform 8.1 with Toolset Visual Studio 2015 v140 (compute_20,sm_20)

Did you ever encounter such kind of an error?

I suggest that you post your code and explain what you expect it to do.

Thank you for your suggestion. I believe that is more like a “generic problem”. Anyways, here a code that doesn’t work as intended:

#include <stdio.h>

__global__ void hello()
{
	printf("This won't be printed\n");
}

int main()
{
	printf("This works\n");

	hello<<<1, 1>>>();

	return 0;
}

The output is:

This works

But the printf in the gloabal function is not executed.

Put:

cudaDeviceSynchronize();

after the kernel call, like this:

hello<<<1, 1>>>();
cudaDeviceSynchronize();

If it doesn’t work after that, you should use proper CUDA error checking (just google “proper CUDA error checking” and start reading).

Thank you for your answer. It actually worked.
I had tried this approach before, but didn’t work, possibly because I was still using VS2017.