Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FastTree does not work in UWP #2444

Open
eerhardt opened this issue Feb 6, 2019 · 2 comments

Comments

Projects
None yet
3 participants
@eerhardt
Copy link
Member

commented Feb 6, 2019

System information

  • OS version/distro: Windows UWP app
  • .NET Version (eg., dotnet --info): UWP

Issue

FastTree is currently always attempting to PrintMemoryStats during training. This is an issue on some platforms (specifically UWP) because these APIs throw exceptions.

We should at least have a way to disable these stats when on platforms that don't support it.

  • What did you do?

Try to train a FastTree model in a UWP app.

  • What happened?

A PlatformNotSupportedException was thrown from the following method:

protected virtual void PrintMemoryStats(IChannel ch)
{
Contracts.AssertValue(ch);
ch.Trace("Training {0}", GetDatasetStatistics(TrainSet));
if (ValidSet != null)
ch.Trace("Validation {0}", GetDatasetStatistics(ValidSet));
if (TestSets != null)
{
for (int i = 0; i < TestSets.Length; ++i)
ch.Trace("ComputeTests[{1}] {0}",
GetDatasetStatistics(TestSets[i]), i);
}
if (AllowGC)
ch.Trace("GC Total Memory = {0} MB", GC.GetTotalMemory(true) / 1024 / 1024);
Process currentProcess = Process.GetCurrentProcess();
ch.Trace("Working Set = {0} MB", currentProcess.WorkingSet64 / 1024 / 1024);
ch.Trace("Virtual Memory = {0} MB",
currentProcess.VirtualMemorySize64 / 1024 / 1024);
ch.Trace("Private Memory = {0} MB",
currentProcess.PrivateMemorySize64 / 1024 / 1024);
ch.Trace("Peak Working Set = {0} MB", currentProcess.PeakWorkingSet64 / 1024 / 1024);
ch.Trace("Peak Virtual Memory = {0} MB",
currentProcess.PeakVirtualMemorySize64 / 1024 / 1024);
}

  • What did you expect?

I expected FastTree to work inside a UWP app.

Source code / logs

On UWP apps, you can't get certain information about local processes - it throws an exception:

System.PlatformNotSupportedException: Retrieving information about local processes is not supported on this platform.
   at System.Diagnostics.NtProcessInfoHelper.GetProcessInfos(Predicate`1 processIdFilter)
   at System.Diagnostics.ProcessManager.GetProcessInfo(Int32 processId, String machineName)
   at System.Diagnostics.Process.EnsureState(State state)
   at System.Diagnostics.Process.get_WorkingSet64()

@Ivanidzo4ka Ivanidzo4ka added the UWP label Feb 21, 2019

@danmosemsft

This comment has been minimized.

Copy link
Member

commented Feb 21, 2019

I believe all of these will throw PlatformNotSupportedException so one option is just to try/catch for that.

            ch.Trace("Working Set = {0} MB", currentProcess.WorkingSet64 / 1024 / 1024);
            ch.Trace("Virtual Memory = {0} MB",
                currentProcess.VirtualMemorySize64 / 1024 / 1024);
            ch.Trace("Private Memory = {0} MB",
                currentProcess.PrivateMemorySize64 / 1024 / 1024);
            ch.Trace("Peak Working Set = {0} MB", currentProcess.PeakWorkingSet64 / 1024 / 1024);
            ch.Trace("Peak Virtual Memory = {0} MB",
                currentProcess.PeakVirtualMemorySize64 / 1024 / 1024);

Incidentally I also see use of Process.Start to launch a URL (?) in FastTree

System.Diagnostics.Process.Start(uri.AbsoluteUri + "content/GamViz/");

If that's URL I'm surprised if it works on .NET Core. In .NET Core, the default value of UseShellExecute is false. That must be true to launch the browser implicitly from a URL. If indeed that's a problem, you should explicitly set UseShellExecute to true for this launch.

Further note that on UWP, if the value is true, it will throw another PlatformNotSupportedException because it doesn't support UseShellExecute=true. You could catch that, potentially.

@danmosemsft

This comment has been minimized.

Copy link
Member

commented Feb 21, 2019

@eerhardt tells me the Process.Start is not an issue:

The Process.Start call appears to be on an internal-only “visualization” command that is only accessible through the ML.NET command line (which isn’t shipping in v1). It is not reachable from public API, so it shouldn’t be a problem.

  • Note: it also depends on being able to start up a web server on the local machine. ☹ Good thing this code is internal.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.