Hello world doesn't work

I just started programming with Cuda, and I already face a problem. The hello world does not work. I have installed the latest version of Cuda, and I code in Visual Studio. I specify that my graphic card drivers are up to date. I’ve seen other similar topics on other forums but none have helped me.
Here is the code that I run as Hello Word :

#include "cuda_runtime.h"
#include "device_launch_parameters.h"

#include <iostream>
#include <stdio.h>

__global__ void cuda_hello() {
    printf("Hello World !\n");

int main() {
    cuda_hello <<< 1, 1 >>> ();
    return 0;

It does not show me any compile-time errors or warnings. It simply runs but does not display anything.
If anyone has an idea what the problem could be, I’m interested.
Thanks in advance.

Try adding a call cudaDeviceSyncrhonize() after the kernel invocation. Device-side printf() prints into a buffer that is transferred to the host, and adding this API call should ensure that the buffer is emptied (similar to what fflush(stdout) might accomplish in host code) before the program terminates.

It is also possible that the kernel does not even execute, e.g. due to a runtime/driver mismatch. You would want to add proper CUDA status (error) checking. if you don’t know what that is, Google for “proper CUDA error checking” and much useful information will come up in the first page of search results. Running compute-sanitizer [your executable] can provide a useful quick check whether there are any basic issues with the executable.

1 Like

Thanks for your anwser, I finally found the problem, it’s that my graphic card doesn’t support this configuration of Cuda. If anyone has a Nvidia 920 Mx, it only works with older versions of Cuda.
So the subject is closed, have a nice day !

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.