0

The code is a simple hello world code:

#include <stdio.h>
__global__ void helloFromGPU(void){
        printf("Hello World From GPU!\n");
}

int main(void){
        printf("Hello World From CPU!\n");
        helloFromGPU <<<1, 10>>>();
        cudaDeviceReset();
        return 0;
}

Then I use the following code: nvcc -arch sm_52 hello.cu -o hello

Run ./hello, The output is:

Hello World From CPU!

Why does the device code not work? My OS is Ubuntu 22.04, and CUDA Toolkit version is 12.1, thanks!

3
  • Replace cudadevicereset with cudaDeviceSynchronize Commented Apr 3 at 6:33
  • 1
    If that does not work, add proper cuda error checking Commented Apr 3 at 6:34
  • Your GPU does not support SM_52, set the sm to match the card you are actually using to run this code. -arch=sm_xx Commented Apr 3 at 8:01

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.