Search code examples
deep-learningcntkvisual-studio-mac

Microsoft CNTK on NuGet and VisualStudio for Mac


I'm using NuGet on VisualStudio Mac Preview 2 on macOS Sierra 10.12.2

When I try to install Microsoft CNTK packages:

Microsoft.Research.CNTK.CpuEval-acml 1.5.0

Microsoft.Research.CNTK.CpuEval-mkl 1.7.2

I get some errors

Done Building Project "/Users/loretoparisi/Projects/CNTKDemo/CNTKDemo/CNTKDemo.csproj" (restore target(s)) -- FAILED.



Build FAILED.



"/Users/loretoparisi/Projects/CNTKDemo/CNTKDemo/CNTKDemo.csproj" (restore target) (1) ->

(Restore target) -> 

  /Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/xbuild/NuGet.targets : error : Package Microsoft.Research.CNTK.CpuEval-acml 1.5.0 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Microsoft.Research.CNTK.CpuEval-acml 1.5.0 supports: net45 (.NETFramework,Version=v4.5) [/Users/loretoparisi/Projects/CNTKDemo/CNTKDemo/CNTKDemo.csproj]
  /Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/xbuild/NuGet.targets : error : One or more packages are incompatible with .NETCoreApp,Version=v1.0. [/Users/loretoparisi/Projects/CNTKDemo/CNTKDemo/CNTKDemo.csproj]


    0 Warning(s)
    2 Error(s)


Time Elapsed 00:00:01.57

L'applicazione è stata terminata da un segnale: SIGHUP

Install failed. Rolling back...
Executing nuget actions took 3,48 sec
Unable to restore packages.

[UPDATE] Using a .NET Console project it is possibile to install via NuGet pre-release the package CNTK.CPUOnly 2.0.0-beta8. By the way running a basic sample code that is using CNTK package like [this][1] simple example adapted from CNTK Eval examples [here][2] causes a exception:

