flatironinstitute / cufinufft

Nonuniform fast Fourier transforms of types 1 and 2, in 1D, 2D, and 3D, on the GPU
Other
83 stars 18 forks source link

Issue with interpolation only option with python wrapper #139

Open headmeister opened 2 years ago

headmeister commented 2 years ago

Hello, I encountered the issue, when I select a gpu_spreadinterponly (I want to only interpolate, I do not need the FFT at this moment). I use this simple code to do the planning, where X and Y are the cartesian dimensions.

plan_a=cufinufft(1,(X,Y),1,eps=1e-6,dtype=np.float32,gpu_spreadinterponly=1)

After calling the planning get the following error:

CUDA error at src/memtransfer_wrapper.cu:175 code=700(cudaErrorIllegalAddress) "cudaMalloc(&d_plan->binsize,numbins[0] numbins[1]sizeof(int))"

PyCUDA ERROR: The context stack was not empty upon module cleanup.

A context was still active when the context stack was being cleaned up. At this point in our execution, CUDA may already have been deinitialized, so there is no way we can finish cleanly. The program will be aborted now. Use Context.pop() to avoid this problem.

I had this issue also with the precompiled version of the cufinufft library for manylinux2010, but after compiling it from source I got it working at least in the NUFFT mode just fine. I wanted to turn the FFT off to use this package in the density compensation calculation, but it fails and no recompilation even with specific gpu architecture helps.

I tried this on two of our systems and got the same error. Both machines are running newest CUDA 11.6.

paquiteau commented 2 years ago

Hi, I have the same problem. I also want to disable FFT setup for the computation of density compensation. I am using CUDA 11.0 and cupy on my end, but I don't think it matters.

I have try to go around the problem by accessing the functions CUFINUFFT_SPREAD2D or CUFINUFFT_SPREAD3D , and their Interp counterpart, without success for two main reasons: 1) The setup of the plan has to be done manually, following what the test/spread2d_test.cu does. 2) I am not that comfortable with using ctype for (mangled) functions with custom type, like the cufinufft_plan

Ideally, end-user should be able to call flawlessy make_plan, set_pts, exec_plan , with or without the fft running (this being setup by opts.gpu_spreadinterponly =1

An alternative is to use tensorflow-nufft and tensorflow-mri: https://mrphys.github.io/tensorflow-mri/api_docs/tfmri/sampling/estimate_density

This requires tensorflow-2.8 and hence has a strong dependency on CUDA 11.2