Cudafy (BLAS) samples cannot be executed with

401 Views Asked by At

Cannot execute cudafy (BLAS) sample.

Failed on line: GPGPUBLAS blas = GPGPUBLAS.Create(gpu);

Message: Specified method is not supported.

Stack trace:

   at Cudafy.Maths.BLAS.CudaBLAS..ctor(GPGPU gpu)
   at Cudafy.Maths.BLAS.GPGPUBLAS.Create(GPGPU gpu)
   at CUDAFY_Samples.Program.Main(String[] args) in d:\@Igor\SW\GPU\CUDAFY-Samples\Program.cs:line 22
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Error's screen: enter image description here

Test sources copied from http://cudafy.codeplex.com/discussions/331743

static void Main(string[] args)
{
    // Get GPU device
    GPGPU gpu = CudafyHost.GetDevice(CudafyModes.Target);

    // Create GPGPUBLAS (CUBLAS Wrapper)
    GPGPUBLAS blas = GPGPUBLAS.Create(gpu);

    // Prepare sample data
    Random rand = new Random();
    int n = 500;
    double[] cpuVectorX = new double[n];
    double[] cpuVectorY = new double[n];
    double[] cpuMatrixA = new double[n * n];

    for (int i = 0; i < n; i++)
    {
        cpuVectorX[i] = rand.Next(100);
        cpuVectorY[i] = rand.Next(100);
    }

    for (int i = 0; i < n * n; i++)
    {
        cpuMatrixA[i] = rand.Next(100);
    }

    // Copy CPU to GPU memory
    // Before using GPGPUBLAS, You have to copy data from cpu to gpu.
    double[] gpuVectorX = gpu.CopyToDevice(cpuVectorX);
    double[] gpuVectorY = gpu.CopyToDevice(cpuVectorY);
    double[] gpuMatrixA = gpu.CopyToDevice(cpuMatrixA);

    // BLAS1 sample : y = x + y
    blas.AXPY(1.0, gpuVectorX, gpuVectorY);

    // BLAS2 sample : y = Ax + y
    blas.GEMV(n, n, 1.0, gpuMatrixA, gpuVectorX, 1.0, gpuVectorY);

    // Get result from GPU
    gpu.CopyFromDevice<double>(gpuVectorY, cpuVectorY);

    // And you can use result cpuVectorY for any other purpose.
}

UPDATE1 Set platform x64 (instead of "Any CPU") and now next error shown:

Unable to load DLL 'cublas64_70': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

But I have v7.5 installed on my computer. So, I am going to install v7.0 and check the issue again.

1

There are 1 best solutions below

0
On BEST ANSWER
  • Target platform of project should be x64.
  • Copied to bin\DEBUG folder 2 files: cublas64_70.dll and cufft64_70.dll.
  • blas.Dispose() should be added at the end of blas usage.