Unable to load DLL 'curand64_80' - c#

This is my first time trying to run the Alea TK MNIST example on my machine.
I installed CUDA 8 and everything in accordance with http://www.aleagpu.com/release/3_0_2/doc/installation.html
However running it I always get this error: Unable to load DLL 'curand64_80': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Even though I can clearly see the curand64_80.dll in C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin
I've set the configuration as such (app.config):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="aleaSettings" type="Alea.Settings, Alea"/>
</configSections>
<aleaSettings>
<cuBLAS version="8.0"/>
<cuRAND version="8.0"/>
</aleaSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
This is the full exception stack trace:
at Alea.DynamicInterop.curandCreateGenerator.Invoke(IntPtr , RngType )
at A.cdbbf7f52ce1317681b2fa10b7329e78e.-ctor#386-309.Invoke(Unit _arg3)
at Alea.cuRAND.Generator..ctor(FSharpOption`1 cc2af9506f3fc494fecea785eae58ff3b, FSharpOption`1 cdd5e91d5c509dec430918468c49a7937, RngType c23e4321fb7f1de7409a3cd12e2cd5890)
at (FSharpOption`1 , FSharpOption`1 , RngType )
at AleaTK.GpuContext.CreateRandomGenerator(PseudoRandomType type)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at AleaTK.ExprImpl.PseudoRandomExpr`1.Execute(Assignment assignment, ILValue`1 output)
at AleaTK.LExpr`1.Execute(Assignment assignment)
at System.Threading.Tasks.Task.Execute()
What am I missing and how can I run the sample successfully?

Alea GPU 3.0.2 is looking for CUDA toolkit 7.5 by default. You seem to use CUDA toolkit 8.0. You have to configure Alea GPU accordingly. Refer to the documentation for details how to config the CUDA tookit version. Also make sure that you build and run 64 bit because several CUDA libraries are only available in 64bit. HTH.

Update the PATH environment variable to include C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin
I assumed that the CUDA installation would update my PATH environment variable, but it didn't

Related

Applying bindingRedirect config to pythonnet

I have an application that relies on NuGet's <bindingRedirect> feature to ensure a single version of log4net.dll. Binding redirects are automatically added to the applications app.config file.
I'd like to load that application's assemblies into Python and call into its code, but because the binding redirects are application-specific, they're not being picked up by Pythonnet and the assembly fails to load:
LOG: Post-policy reference: log4net, Version=1.2.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a
[...snip...]
LOG: Assembly Name is: log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a
WRN: Comparing the assembly name resulted in the mismatch: Major Version
Can I get pythonnet to refer to my application's app.config and use the <bindingRedirect> found there? Or can I apply a binding redirect after startup, without needing an app.config?
Here is how to enable app.config with pythonnet when using .NET assemblies from CPython:
Place python.exe.config file next python.exe with the following configuration for detection later:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="customAppSettingsGroup">
<section name="customAppSettings" type="System.Configuration.AppSettingsSection, System.Configuration" />
</sectionGroup>
</configSections>
<customAppSettingsGroup>
<customAppSettings>
<add key="Debugger" value="True"/>
</customAppSettings>
</customAppSettingsGroup>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
</configuration>
Generate .NET assembly with the following code for testing and reading app.config settings:
using System;
using System.Collections.Specialized;
using System.Configuration;
namespace dotnet20
{
public class Class1
{
public Class1()
{
NameValueCollection settings =
ConfigurationManager.GetSection("customAppSettingsGroup/customAppSettings") as NameValueCollection;
if (settings != null)
{
foreach (string key in settings.AllKeys)
{
if ((key == "Debugger") && (settings[key] == "True"))
{
Console.WriteLine("Detected debugger mode");
}
}
}
}
}
}
Now test that pythonnet is able to detect these custom settings from app.config:
python
Python 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 16:02:32) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import clr
>>> import sys
>>> sys.path.append(r"C:\pythonnet\dotnet2.0\bin\Debug")
>>> clr.AddReference("dotnet2.0")
<System.Reflection.RuntimeAssembly object at 0x000001A51626D630>
>>> from dotnet20 import Class1
>>> Class1()
Detected debugger mode
<dotnet20.Class1 object at 0x000001A51626D6A0>
>>>
I have got into similar problem using Pythonnet with .net dLLs.
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.
I didn't have Version 3.1.0.0 of Microsoft.Extensions.DependencyInjection.Abstractions and hence the error. My .net project has app.config file which was pointing to a newer version of this dependency ( 3.1.5.0) [ bindingRedirect ]
The solution was to use this app.config file from .net project, rename it to python.exe.config and put it in the same folder where python.exe is. I am not sure if this is the best solution but i have looked in to a bunch of other solutions and this only seems to be working.
You can use pyinstaller (to install with pip: pip install pyintaller see project page) to create a single executable file and place the config file in the same folder.
be able to work with the app.exe.config files on a per project basis.
pyinstaller --onefile script.py
this will create a dist folder inside your current working directory with an exe file (script.exe) and there you can place your script.exe.config file which will parse upon running script.exe

Mono: runtime error: v4.0.30319

I have a big problem with Mono; constantly receiving this error message.
WARNING: The runtime version Supported by This application is unavailable. Using default runtime: v4.0.30319
I have reinstalled the server three times already, but new installs unfortunately always have the same problem.
OS: Debian 7 mini
Mono: full instaled (mono-complet up to date)
PROCON: 1.4.0.6
Link: PROCON usage on Debian 7
If the application starts normally and you only want to suppress the warning, there are two options:
Configuration file
Add the configuration file to the directory where the binary is located, with the name <binary-name>.config, e.g. for application.exe use application.exe.config.
The contents of the file should be as following. Of course, the comment is optional.
<?xml version="1.0" encoding="utf-8"?>
<!-- Add this file to the legacy .NET application folder to prevent:
WARNING: The runtime version supported by this application is unavailable. -->
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
<supportedRuntime version="v4.0"/>
</startup>
</configuration>
Sources
http://do-the-right-things.blogspot.cz/2017/05/the-way-to-suppress-monos-warning.html
https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/#application-configuration-files
Command line
Specify the runtime manually when launching the application.
mono --runtime=v4.0 application.exe
Sources
https://linux.die.net/man/1/mono
Mono on MacOSX - "The runtime version supported by this application is unavailable." v4.5
If you use a dissembler to check the assemblies you should see which CLR version they were built against. My guess is that they were built against 2.0.
Mono 4 removes the old 2.0 CLR and 4.0 CLR (in fact 4.5 profile) becomes the default and the only. So this is simply a warning, not an error.

LINQ stopped working after upgrade to VS 2010 and .NET 4.0

I have started using Visual Studio 2010 recently. I have upgraded my solution from old 2008. After this I have tried to run my project, which is very simple database search engine using linq commands and it worked. Then I have switched to .NET 4 and since then I am dead in the water. Any linq query does not execute, nor any exception is thrown. When I pause while the linq command is being executed, it freezes on DataContext.GetTable() method. All I could come up with were some compatibility issues, but I could not figure out what exactly the problem is.
My Linq command is typical "select *":
var query = from mateInfo in context.TableMateInfos
select mateInfo;
I am using SQL Server 2008. I do not have any clue, why command execution should stop working after upgrade to .NET 4, especially because I am still able to connect to database. When I open DB in Management studio, SQL command (select * from TableMateInfo) works just fine and returns data I want. Does anybody have any ideas, where the burried dog might be please?
EDIT:
I have run my application by its' exe file, following exception has been thrown:
System.IO.FileLoadException: Mixed mode assembly is built against version 'v1.1.4322' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.
at System.Signature.GetSignature(SignatureStruct& signature, Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
at System.Signature..ctor(IRuntimeFieldInfo fieldHandle, RuntimeType declaringType)
at System.Reflection.RtFieldInfo.get_FieldType()
at System.Data.Linq.SqlClient.TypeSystem.GetMemberType(MemberInfo mi)
at System.Data.Linq.Mapping.AttributedMetaDataMember..ctor(AttributedMetaType metaType, MemberInfo mi, Int32 ordinal)
at System.Data.Linq.Mapping.AttributedMetaType.InitDataMembers()
at System.Data.Linq.Mapping.AttributedMetaType..ctor(MetaModel model, MetaTable table, Type type, MetaType inheritanceRoot)
at System.Data.Linq.Mapping.AttributedRootType..ctor(AttributedMetaModel model, AttributedMetaTable table, Type type)
at System.Data.Linq.Mapping.AttributedMetaTable..ctor(AttributedMetaModel model, TableAttribute attr, Type rowType)
at System.Data.Linq.Mapping.AttributedMetaModel.GetTableNoLocks(Type rowType)
at System.Data.Linq.Mapping.AttributedMetaModel.GetTable(Type rowType)
at System.Data.Linq.DataContext.GetTable[TEntity]()
I have added app.config file with following content to the same exact location where exe file and all libraries are located. Still I got the error above.
<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
I think you have Linq namespace problem, Just do one thing
Go to [project name] -> References -> Add reference -> System.Data.Linq
Add System.Data.Linq namespace by Add references.
Hope it solves your problem
Problem was in different versions of .NET used to build single projects after all. The app.config file above would work if there already weren't one without useLegacyV2RuntimeActivationPolicy="true" attribute. I had to add it manually, now it works perfectly.

Failed obtaining configuration for Common.Logging from configuration section 'common/logging'

I'm trying to configure a console application with the following logging assemblies:
Common.Logging.dll (2.1.0.0)
Common.Logging.Log4Net1211.dll (2.1.0.0)
log4net.dll (1.2.11.0)
If the logger gets configured programmatically then everything works fine:
NameValueCollection properties = new NameValueCollection(); properties["showDateTime"] = "true";
Common.Logging.LogManager.Adapter = new Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter(properties);
But if I try to launch it using the following configuration file, it blows up:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
<arg key="configType" value="FILE-WATCH"/>
<arg key="configFile" value="~/Log4NET.xml"/>
</factoryAdapter>
</logging>
</common>
</configuration>
These are the relevant error messages:
{"Unable to cast object of type 'System.Configuration.DefaultSection' to type 'System.Configuration.AppSettingsSection'."}
{"Failed obtaining configuration for Common.Logging from configuration section 'common/logging'."}
It seems to being unable to parse my configuration file, does anyone know what the correct format should be or is it something else that's wrong? I created my configuration file using the official documentation.
I was having this (or related) issue as well and after half a day of error hunting and debugging I narrowed it down to a configuration problem.
The exception was the same as the OP and the inner exception a few level inside of it was failing to find Common.Logging.Log4Net (FileNotFoundException).
It seems that for the Common.Logging.Log4Net1211 NuGet package, they have renamed the assemblyname to be Common.Logging.Log4Net1211 instead of simply Common.Logging.Log4Net. This means in your app.config you need to refer to this new assembly name:
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4net1211">
Here's my entire common/logging section of app.config for reference:
<common>
<logging>
<!-- Notice that it's Log4net1211 -->
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4net1211">
<arg key="configType" value="FILE-WATCH" />
<arg key="configFile" value="~/Log4Net-MAIN.config" />
</factoryAdapter>
</logging>
</common>
There are two problems with your application (the one I downloaded):
Your configSections in app.config looks like this:
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
</configSections>
Notice that the log4net-section is declared twice? Remove the first one.
After removing the first log4net-section, I get the following:
Could not load file or assembly 'log4net, Version=1.2.11.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I downloaded log4net 1.2.11.0 from the log4net website, unzipped it, unblocked the dll and replaced the log4net in your example and it seems to work.
I'm using
Common.Logging v3.3.1.0
with
Common.Logging.Log4Net1213 v3.3.1.0
in ASP.NET Web API v5, which throws exception
"parent configuration sections are not allowed"
Exception is thrown from Common.Logging.ConfigurationSectionHandler.Create method
In order to make this work, I had to grammatically configure the adapter
var properties = new Common.Logging.Configuration.NameValueCollection();
properties["configType"] = "INLINE";
Common.Logging.LogManager.Adapter = new Log4NetLoggerFactoryAdapter(properties);
I still have to figure out why IIS/Express calls the Create method twice, which is causing the exception to be thrown inside the if condition, but at least the pressure is off for now.
I got it working by installing a missing package
Install-Package Common.Logging.Log4Net1211
Although this is an old question, I had this issue a few weeks and none of the current answers seemed to remedy it. It seemed my configuration was correct as I had many other applications using near identical configuration with no issue. After quite a bit of debugging and running through stacktraces, I finally found the issue.
Notice that in IIS, I have the API application hosted under another application. In this case both the CAMP application and the API application under it are both using Common.Logging. Because of this, both web.config files get loaded, Common.Logging reads CAMP's configuration, then it sees that API has configuration and tries to read that as well, sees the Common.Logging section and throws up because it already read that from the CAMP application.
In the end the solution was to move the API out from under the CAMP application in IIS. A bit of an obsucre edge case, but perhaps someone else might face this issue some day.
Can you try with Common.Logging.dll version 2.1.1.0 instead.
You can download and compare the source of the two versions yourself, but as far as I can see the only difference between 2.1.0.0 and 2.1.1.0 is a change relating to reading the configuration settings in order to workaround a Framework 4.0 bug. The description of the bug (see http://support.microsoft.com/kb/2580188) refers to running from a network share which I am not running from a network, yet a test app using 2.1.0.0 generates the same error as you are getting whereas 2.1.1.0 doesn't.
If you are using another library that expects version 2.1.0.0 of common.logging.dll, then you should be able to using an assembly redirect to use 2.1.1.0 instead.
PS
Not sure whether it is relevant, but I left the name of the dll as Common.Logging.Log4Net121.dll and modified the app.config instead
I found that it was due to the Common.Logging.Log4Net1211 NuGet package retrieveing an older version of Common.Logging. Check for NuGet updates to Common.Logging and if you find one download it and try again.
If your log4net is 2.0.6 or above, it may be convenient to use Common.Logging.Log4Net.Universal package.

DllNotFoundException with DllImport in Mono on Mac: wrong architecture

I'm trying to interop with the ImageMagick library in Mono on a Mac. I installed the ImageMagick library with MacPorts and have verified that the file libMagickWand.dylib exists in the directory /opt/local/lib. I've also created a soft link to that file in the directory /usr/local/lib.
Here's my DllImport statement:
[DllImport("libMagickWand", EntryPoint = "MagickWandGenesis")]
static extern void WandGenesis();
Here's my App.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<dllmap dll="libMagickWand" target="/opt/local/lib/libMagickWand.dylib" />
</configuration>
And, at the call to WandGenesis();, I get a DllNotFoundException, with the message 'libMagickWand'.
I've read this page and I think I'm following all the rules. Is there anything else I can try?
Update:
I ran the .exe with MONO_LOG_LEVEL=debug. Here is the pertinent information:
Mono: DllImport error loading library 'dlopen(/opt/local/lib/libMagickWand.5.dylib, 9):
no suitable image found.
Did find: /opt/local/lib/libMagickWand.5.dylib: mach-o, but wrong architecture'.
wrong architecture: I'm running Snow Leopard in 32-bit mode and always have. I installed ImageMagick with MacPorts, and I installed Mono with the Mac package from mono-project.com. What would have been compiled with a different architecture?
Update:
I think I found my problem:
MacBook-Pro:lib ken$ lipo -info libMagickWand.5.dylib
Non-fat file: libMagickWand.5.dylib is architecture: x86_64
Update:
...but I'm still having issues. I can't seem to figure out how to compile ImageMagick with i386 architecture. When I try to do so using flags, it complains about other libraries that were compiled as 64-bit.
Update:
Mono on Mac OS X is 32 bit (at least usually, you can confirm that with mono --version) and you are trying to link with 64bit binary which is not possible. You have to provide 32-bit binary (or use 64-bit Mono).
Do you have the error even when only the library's file name is in the target and the library is placed appropriately (or the DYLD_LIBRARY_PATH set)? In such case please provide the output of mono executed with MONO_LOG_LEVEL=debug.

Categories

Resources