Alea.cubase gpu programming in F# - f#

While running one piece of code using Alea.cuBase I am getting a type initialization exception
let worker = Engine.workers.DefaultWorker
System.TypeInitializationException was unhandled
Message: The type initializer for 'Worker' threw an exception.
I am using
visual studio 2012
.Net frame work 4.0
F# 3.1
Another piece of code I tried and got the same error at,
useprogram = template |> Compiler.loadWorker.Default
I started with trial version of Alea.cuBase 1.3.914.
Guide me how to fix this..

Problem got resolved.
My pc was having graphics card quadro fx 1800.
Because Alea cuBase support fermi or higher architecture.
When I tried with k4000 I could run the same program.

Related

Plotly.NET configuration issue

Problem running Plotly.NET on F# Interactive. (VS2019, FSharp Core 7.0.0, Plotly.NET 3.0.1, TargetFramework: net472)
#r C:\....\.nuget\packages\plotly.net\3.0.1\lib\netstandard2.0\Plotly.NET.dll"
open Plotly.NET
let xData = [0. .. 10.]
let yData = [0. .. 10.]
let myFirstChart = Chart.Point(xData,yData)
Gives an error: " C:\...\AppData\Local\Temp\1\unknown(1,1): error FS3216: type 'Plotly.NET.GenericChart+GenericChart' not found in assembly 'Plotly.NET, Version=3.0.0.0, Culture=neutral, PublicKeyToken=.......'. A possible cause may be a version incompatibility. You may need to explicitly reference the correct version of this assembly to allow all referenced components to use the correct version."
What should be correct configuration for environment to get that running?
I'm not sure why you mention "TargetFramework: net472". Also I'm puzzled by your mention of "FSharp Core 7.0.0", since F# interactive is going to be tied to some specific version of F#, for VS 2019 that won't be 7.0.
It's better to use the new syntax for referencing a nuget package from a script:
#r "nuget: Plotly.NET"
I tried your code in VS 2019 (referencing the nuget package as above) and still got a weird error. I then went to Tools | Options | F# Tools | F# interactive and changed the option "Use .NET Core Scripting" from false to true. I then reset the F# interactive session to make the change take effect, and tried your code again, and it worked.
> let myFirstChart = Chart.Point(xData,yData);;
Binding session to 'C:/Users/jimfo/.nuget/packages/plotly.net/3.0.1/lib/netstandard2.0/Plotly.NET.dll'...
Binding session to 'C:/Users/jimfo/.nuget/packages/dynamicobj/2.0.0/lib/netstandard2.0/DynamicObj.dll'...
val myFirstChart: GenericChart.GenericChart =
Chart
(Plotly.NET.Trace2D, Plotly.NET.Layout, Plotly.NET.Config,
Plotly.NET.DisplayOptions)
I didn't bother testing 32 bit vs 64 bit or seeing what happens in VS 2022.
I don't know what the errors are about, I have seen some strange errors lately given the mix of F# compiler versions, FSharp.Core versions, VS versions (think of all the patched versions), and sometimes you have to just fool around a bit until you get the right combination that works.

InvalidCastException for Z3 in F#

I try to get the Z3 solver up and running in F#. So I created a fresh F# project in Visual Studio, added a reference to Microsoft.Z3.dll, and typed in the following code:
open Microsoft.Z3
let ctx = new Context()
let a = ctx.MkBoolConst("a")
Running this in the interactive window yields the following error:
System.InvalidCastException: Unable to cast object of type 'Microsoft.Z3.AlgebraicNum' to type 'Microsoft.Z3.BoolExpr'.
at Microsoft.Z3.Context.MkBoolConst(String name)
at <StartupCode$FSI_0013>.$FSI_0013.main#() in C:\Users\...\Program.fs:line 3
Stopped due to error
What am I missing?
This sounds very much like https://github.com/Z3Prover/z3/issues/1882
You might have to recompile/reinstall. Follow the instructions in that ticket.

F# interactive Marshal.SizeOf with Mono throws “assertion” error

I am trying to read a GIF file header into a structure with F#, using Mono 5.8 on Mac OSX. The following code sample works fine in Visual Studio 2017 on Windows 10; however, when I try to run it in Visual Studio for Mac, I get the following error in F# interactive:
* Assertion at class-accessors.c:138, condition `mono_class_has_static_metadata (klass)' not met
The code I am using is below. The structure is probably incorrect since I just threw it together quickly for the question, but
open System
open System.IO
open System.Runtime.InteropServices
[<Struct; StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)>]
type GifHeader = {
[<MarshalAs(UnmanagedType.ByValTStr, SizeConst = 3)>]
signature: string
[<MarshalAs(UnmanagedType.ByValTStr, SizeConst = 3)>]
version: string
logicalWidth: int16
logicalHeight: int16
}
When I invoke Marshal.SizeOf(typeof<GifHeader>) in Visual Studio for Mac's FSI, I get the error mentioned above.
I noticed that when I am reading into a structure like:
[<Struct; StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)>]
type SomeOtherHeader = {
field1: uint16
field2: int32
field3: int16
field4: float
}
i.e. with no MarshalAs UnmanagedType specification, the error is not thrown.
Does anyone know what this error means? I haven't seen any other instances of this particular error on Google or other SE posts, and it is especially puzzling since it doesn't occur on Windows/.NET Framework 4.7. Not having the interactive window to test code is a massive hindrance for learning, and quite frustrating since I don't think it's possible to use an alternative (non-Mono) FSI.
This was an issue intrinsic to the current Mono release. Per the Mono team, this has been fixed as of Mono 5.14.

Runtime exception(s) when running an F# benchmark on Mono

I am trying to compare the performance of a specific F# benchmark running on .NET and Mono 2.10.2 (Windows 7, 64-bit). I took the Spectral-Norm benchmark from the Benchmarks Game followed the traditional SO advice of using System.Diagnostics.StopWatch for benchmarking C# and added the lines 4, 89-90, and 93-95 at this link. I compiled this code in Visual Studio 2010 (For runtime 4.0, not client profile, any CPU, with optimize code and tail calls turned on). The compiled code runs just fine on .NET (including inside VS), but when I run the .exe on Mono with "mono shootout_spectralnorm.exe" I get the following error (repeated in the fssnip.net link):
Unhandled Exception: System.TypeInitializationException: An exception was thrown
by the type initializer for System.Diagnostics.Stopwatch ---> System.InvalidPro
gramException: Invalid IL code in System.Diagnostics.Stopwatch:.cctor (): method
body is empty.
--- End of inner exception stack trace ---
at Program.main (System.String[] args) [0x00000] in <filename unknown>:0
The strange thing is, when I remove the lines I had added (lines 4, 89-90, and 93-95, which relate to the timing part of the benchmark), the error goes away on Mono, and it acts just like it does on MS .NET. This is just baffling me. I set all of the referenced assemblies in VS to be copied locally, so they should be visible to Mono, but there could be some precedence issue with different assemblies in the GAC that have the same name as the ones in the local folder. Has anyone encountered this issue or a similar one, especially on Windows Mono? If so, or if you think you know how this problem could be fixed, I hope you can help me resolve it.
Reference Assemblies do not (often) have code - they are API signatures only (enough info for the compiler to reference them at design-time/compile-time). You need to copy the runtime assemblies, not the reference assemblies, in order to run it. (You'll often find the runtime assemblies in the GAC.)
Here are measurements for FSharp-2.0.0.0 spectral-norm #2 (Intel Q6600 quad-core, MS Vista 32 bit)
fsc CPU s Elapsed s
500 0.281 0.337
3000 4.883 1.453
5500 15.85 4.212
2.10.2 CPU s Elapsed s
500 0.343 2.222
3000 4.836 3.361
5500 15.912 6.153
C:/Mono-2.10.2/bin/mono.exe C:/FSharp-2.0.0.0/bin/fsc.exe --platform:x86
--optimize+ --out:spectralnorm.exe spectralnorm.fsharpmono-2.fs
C:/Mono-2.10.2/bin/mono.exe --gc=sgen spectralnorm.exe 5500
Now the benchmarks game spectral-norm on MS Vista demo, includes F# on Mono.

F# on mono in leopard. Seq.cast error

I came across this answered question, but I can't seem to compile the code. I'm getting the following error on Seq.cast:
error FS0039: The value, constructor, namespace or type 'cast' is not defined.
I'm using Mono 2.0.1_1 and F# 1.9.4.19 on leopard. Is there something funky with f# when running under mono?
You need to upgrade to the latest version of F# 1.9.6.2 (also known as the September CTP):
http://www.microsoft.com/downloads/details.aspx?FamilyID=61ad6924-93ad-48dc-8c67-60f7e7803d3c&displaylang=en
Cheers,
Rob
Thanks Rob. That was it. I was able to get around it using map_to_typed in 1.9.4.19.
Seq.map_to_typed (fun e -> e :> System.Xml.XmlNode)

Resources