Comments (3)
Hi,
cudaContext.Synchronize()
is the driver API equivalent of cudaDeviceSynchronize()
, but you shouldn't actually need to synchronize at all. I guess you don't use streams here, so everything runs implicitly on the 0-stream
.
So why isn't it synchronized? In Cuda 11.0 (or 11.1? I don't remember exactly...), Nvidia changed the behavior of Cuda libraries like cufft with respect to context sharing. You likely create a standard context (aka ManagedCuda.CudaContext
) in your application and then do a call to cufft. Before Cuda 11, cufft would just take over the existing context and run normally. Now it seems that it sort of creates half a new context: sometimes it does work normally, sometimes it doesn't work at all, sometimes it gives strange issues like here.
The fix on the other side is simple: use a primary context. Simply exchange your CudaContext
by PrimaryContext
and it should work!
Instead of
CudaContext ctx = new CudaContext(deviceID);
use
CudaContext ctx = new PrimaryContext(deviceId);
ctx.SetCurrent(); //Important: call this from your processing CPU-thread as primary contexts are not bound initially!
If this doesn't fix the synchronization issue, it still might be that CUFFT runs internally on multiple streams and that you need to explicitly synchronize, I'd have to check the documentation for that though. Anyhow, with the correct context now established, a call to ctx.Synchronize()
now correctly synchronizes the entire GPU-work load.
(Primary context is the type of context used by the cuda runtime API and cuda libraries and was made available through driver API in some earlier cuda versions but not from the beginning on.)
from managedcuda.
Hey,
thank you for the fast reply. You are correct I am not using streams here. I will try your suggestions and will report back if the texture is still visibly broken of if that fixes everything so other will know.
As far as I can say (managed) CuFFT runs on the context created by ManagedCuda without the need to explicitly being told about the context. But it will not run (as far as I remember it threw an exception) when no context was created by ManagedCuda before.
CU, so very helpful your project!
from managedcuda.
Well, as far as I can tell by now your hint to use PrimaryContext
seems to work. So this issue can be closed I guess and others can find it once running into that problem. No Sync needs to be used at all, that was just my assumption why it wasn't working as intended, because the original C++ samples use Sync after each FFT batch execution.
from managedcuda.
Related Issues (20)
- Assembly.GetTypes() problem HOT 2
- cudaFftPlanMany.Exec only works with in place transforms HOT 3
- cudaOccMaxPotentialOccupancyBlockSize fails with A6000 HOT 3
- Big Thanks! HOT 1
- when the NPPJpegCompression project from Sample file is runing will occur the problem,why? HOT 2
- what is the latest nuget package HOT 3
- template<typename T> causes a failure in CudaRuntimeCompiler.Compile() (nvrtcCompileProgram dll) HOT 2
- CudaFFT 2D Array transform HOT 4
- ManagedCuda.CudaException: 'ErrorInvalidPtx: This indicates that a PTX JIT compilation failed.' HOT 3
- Exception with CudaContext.CreateOpenGLContext HOT 7
- (NPP) Shared Library loading issue on Linux HOT 5
- Issues setting GridDimensions and BlockDimensions on CudaKernel for large 2D array HOT 7
- Can you manage the tensorrt library HOT 1
- How do I convert the following code to managedCuda code HOT 1
- Where can I download cuda11 version of managedCuda HOT 1
- ManagedCuda.NVRTC.NVRTCException:“ErrorBuiltinOperationFailure: Builtin operation failure.”
- cudaTextureDesc can not find readMode
- Why `cuD3D11GetDevice` success, but still got a `0` device? HOT 3
- do copy with CudaOpenGLImageInteropResource alwasy returns `ErrorInvalidValue` HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from managedcuda.