问题
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.
回答1:
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
回答2:
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.
来源:https://stackoverflow.com/questions/40503817/typeinitializationexception-thrown-by-aleagpu