CUDA for beginner


I use Ubuntu 9-10(gcc 4.3, CUDA(last version)) for develop.

I’ve successfully installed CUDA SDK to /NVIDIA_GPU_Computing_SDK and command make in ‘C’ directory was success.

I tried to write CUDA “hello world” program.

this is it:


#include <stdio.h>

#include <cuda.h>

#include <cuda_runtime.h>

global void hello() {

printf("%s", "hello world!\n");


main(int argc, char** argv) {

    hello<<<1, 3>>>(); // i suppose, it must run 3 times (?is it true?)

return 0;



, but when I try compile it, there are some bugs:


vas@red-eye:~/cuda/test$ nvcc main.c

main.c: In function ‘main’:

main.c:10: error: expected expression before ‘<’ token


Could you help me?

(Sorry for language barrier, I’m Russian and I know english less than the Intermediate level. If you’re Russian, please, отвечайте на русском :rolleyes: )

I’m new to this as well, but looks to me like you are just compiling with g++

you need to compile things with <<<…>>> with cudacc - are you using a makefile, and have you named it with CUFILES_sm_11.

Look at some of the other make files for the sample programs to see what is going on.

You can write a whole program as a cu file as long as you limit to one type (that is either sm_11 or sm_13).

also you cannot printf from the GPU side (it will fail to compile)