segfault with python + libcudart

The following python code causes a segfault on exit:

from ctypes import c_int, CDLL
cudartlib = CDLL(‘libcudart.so’)
err = cudartlib.cudaSetDevice(c_int(0))

The command works as desired (err=0 and can verify elsewhere that it sets the device correctly), and things go fine until I exit python, and which point the segfault occurs.

This is on 64-bit ubuntu. It work without a segfault on a mac (changing .so to .dylib), but I don’t know if that’s the OS or the fact that it only has one GPU.

Thanks for any insights.

Still stuck on this. Any ideas?

Note that cudaGetDevice() also fails – runs fine but segfaults upon exiting python:
from ctypes import CDLL
cudartlib = CDLL(‘libcudart.so’)
deviceid = cudartlib.cudaGetDevice()
print “Device:”, deviceid

Still stuck on this. Any ideas?

Note that cudaGetDevice() also fails – runs fine but segfaults upon exiting python:
from ctypes import CDLL
cudartlib = CDLL(‘libcudart.so’)
deviceid = cudartlib.cudaGetDevice()
print “Device:”, deviceid

This thread shines some light: http://groups.google.com/group/theano-users/browse_thread/thread/c351846e5cebe35f?pli=1

Looks like we need a cudaThreadExit().