2013-09-05 2 views
0

Windows 7 64x에서 VS 2010을 사용하고 있습니다.테스트 도중 cudafy가 예외를 throw합니다.

다음 코드

namespace Network 
{ 
    public static class Cuda 
    { 
     static GPGPU gpu= CudafyHost.GetDevice(); 
     static CudafyHost host = new CudafyHost(); 
     static GPGPUBLAS blas = GPGPUBLAS.Create(gpu); 

     public static void GEMM(int m, int n, int k, float alpha, float[] a, float[] b, float beta, float[] c,Cudafy.Maths.BLAS.Types.cublasOperation Op) 
     { 
      float[] d_a = gpu.Allocate(a); 
      float[] d_b = gpu.Allocate(b); 
      float[] d_c = gpu.Allocate(c); 

      gpu.CopyToDevice(a, d_a); 
      gpu.CopyToDevice(b, d_b); 
      gpu.CopyToDevice(c, d_c); 

      blas.GEMM(m, n, k, alpha, d_a, d_b, beta, d_c, Op); 

      gpu.CopyFromDevice(d_c, c); 

      gpu.Free(d_a); 
      gpu.Free(d_b); 
      gpu.Free(d_c); 
     } 
    } 
} 

와 정적 클래스 CUDA는을 만들었습니다 그리고 성공적으로 GEMM 기능을 사용하지만, 나는이

`` 
namespace TestProject 
{ 
    [TestClass] 
    public class MatrixTest 
    { 
     /// <summary> 
     ///op_Multiply 
     ///</summary> 
     [TestMethod()] 
     public void op_MultiplyTest() 
     { 


      Matrix a = new Matrix(2,3); 
      a.Data = new float[] { 1, 2, 3, 4, 5, 6 }; 

      Matrix b = new Matrix (3,4); 
      b.Data = new float[] { 1, 0, 2, 3, 1, 2, 0, 4, 2, 1, 1, 0, 3, 0, 1, 1 }; 

      Matrix expected = new Matrix(2, 4); 

      expected.Data = new float[] {11,14,16,22,22,28,4,6}; 

      Matrix actual; 
      actual = (a * b); 
      Assert.AreEqual(expected, actual); 
     } 
    } 
} 
같은 테스트 내 코드를 테스트 할 때

다음 예외가 발생합니다.

System.TypeInitializationException 
Message=Type Initializer "Cudafy.Host.CudafyHost" threw an exception. 
Source=Cudafy.NET 
TypeName=Cudafy.Host.CudafyHost 
StackTrace: 
    в Cudafy.Host.CudafyHost.GetDevice(eGPUType type, Int32 deviceId) 
    в Network.Cuda..cctor() в C:\Users\Dan\Documents\Visual Studio 2010\Projects\Network\Network\Cuda.cs:строка 14 
InnerException: System.InvalidOperationException 
    Message=Category does not exist. 
    Source=System 
    StackTrace: 
     в System.Diagnostics.PerformanceCounterLib.CounterExists(String machine, String category, String counter) 
     в System.Diagnostics.PerformanceCounter.InitializeImpl() 
     в System.Diagnostics.PerformanceCounter..ctor(String categoryName, String counterName, String instanceName, Boolean readOnly) 
     в System.Diagnostics.PerformanceCounter..ctor(String categoryName, String counterName) 
     в Cudafy.Host.EmulatedGPU..ctor(Int32 deviceId) 
     в Cudafy.Host.CudafyHost.DoCreateDevice(eGPUType target, Int32 deviceId) 
     в Cudafy.Host.CudafyHost.CreateDevice(eGPUType type, Int32 deviceId) 
     в Cudafy.Host.CudafyHost.GetDevice(eGPUType type, Int32 deviceId) 
     в Cudafy.Host.CudafyHost..cctor() 
    InnerException: 

문제는 IDE의 cudafy DLL을 두 번 사용하거나 정적 클래스를 두 번 초기화 ...

어떻게 해결할 수 있습니까?

=============== 나는에 cudafy DLL에서 모든 기능을 사용하려고

편집 =============== 내 MatrixTest 클래스입니다. 음, 작동합니다. 하지만 전부는 아닙니다. 예를 들어, Cudaf를 사용할 수있는 장치가없는 것처럼 Cudafy.Host.CudaGPU.GetDeviceCount()는 0을 반환합니다.

그리고 내가 CudafyHost.GetDeviceCount (eGPUType.Cuda) 또는 다른 클래스 CudafyHost에서 같은 smth 사용하려고하면 위의 예외가 발생합니다.

답변

0

표시되는 예외는 시스템의 성능 카테고리가 누락 된 경우입니다. 이것은 분명히 때때로 .NET에서 잘못되는 것입니다. this thread for more information을 참조하십시오. 다음 CUDAfy 릴리스는 이러한 오류를보다 정상적으로 처리합니다.