printf() not working on colab while running a CUDA c++ code
This is my first time working with CUDA programs. So I just wrote a simple hello world program.
#include
__global__ void hello(){
printf("Hello block: %u and thread: %u\n", blockIdx.x, threadIdx.x);
}
int main(){
hello<<<2,2>>>();
cudaDeviceSynchronize();
}
I compiled this using nvcc hello.cu -o hello and ran it using ./hello.
%%shell
nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Thu_Jun__6_02:18:23_PDT_2024
Cuda compilation tools, release 12.5, V12.5.82
Build cuda_12.5.r12.5/compiler.34385749_0
I'm running it on Google Colab using the T4 GPU. When I run the code, I do not get any output printed. Any ideas on how to fix it?