Frederico Schardong
Frederico Schardong

Reputation: 2115

Cuda 5.0 printf not working

I am trying to run the cuda's printf example that I found in this thread:

#include <stdio.h>

__global__ void helloCUDA(float f)
{
  printf("Hello thread %d, f=%f\n", threadIdx.x, f);
}

int main()
{
  helloCUDA<<<1, 5>>>(1.2345f);
  cudaDeviceReset();
  return 0;
}

It's being compiled with:

nvcc -arch=sm_20 test.cu -run

I got no output as well:

$ nvcc -arch=sm_20 test.cu -run
$ 

Here is my cuda version:

$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2012 NVIDIA Corporation
Built on Fri_Sep_21_17:28:58_PDT_2012
Cuda compilation tools, release 5.0, V0.2.1221

I am using bumblebee version 3:

$ optirun --version
optirun (Bumblebee) 3.1
Copyright (C) 2011 The Bumblebee Project

$ uname -a
Linux zeus 3.5.0-25-generic #39-Ubuntu SMP Mon Feb 25 18:26:58 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Upvotes: 1

Views: 2770

Answers (1)

Robert Crovella
Robert Crovella

Reputation: 152173

change that cudaDeviceReset() call to a cudaDeviceSynchronize() call. Also do cuda error checking on the cudaDeviceSynchronize() call. There may be a problem with your GPU or setup.

Upvotes: 3

Related Questions