public static void CheckCudaError(Swigged.Cuda.CUresult res) { if (res != CUresult.CUDA_SUCCESS) { Cuda.cuGetErrorString(res, out IntPtr pStr); var cuda_error = Marshal.PtrToStringAnsi(pStr); throw new Exception("CUDA error: " + cuda_error); } }