On Sonntag 03 Januar 2010, Ying Wai (Daniel) Fan wrote:
I think you only change the code for detach in
cuda.hpp, but still keep
context.pop in pycuda.autoinit. With context.pop in pycuda.autoinit, I
get the following error when exiting Python after running some cufft code:
terminate called after throwing an instance of 'cuda::error'
what(): cuCtxPushCurrent failed: invalid value
Maybe you still need to change context.pop to context.detach in autoinit.
No, there's something else at work here. Within PyCUDA, context destruction
works as follows: If we are destroying the context that is current to this
thread, detach from it and everything is good. If we are destroying a non-
current context, make it current, and then detach from it. This slightly
circuitous route is necessary because cuCtxDestroy (which Nvidia says should
be used to get rid of non-current contexts) insists on entirely deleting the
context, disregarding its reference count (from Attach/Detach), and
cuCtxDetach requires the context to be current to the calling thread.
Now in your situation there's a failure when reactivating the context to
detach from it, probably because the runtime is meddling about. The only
reason why cuCtxPushCurrent would throw an "invalid value", is, IMO, if that
context is already somewhere in the context stack. So it's likely that the
runtime reactivated the context. In current git, a failure of the PushCurrent
call should not cause a failure any more--it will print a warning instead.
Regarding the complex numbers stuff, I discovered
/usr/local/cuda/include. It includes complex.h from C library if
CU_USE_NATIVE_COMPLEX is defined. Would cuComplex.h or complex.h be a
better way to implement complex numbers?
Do you know to what extent this is documented? I wouldn't like for Nvidia to
be changing this stuff out from under us. Also, since what CUDA version has it
If it pans out, this does sound like a pretty good plan.
By the way, will you attend the PyCon2010 next month?
I'll be there
presenting a poster. If you'll be there, you can consider organizing a
sprint on pycuda.
I'd love to, but my number one priority for the next few months is on
finishing my PhD. This is an excellent idea though--I'd be happy to hang out
on IRC and support such a sprint remotely if there is interest.