Closed dimitsev closed 2 years ago
My mistake and an easy fix with good advice from the master (https://github.com/inducer/pycuda/discussions/356):
By using pycuda.autoinit, you're putting pycuda in charge of context management. That's not typically a good recipe for interacting with libraries that use the CUDA runtime API (like cuFFT, to my understanding). You might be better off retaining the "primary context" made by/for the runtime API and using that instead.
As stated above, the solution to my problem is retaining the primary context instead of letting pyCUDA create a new context. The easiest way to do this is via:
import pycuda.autoprimaryctx
instead of import pycuda.autoinit
Voila, everything works now. See also the documentation and the code for pycuda.autoprimaryctx
.
Running the following in a clean python context throws
pycuda._driver.LogicError: cuMemAlloc failed: context is destroyed
on the last line:Deleting the FFT plan in scikit-cuda destroys the pycuda context. This happens no matter if you use
del plan
orskcuda.cufft.cufftDestroy(plan.handle)
. So maybe CUDA itself is messing up here.As long as
skcuda.cufft.cufftDestroy()
is not called, everything is ok. But what if I want to call it?(See also my stackoverflow question: https://stackoverflow.com/questions/72218532/deleting-an-fft-plan-in-scikit-cuda-destroys-the-pycuda-context.)
My system: