Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeInitializationException thrown by aleagpu

Tags:

c#

aleagpu

I am trying to use aleagpu but I get the System.TypeInitializationException. I have tried to google what the problem is but I couldn't find any solution, so please help. The program is the simplest possible:

class Klazz
{
    private const int N = 100;
    private const int Length = 10000000;
    var gpu = Gpu.Default;// here is the Exception thrown          
    public static void Unmanaged()
    {
        var data = new int[Length];

        for (var k = 0; k < N; k++)
            gpu.For(0, data.Length, i => data[i] += 1); 
    }
}

I am imagining that there is something wrong in my installation, because the program is a copied example from aleagpu's homepage.

My system is:

  • Windows 10
  • .NET v4.5.2
  • VS 2015 Community NVIDIA GPU computing toolkit CUDA v8.0

Alea is installed from NuGet November 9. 2016

  • Alea (3.0.1)
  • Alea.IL (2.2.0.3307)
  • Alea.CUDA (2.2.0.3307)
  • Alea.CUDA.IL (2.2.0.3307)
  • Alea.CUDA.Unbound (2.2.0.3307)

The variables in PATH is correct.

I have tried the AleaSample.CS.ParallelForAutoMemMgt as well with the same result.

like image 334
Anders Finn Jørgensen Avatar asked Nov 09 '16 09:11

Anders Finn Jørgensen


2 Answers

It turns out that aleagpu is written in F#, and when you install FSharp.Core the program works. Thanks to Ghosthack answering the question: Alea GPU Tutorial not compiling on VS 2015 Update 2 with FSharp.Core 4.4.0.0

like image 183
Anders Finn Jørgensen Avatar answered Nov 13 '22 12:11

Anders Finn Jørgensen


Also, please make sure that you either install version 2.2 or version 3.x. For the new version 3.x you only need to install the Alea or the Alea.Fody package [https://www.nuget.org/packages/Alea/3.0.1][1] and do not mix with the 2.2 packages.

like image 22
Daniel Avatar answered Nov 13 '22 13:11

Daniel