Cntk: Support for netcoreapp2.0

Created on 15 Sep 2017  路  61Comments  路  Source: microsoft/CNTK

Is there any plans to bring CNTK to, let's say, .NET Standard 2.0?

feature request

Most helpful comment

.Net Core 2 for Windows is already in master, Linux will follow soon. @davidbrownellMS

All 61 comments

Yes, CNTK C# API will comply with .NET 2.0.

Can I ask for ETA?

I'm getting warning message when import CNTK.GPU from nuget:

Warning NU1701 Package 'CNTK.GPU 2.2.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project. CNTKTest D:\Projects\CNTKTest\CNTKTest\CNTKTest.csproj 1

Isn't .Net Core 2.0 support ship with CNTK 2.2 yet?

@kkc0923 @robinhad
For .NET Core 2.0 support (e.g. Raspberry PI) . One of the main limitations faced by CNTK team is to bring the C++ DLL to ARM OS, in addition to Linux etc.

It will come. Community support is welcome.

Just got CNTK 2.2 released. One of many features added to this release is the Basic C# training API. While we believe CNTK C# API (for training and evaluation) is compatible with .Net core 2.0, we did not package CNTK C# API as a .Net core NuGet. Due to limited resources, we hope someone from the community can pick up this task to make a .net core 2.0 NuGet package.

Regarding, ARM support, I agree with @JimSEOW.

@liqunfu I'm sorry for dummy question, but do you have instructions or materials about this? I could try to do it this week

@robinhad, No problem. @kkc0923 had tried to work with .NetCoew 2.0. How did it go? I guess it requires VS 2017 for .NetCore. I will install VS 2017 and try it out.

@liqunfu Yes, I tried it by using latest VS 2017 + .NetCore 2.0 SDK. Then created ".Net Core Console Application" and imported CNTK.GPU 2.2 from Nuget.

@kkc0923 Is there any hope we can use it in Xamarin by targeting .NET Standard?

@robinhad If CNTK does fully support .NET Standard 2.0 and Nuget Packaging, it will work with Xamarin, but not yet I think

No success with using CNTK on .netcore 2.0, get following warning for both GTPU and CPUOnly

Warning NU1701 Package 'CNTK.GPU 2.2.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.

I use VS2017. Any hints?

AFAIK, Cntk's usage of .Net BCL is very limited, so netstandard 1.0 might be a better choice (the lowest version).

@Ark-kun @robinhad
For CNKT support of XAMRIN, it is a VERY Broad topics.
Xamarin's _To boldly go where no man has gone before_ ( cross platform to many OSs).
One has to be very specific (which OS) when asking how and when CNTK will and can support XAMAIN.

@JimSEOW @Ark-kun
We have this table https://docs.microsoft.com/en-us/dotnet/standard/net-standard
It is about to target lowest .NET Standard version possible to achive maximum portability
@liqunfu I could try to run .NET Portability Analyzer to check what .NET Standard version CNTK can already support

