-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible context issue using pyvkfft in a multithreaded/multigpu environment #26
Comments
Dear @kkotyk , could you supply a complete self-contained script which allows to reproduce the issue ? From what I see you are using the simple fftn interface, which caches the fft plans. I would not be surprised if the caching mechanism did not manage to switch threads. If you instantiate directly the cuda.VkFFTApp in each thread I suspect that it would work. Alternatively you can try adding the (I normally only use multiprocessing -and creating the contexts inside the process- to avoid this. Though what you report does look like a bug if other cupy functions manage correctly) |
Here is a minimal example that replicates the issue on 2 different test machines of mine:
I suspect your intuition about App caching is likely the problem. |
I can confirm that taking into account the device when caching solves the issue. Now I just need to finalise the unit tests - it's a bit messy to manipulate GPU contexts through different backends so I'll probably need to encapsulate all in separate process... |
…the VkFFTApp using the pyvkfft.fft interface (#26). Actually use the cuda_stream parameter in the pyvkfft.fft interface.
Thanks for looking at this so quickly. I'm not sure if it helps, but as a user I wouldn't mind if you introduced a |
In the case of cupy, this should be easily taken care of using the Device context manager Beyond that I don't think I can provide any more than examples. Multi-GPU computing can easily be quite complicated. |
Truth |
Hey Vince, I wanted to checkout and test your fixes in this branch but I'm getting the following issue when I try to install with
I am able to install a fresh release version with |
The current git development has some changes to prepare for a reorganisation of the VkFFT headers (see #25) so I'm assuming this is the issue. What version of VkFFT headers are you using ? What is in I think I may use a git submodule to make this simpler. |
…27) * Take into account the current cuda device when automatically caching the VkFFTApp using the pyvkfft.fft interface (#26). Actually use the cuda_stream parameter in the pyvkfft.fft interface. * Add multi-gpu, multi-threaded tests. Use pycuda.driver.Context.get_current() as key for caching. Prevent F-ordered inplace R2C tests with cupy.
Hi @kkotyk, I have just merged a change so that VkFFT will be automatically used as a git submodule, which should be easier to install (I suggest re-checking out pyvkfft, otherwise youmay have to manually init the VkFFT submodule). |
That submodule fix works great. I was easily able to install after that. I ran into another issue trying to run the minimal example I linked before:
My guess is this is typing issue thrown by the lru_cache lib you are using here. |
The minimal example you gave runs fine as far as I can see - I just tested on linux with cupy_cuda11x-12.0.0 and python 3.9. What system are you using ? |
@kkotyk I have changed the way the cuda stream is used as arguments, so the |
Hey Vince, your new changes work for me! I'm not sure what the issue was but this works now! edit: |
Hey Vince, I'm trying to write an app that delegates work to threads to perform FFTs on different gpus. Each thread manages a separate gpu and is in the basic form of:
However, pyvkfft is throwing an exception:
From what I can this an access issue where the code is trying to access data on the wrong GPU. Is this an issue in how pyvkfft is handling context in a multigpu environment, or am I not setting something up correctly for pyvkfft? From my debugging, it looks like all my other Cupy code is respecting the device/stream context. Please let me know if any other information I can provide.
The text was updated successfully, but these errors were encountered: