kunzmi / managedCuda

ManagedCUDA aims an easy integration of NVidia's CUDA in .net applications written in C#, Visual Basic or any other .net language.
Other
440 stars 79 forks source link

Do you have Examples? #36

Closed RussianDragon closed 7 years ago

RussianDragon commented 7 years ago

Hello. Do you have examples solutions? I try using your library, but I had runtime exception.

DriverAPINativeMethods.cuInit(ManagedCuda.BasicTypes.CUInitializationFlags.None); CudaDeviceVariable windowSize = new CudaDeviceVariable(5);

ErrorInvalidContext: This most frequently indicates that there is no context bound to the current thread. This can also be returned if the context passed to an API call is not a valid handle (such as a context that has had cuCtxDestroy() invoked on it). This can also be returned if a user mixes different API versions (i.e. 3010 context with 3020 API calls). See cuCtxGetApiVersion() for more details.

What should I do?

kunzmi commented 7 years ago

You can find several examples in the Samples folder in the repository. For more (general) information about the needed Cuda context, read chapter H.1 in the Cuda programming guide. In short: You need an active Cuda context per device bound to a CPU-thread in order to use the GPU with Cuda.