BLAS GEMM not working

May 17, 2014 at 4:45 AM
Edited May 17, 2014 at 4:48 AM
Hi, I have Cudafy 1.26 and CUDA 5.5 installed. Project is x64 as required by GEMM. Windows 8.1

Kernels run fine, but GEMM is giving an error.
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at Cudafy.Maths.BLAS.CUBLASDriver64Ex.cublasDgemm_v2(cublasHandle handle, cublasOperation transa, cublasOperation transb, Int32 m, Int32 n, Int32 k, Double& alpha, IntPtr A, Int32 lda, IntPtr B, Int32 ldb, Double& beta, IntPtr C, Int32 ldc)
   at Cudafy.Maths.BLAS.CudaBLAS.GEMM(Int32 m, Int32 k, Int32 n, Double alpha, Double[] A, Double[] B, Double beta, Double[] C, cublasOperation transa, cublasOperation transb, Int32 lda, Int32 ldb, Int32 ldc)
All of your test examples run ok. But you dont test BLAS. So I have tried putting GEMM in your cudafy example project and it gives the same error. I have tried float and double.

This is the code.
           GPGPU gpu = CudafyHost.GetDevice(Cudafy.eArchitecture.sm_35);
           CudafyModule km = Cudafy.Translator.CudafyTranslator.Cudafy();
           gpu.SetCurrentContext();
           gpu.LoadModule(km);

           Cudafy.Maths.BLAS.GPGPUBLAS blas = Cudafy.Maths.BLAS.GPGPUBLAS.Create(gpu);
           int N = 1000;
           double[] a = gpu.Allocate<double>(N * N);
           double[] b = gpu.Allocate<double>(N * N);
           double[] c = gpu.Allocate<double>(N * N);
           gpu.SetCurrentContext();

           //  gpu.Launch(n, n * n / n).Relu(a); --- this code runs ok
           blas.GEMM(N, N, N, 1, a, b, 0, c); // --- exception here
            
May 17, 2014 at 5:23 AM
Edited May 17, 2014 at 5:31 AM
same issue as https://cudafy.codeplex.com/discussions/474341

But the problem I was having this time is when I untick VS Hosting Process, it wasnt fixing my project. But I tried it in the examples and when I unticked it, it worked. So my project must be corrupted in some way.

SOLUTION:

OK THIS WAS A REAL PAIN IN THE ASS BUT YOU NEED TO SET YOUR PROJECT TO .Net 4.0, not the default .Net 4.5

so frustrating! I hope this helps future victims.