Here is the code:
[codebox]#include <cuda_runtime.h>
int main(void)
{
cudaSetDevice(0);
return 0;
}[/codebox]
Here is the compilation:
[codebox]gcc -o test main.c -I/usr/local/cuda/include -L/usr/local/cuda/lib64 -lz -lcudart[/codebox]
And here is the crash:
[codebox]$ ./test
Segmentation fault[/codebox]
The backtrace in gdb only shows me this:
[codebox]
#0 0x00007ffff5f34d50 in ?? ()
#1 0x00007ffff7983973 in ?? () from /usr/local/cuda/lib64/libcudart.so.3
#2 0x00007ffff7987b1d in ?? () from /usr/local/cuda/lib64/libcudart.so.3
#3 0x00007ffff79bd169 in ?? () from /usr/local/cuda/lib64/libcudart.so.3
#4 0x00007ffff799e470 in ?? () from /usr/local/cuda/lib64/libcudart.so.3
#5 0x00007ffff796f5df in ?? () from /usr/local/cuda/lib64/libcudart.so.3
#6 0x000000000000000d in ?? ()
#7 0x0000000000000000 in ?? ()
[/codebox]
Passing -lz after -lcudart makes the crash go away, but who knows what else might be silently going wrong.
My environment:
Mandriva Linux 2010.1, kernel 2.6.33.7-desktop-mnb, x86_64
zlib 1.2.3-15mdv2010.1
gcc 4.4.3-2mnb2
nvidia driver 260.24
Cuda compilation tools, release 3.2, V0.2.1221 (the RHEL5.5 binaries)
Can anyone tell me if they can reproduce the crash with the code above by passing -lz before -lcudart?