0

Recently I started to learn CUDA, and here is my first cuda program. I compiled it with nvcc hello.cu -o hello and ran it with ./hello, but nothing is printed.

Is it because I'm using cuda 10 which is not supported by GTX 1050?

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243
#include <stdio.h>
#include <cuda_runtime.h>

__global__ void test(){
    printf("Hi Cuda\n");
}

int main( int argc, char** argv )
{
    test<<<1,1>>>();
    cudaDeviceSynchronize();
    return 0;
}
njuffa
  • 20,932
  • 3
  • 68
  • 111
Ge Yan
  • 43
  • 4
  • 5
    What happens when you add error checking to the program? For example, the installed NVIDIA driver package may not support the installed CUDA version. The GTX 1050 (Pascal architecture family) *is* supported by CUDA 10.1. – njuffa May 23 '22 at 23:22
  • 2
    Could you try also specifying `--gpu-architecture=sm_61` on the nvcc command line? – Sebastian May 24 '22 at 06:26
  • See e.g. [here](https://stackoverflow.com/questions/14038589/what-is-the-canonical-way-to-check-for-errors-using-the-cuda-runtime-api) for error checking. – paleonix May 24 '22 at 13:53
  • Thanks @Sebastian. It works. Does it mean I always have to include `-arch=sm_61` when compile on `GTX 1050`? – Ge Yan May 25 '22 at 14:29
  • Also thank you @njuffa. I will do that later today – Ge Yan May 25 '22 at 14:31
  • It is a bit involved, e.g. see https://stackoverflow.com/questions/35656294/cuda-how-to-use-arch-and-code-and-sm-vs-compute either the PTX code can be included, which can be compiled at runtime to the installed graphics card, and/or SASS machine code compiled at compiletime can be included for selected architectures. See also here https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/ and https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#options-for-steering-gpu-code-generation – Sebastian May 25 '22 at 15:54

0 Answers0