Can I use cufft in both main thread and a thread?

I wrote some codes with multi-thread, i want each thread to use a single GPU
I first run cufft in the main thread, and then create many threads
in each created thread the cufft is used. And all the threads will share the fft plan which is created by the first using.
But I always received some errors from cufft, it said cufft_invalid_value.

Then I move the contents in the created threads into the main thread, let them run in turn in the main thread.
they all work well.

Is it the cufft only run in a single thread? or other reasons?
Or the fft plan can’t be shared in different threads?

By the way, I find cufft is very unstable, any errors which is not related to cufft will result in failure of cufft.
Currently I have to use cufft as a debug tool to find any potential error in my codes. :thumbup:

Thank you.

This is not a feature (or a limitation) only of the cufft: any time you allocate resources on a device those resources may be used only by the thread who allocated it. This problem may be avoided by using a dispatcher but it seems you don’t need it.

Why do you say cufft to be unstable? I’ve never encountered problems with it… what kind of errors does it returns?

Francesco