KMLib Crashing in GTX 770 GPU

223 Views Asked by At

I found the KMLib on the internet and I found it very interesting. But when running the sample application an error appears: "GASS.CUDA.CUDAException" "Error Invalid Source".

The exception occurs in the method:

protected void InitCudaModule () 
     {
         deviceNr int = 0; 
         cuda = new CUDA (deviceNr, true); 
         cuCtx = cuda.CreateContext (deviceNr, CUCtxFlags.MapHost); 
         / / cuda.SetCurrentContext (cuCtx); 

         / / var ctx = cuda.PopCurrentContext (); 
         / / var CTX2 cuda.PopCurrentContext = (); 
         / / var ctx3 cuda.PopCurrentContext = (); 

         modluePath String = Path.Combine (Environment.CurrentDirectory, cudaModuleName); 
         if (! File.Exists (modluePath)) 
             throw new ArgumentException ("Failed to access cuda module" + modluePath); 

         cuModule = cuda.LoadModule (modluePath); / / ERROR! 

         cuFunc = cuda.GetModuleFunction (cudaProductKernelName); 
     } 

I'm using GTX770, Visual Studio 2010 Ultimate, Cuda SDK 5.5 and Windows 7 64-bit.

What can be causing the error?

1

There are 1 best solutions below

0
On

I've had to go through some of the same issues that you went through, but I got it working on my GTX 650 + CUDA 6.5 setup.

I'll describe the changes I had to make into the build/dependencies of KMLIB:

  1. CUDAfy doesn't work for CUDA 6.5: I'm not sure how KMLib uses CUDAfy at all. It might actually NOT be using it for anything except accessing the CUDA.NET API (which is a separate project from CUDAfy that is merged into it). I had to make multiple changes to CUDAfy to make it less brain-damaged than it is, but I'd suggest you attempt replacing the reference with CUDA.NET and see if it really required CUDAfy. If this doesn't work for you, please let me know, and I will find a way to share my CUDAfy/6.5 build with you
  2. The specific GASS.CUDA.CUDAException you've encountered is something that is actually documented on KMLib's web-page, albeit somewhat obscurely:

      -arch=sm_21 or -arch=sm_30 – indicates compute capability, former if for Fermi
      cards(e.g Geforce 470), latter is for Kepler cards (e.g. GeForce 690), it 
      is very important to set this switch depending on yours card compute capability
    

    So the issue you are experiencing has to do with the architecture of the GFX card (Fermi/Kepler/Maxwell) not being in line with the nvcc command-line in the post-build step. I don't know if the sm_30 as the author specifies is correct for the 770 card, but I ended up using the following command line, changing the compute-model, shader-moderl, and the visual-studio path (since CUDA 6.5 usus VS 2013, as was I):

    nvcc -I./ KernelsEllpackCol2.cu KernelsCSR.cu KernelsEllpack.cu KernelsSlicedEllpack.cu gpuFanSmoSolver.cu gpuFOSmoSolver.cu -ccbin "%VS120COMNTOOLS%../../VC/bin" -m64  -cubin -gencode=arch=compute_30,code=sm_30  -Xptxas="-v"
    

    You will need to change the port-build to reflect your build system.