Unhandled Exception:
System.TypeInitializationException: The type initializer for 'CNTK.CNTKLibPINVOKE' threw an exception. ---> System.TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception. ---> System.DllNotFoundException: CNTKLibraryCSBinding
  at (wrapper managed-to-native) CNTK.CNTKLibPINVOKE+SWIGExceptionHelper:SWIGRegisterExceptionCallbacks_CNTKLib (CNTK.CNTKLibPINVOKE/SWIGExceptionHelper/ExceptionDelegate,CNTK.CNTKLibPINVOKE/SWIGExceptionHelper/ExceptionDelegate,CNTK.CNTKLibPINVOKE/SWIGExceptionHelper/ExceptionDelegate,CNTK.CNTKLibPINVOKE/SWIGExceptionHelper/ExceptionDelegate,CNTK.CNTKLibPINVOKE/SWIGExceptionHelper/ExceptionDelegate,CNTK.CNTKLibPINVOKE/SWIGExceptionHelper/ExceptionDelegate,CNTK.CNTKLibPINVOKE/SWIGExceptionHelper/ExceptionDelegate,CNTK.CNTKLibPINVOKE/SWIGExceptionHelper/ExceptionDelegate,CNTK.CNTKLibPINVOKE/SWIGExceptionHelper/ExceptionDelegate,CNTK.CNTKLibPINVOKE/SWIGExceptionHelper/ExceptionDelegate,CNTK.CNTKLibPINVOKE/SWIGExceptionHelper/ExceptionDelegate)
  at CNTK.CNTKLibPINVOKE+SWIGExceptionHelper..cctor () [0x000ee] in <0337cf7b3aa84dd9ab831eb8b7a1f934>:0 
   --- End of inner exception stack trace ---
  at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_generic_class_init (intptr)
  at CNTK.CNTKLibPINVOKE..cctor () [0x00000] in <0337cf7b3aa84dd9ab831eb8b7a1f934>:0 
   --- End of inner exception stack trace ---
  at CNTK.DeviceDescriptor.GetCPUDevice () [0x00000] in <0337cf7b3aa84dd9ab831eb8b7a1f934>:0 
  at CNTK.DeviceDescriptor.get_CPUDevice () [0x00000] in <0337cf7b3aa84dd9ab831eb8b7a1f934>:0 
  at CNTKDemo.MainClass.Main (System.String[] args) [0x0000b] in /Users/loretoparisi/Documents/Projects/AI/CNTKDemo/CNTKDemo/Program.cs:46 
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'CNTK.CNTKLibPINVOKE' threw an exception. ---> System.TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception. ---> System.DllNotFoundException: CNTKLibraryCSBinding
  at (wrapper managed-to-native) CNTK.CNTKLibPINVOKE+SWIGExceptionHelper:SWIGRegisterExceptionCallbacks_CNTKLib (CNTK.CNTKLibPINVOKE/SWIGExceptionHelper/ExceptionDelegate,CNTK.CNTKLibPINVOKE/SWIGExceptionHelper/ExceptionDelegate,CNTK.CNTKLibPINVOKE/SWIGExceptionHelper/ExceptionDelegate,CNTK.CNTKLibPINVOKE/SWIGExceptionHelper/ExceptionDelegate,CNTK.CNTKLibPINVOKE/SWIGExceptionHelper/ExceptionDelegate,CNTK.CNTKLibPINVOKE/SWIGExceptionHelper/ExceptionDelegate,CNTK.CNTKLibPINVOKE/SWIGExceptionHelper/ExceptionDelegate,CNTK.CNTKLibPINVOKE/SWIGExceptionHelper/ExceptionDelegate,CNTK.CNTKLibPINVOKE/SWIGExceptionHelper/ExceptionDelegate,CNTK.CNTKLibPINVOKE/SWIGExceptionHelper/ExceptionDelegate,CNTK.CNTKLibPINVOKE/SWIGExceptionHelper/ExceptionDelegate)
  at CNTK.CNTKLibPINVOKE+SWIGExceptionHelper..cctor () [0x000ee] in <0337cf7b3aa84dd9ab831eb8b7a1f934>:0 
   --- End of inner exception stack trace ---
  at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_generic_class_init (intptr)
  at CNTK.CNTKLibPINVOKE..cctor () [0x00000] in <0337cf7b3aa84dd9ab831eb8b7a1f934>:0 
   --- End of inner exception stack trace ---
  at CNTK.DeviceDescriptor.GetCPUDevice () [0x00000] in <0337cf7b3aa84dd9ab831eb8b7a1f934>:0 
  at CNTK.DeviceDescriptor.get_CPUDevice () [0x00000] in <0337cf7b3aa84dd9ab831eb8b7a1f934>:0 
  at CNTKDemo.MainClass.Main (System.String[] args) [0x0000b] in /Users/loretoparisi/Documents/Projects/AI/CNTKDemo/CNTKDemo/Program.cs:46 

that is due to the type initializer SWIGExceptionHelper:

System.TypeInitializationException: The type initializer for 'CNTK.CNTKLibPINVOKE' threw an exception. ---> System.TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception. ---> System.DllNotFoundException: CNTKLibraryCSBinding

- References on CNTK Github:see [here][3].
- Filed a Xamarin Bugzilla [here][4]:


  [1]: https://gist.github.com/loretoparisi/61f5c7f8d1a21a7f59771f35c9092de6
  [2]: https://github.com/Microsoft/CNTK/blob/master/Examples/Evaluation/CNTKLibraryCSEvalCPUOnlyExamples/CNTKLibraryCSEvalExamples.cs
  [3]: https://github.com/Microsoft/CNTK/issues/1288#issuecomment-272421564
  [4]: https://bugzilla.xamarin.com/show_bug.cgi?id=51569

Solution

  • The CNTK Eval Nuget Package currently requires .NET 4.5. I do not know whether MonoFramework 4.8 you are using supports it or not. In addition, the C# Eval requires some native dlls which are built for the Intel/AMD X64 platform, I am not sure whether they can directly run on your MAC machine? Another question: do you have any particular reason to use Microsoft.Research.CNTK.CpuEval-acml 1.5.0? It is depreated, we currently use Intel MKL instead of ACML, and the latest version is Microsoft CNTK Eval CPUOnly-mkl NuGet 2.0.0-beta7. Please enable the "include pre-release" option when searching for Nuget packages, otherwise you can only find Microsoft CNTK Eval CPUOnly-mkl NuGet 1.7.2.