@liqunfu @JimSEOW @Ark-kun
I run Portability Analyzer and got this report (attached).
Instruction how to read this is there: https://github.com/Microsoft/dotnet-apiport/blob/master/docs/HowTo/PlatformPortability.md
Long story short: current code is fully compatible with .NET Standard 2.0, lowest versions require changes, that you can find on Details page in attached report.
CNTKApiPortAnalysis.xlsx
I`m going to change target frameworks and will tell you tomorrow if it worked.

@robinhad Errors concerning the exception classes look like noise. InteropServices.* are more problematic. I guess, HandleRef limits us to 2.0.

@liqunfu @JimSEOW @Ark-kun
I built successfully for .NET Standard and run "Training" unit tests successfully. I will try to run EvalTests this weekend and then will make a PR.

@liqunfu Can you share pretrained models so I can test Eval examples? I don't have GPU to train on.

@cha-zhang Could you share atis.dnn model?

@robinhad If you share with me your email, I can send the model to you. Thanks!

@cha-zhang It seems like I encountered an issue #2260, not related to .NET bindings, but to CNTK itself. Sorry for disturbing you.

@cha-zhang @liqunfu Targeting to .NET Standard also means using VS2017, because no tools for .NET Standard availbale for VS2015. But changing <TargetFrameworkName>v4.5<\TargetFrameworkName> to <TargetFrameworks>netstandard2.0;net45<\TargetFrameworks> leads to error:

platform value cannot be null

and as a result project can't be loaded.

@robinhad VS2017 will need to wait till cuda 9 integrates. This should be done by the end of this iteration.

@cha-zhang Then I will wait until CNTK will be ported to VS2017, there is no sense to do anything related to this issue before it happens.

@cha-zhang Any update on this? I can't seem to find any documentation on the 2.3 release (its blockers, status, whether net standard 2 is in or out, anything about CUDA9's relationship with the release) -- if there's a good central place to track this information, I'd be grateful if you could pass it along.

@ddurschlag , v2.3 hasn't been released and it's due Nov. 14. Please follow our iteration plan here:
https://github.com/Microsoft/CNTK/wiki/Iteration-Plans

Hi @cha-zhang -- it sounds like NetStandard targeting requires VS2k17, and VS2k17 requires CUDA9, and none of these made it for v2.3. Is that correct? If so, is it likely these might make v2.4?

@ebarsoumMS can answer this.

Does v2.3 support .NET Core?

VS2017, CUDA9, cuDNN 7 and fp16 (volta) will be in 2.4 release. .net core if we can get it for 2.4 we will, if not it will be I the next release.

I checked that 2018-01-22 release doesn't have .net core support. Is it postponded to next release?

2018-03-15 release also doesn't have .net core support. Is it postponded to next release?

v.2.5.0 still doesn't have .NET Core support :(

With the move to VS2k17 and CUDA 9 in 2.4, is this now possible? @robinhad -- does that unblock your earlier work? It sounded promising.

I have already translated Signum Framework to .Net Core 2.1, the only missing thing to start translating applications is the CNTK dependency.

I've seen that there is some progress there: https://github.com/Microsoft/CNTK/commits/master/bindings/csharp/CNTKLibraryManagedDll/CNTKLibraryManagedDll.csproj

When can we expect .Net Core support to be ready?

Thanks in advance!

.Net Core 2 for Windows is already in master, Linux will follow soon. @davidbrownellMS

Great! When will be available as Nuget?

Hi again. Any progress on .Net Core?

Having any fuzzy-and-non-compromising estimate of when .Net Core will be supported (even if only for Windows and using pre-release Nuget) will be of great help to start migrating projects.

Thanks in advance.

Hi @olmobrutall it is already in master and work for both Windows and Linux. You should be able to get from the nightly build. You can use the nightly build nuget package.

Maybe I'm doing something wrong then:

image

Should I be using the UWP version?

The way we package the nugets in our Jenkins script is incorrect. It only assumes .net framework and therefore only packs for that one target. I will look into changing the packaging process to have net core packed in nightly build.

Current CNTK 2.6.0-rc0.dev20180731 in nuget does not work with .NET Core project. I wish next CNTK release supports .NET Standard 2.0 :)

Looks like https://github.com/Microsoft/CNTK/blob/master/bindings/csharp/CNTKLibraryManagedDll/CNTKLibraryManagedDll.csproj is already targeting netstandard2.0 so it should work... Any idea @davidbrownellMS?

I would like to unblock this. Is this open for PRs? or only the .snk owners can test it?

The project itself is able to work with both netcore and netframework, it's the way we were packing the nugets. Since PackageManager looks at the lib path(i.e. net45 or netstandard2.0 etc) to determine the target framework, we were always packing the managed DLLs into net45 folder. I fixed our script yesterday to pack for netstandard2.0, but looks like our last nightly Windows build was failing which prevented the nugets from being published to nuget.org. We are looking into getting it all green now.

Any update @Tixxx? :) would love to try it! standing ready to enter dotnet add <proj> package CNTK.CPUOnly --version <newversion> ;)

@Tixxx Awesome work, looking forward to seeing the new nuget package

20 days without a daily 馃様 Problems with publish script? Can we help somehow?

Apologize for the delay everyone. We have been fighting some test failures and infra issues which prevented the nugets from being uploaded. We have pushed a new version of CNTK nugets. I tested them with a net core app and it worked for me. Please give them a try and let me know if you see any issues.

Hi @Tixxx, I鈥檝e tried in a console application and works like a charm. Funny all this virtual dll files in the root folder.

I鈥檝e had problems starting the web application. I鈥檒l try harder tomorrow.

Thanks a lot!馃樅

Sounds good @olmobrutall .
As for the virtual dlls, it's because in our .targets files we have
"PreserveNewest" for each included item, the packageReference style didn't show these in solution explorer but i think with the new SDK-style projects, all externals are shown now. We can try putting False for each item when packing the nugets. Are these dlls causing too much noise for you?

@Tixxx
Thanks for .net core supporting!

For the virtual dlls, some projects (like https://github.com/shimat/opencvsharp ) makes their native dlls into subfolder called "dll/x86/" or "dll/x64" so the project view is very clean.

@Tixxx Also, I found that newest build throw System.StackOverflowException on Trainer.TrainMinibatch().

My code did work with CNTK.GPU v2.5.1 (.NET Framework 4.7.1) and exactly same code throws above exception with CNTK.GPU v2.6.0-rc0.dev20180821 (.NET Core 2.1).

Both test uses saved model and checkpoint data from 2.5.1.

@kkc0923 Thanks for the link.
For the other exception you are seeing, do you mind opening another issue? It would be great if you can paste you code there as well. We have daily end-to-end tests to test that code path and they have been passing all along. If this is a regression, we will need to fix it asap. Thanks.

@Tixxx I created seperated issue ticket with minimum reproducible code. #3368
I hope this will help you.

Another issue that i ran into, https://stackoverflow.com/questions/51974745/how-to-load-a-onnx-model-with-cntk-on-dotnet-core

If i do a normal console app in visual studio and use latest stable version from nuget it loads and works fine. Have not figured out why it dont work with dotnet core/new csproj format.

@Tixxx web app works perfectly too! Thanks!

I created a repro here with a none working 2.6 example: https://github.com/pksorensen/cntk-issue-26

@pksorensen I tested your app, it looks like the exception is agnostic to .net platform but related to cntk version because i see it fails on both net framework and netcore with 2.6.0-rc0.dev20180821 but passes for 2.5.1 on net framework. I'm suspecting this might be related to how the model was generated. That particular "attribute is missing type" exception only happens if the onnx IR version is >= 2 which is the case in 2.6.0, I need to get confirmation of what the IR version is in 2.5.1. Meanwhile if you can refer to this similar issue(https://github.com/onnx/models/issues/9) in ONNX to see if adding type INT on the "axis" attribute in your model helps that would be great. If not, please open another issue for us to track as this thread for net core support topic. Thanks.

Thanks @Tixxx - as i downloaded the model from the model zoo thing, i cannot update it myself. But i will try to see if i can regenerate the onnx file and take it from there.

problem was solved with newer model . thanks @Tixxx

Was this page helpful?
0 / 5 - 0 ratings