inducer / pycuda

CUDA integration for Python, plus shiny features
http://mathema.tician.de/software/pycuda
Other
1.85k stars 288 forks source link

`pycuda._driver.LogicError: cuMemAlloc failed: context is destroyed` (caused by scikit-cuda or even CUDA itself?) #355

Closed dimitsev closed 2 years ago

dimitsev commented 2 years ago

Running the following in a clean python context throws pycuda._driver.LogicError: cuMemAlloc failed: context is destroyed on the last line:

import pycuda.autoinit

import numpy as np
import pycuda
import skcuda
import skcuda.fft as cufft

plan = cufft.Plan((2,2), np.complex64, np.complex64)

del plan # equivalent to `skcuda.cufft.cufftDestroy(plan.handle)`
#skcuda.cufft.cufftDestroy(plan.handle) # equivalent to `del plan`

pycuda.gpuarray.empty((2,2), np.float32)

Deleting the FFT plan in scikit-cuda destroys the pycuda context. This happens no matter if you use del plan or skcuda.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 I want to be able to destroy FFT plans...

(See also my stackoverflow question: https://stackoverflow.com/questions/72218532/deleting-an-fft-plan-in-scikit-cuda-destroys-the-pycuda-context.)

My system: