Hi, I have a small project that uses the cuda driver api as well as cufft. The problem is that my first call to the cufft api - cufftPlan2d - returns CUFFT_INVALID_DEVICE. I was able to break it down to the following minimal example.
#include <cuda.h>
#include <cufft.h>
#include <iostream>
int main(int argc, char* argv[])
{
std::cout << "cuInit: " << cuInit(0) << std::endl;
CUcontext ctx;
std::cout << "cuCtxCreate: " << cuCtxCreate(&ctx, 0, 0) << std::endl;
cufftHandle plan;
std::cout << "cufftPlan2d: " << cufftPlan2d(&plan, 4096, 4096, cufftType::CUFFT_R2C) << std::endl;
}
The output is
cuInit: 0
cuCtxCreate: 0
cufftPlan2d: 11
I’m not sure if the cuInit and cuCtxCreate calls are actually needed, removing them as well as #include <cuda.h> doesn’t seem to make a difference. Neither am I sure if I have broken down the example too much and removed function calls that are needed.
There are two things that are curious here:
Firstly, cufftPlan2d is not supposed to return CUFFT_INVALID_DEVICE. At least there is no mention of that in the documentation. https://docs.nvidia.com/cuda/cufft/index.html#function-cufftplan2d
Secondly, the program (my larger project, not this minimal example) used to work a few weeks ago without issue. I have not changed my drivers or libraries since. I only changed a few included files that are unrelated to cufft. At first, I thought I somehow changed the include order thereby screwing something up, but given that the issue persists after I removed all other includes, that doesn’t seem to be the cause.
Any ideas what’s wrong?