12 Using Local ML.NET Binaries With NimbusML
pieths редактировал(а) эту страницу 2020-02-18 13:55:17 -08:00
  1. Build ML.Net.

    1. Build the libraries in either debug or release mode. Building in debug mode will add support for debugging from NimbusML in to ML.Net. See here for more information.

      build -debug
      

      or,

      build -release
      
    2. Create the nuget packages out of the libraries built in step (1). Some users have reported requiring -debug or -release as an additional argument to the build command to produce the correct nuget packages.

      build -debug -buildPackages
      

      or,

      build -release -buildPackages
      

      The newly built packages can be found in [YOUR_MLNET_ROOT]\bin\packages.

  2. Add the local nuget package directory created in step (1.ii) to [YOUR_NIMBUSML_ROOT]\nuget.config. The packageSources section provides nuget with the locations that it should check to find any required packages.

      <packageSources>
        <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
        <!-- COMMENT THIS OUT
        <add key="MlNet_Daily" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
        -->
        <add key="local_mlnet" value="[YOUR_MLNET_ROOT]\bin\packages" /> <!-- ADD THIS LINE -->
      </packageSources>
    
  3. Update the versions in the DotNetBridge project file [YOUR_NIMBUSML_ROOT]\src\DotNetBridge\DotNetBridge.csproj to either match the versions of the packages created in step (1.ii) or use the latest version of all the versions nuget finds at the locations specified in step (2). The latter is specified by appending an asterix (*) to the version as shown below. See here for more information: https://docs.microsoft.com/en-us/nuget/concepts/dependency-resolution#floating-versions.

    The wildcard version is preferred over specifying the version explicitly since it will automatically reference the latest packages which requires fewer changes in the long run when the local ML.Net packages are rebuilt. Local ML.Net builds will have an extra build number appended to them so they will get chosen over the version found at nuget.org when they have the same base version. For example, Version="1.5.0-preview*" will select Microsoft.ML.1.5.0-preview2-28613-0 over Microsoft.ML.1.5.0-preview2.

    <PackageReference Include="Microsoft.ML" Version="1.5.0-preview*" />
    <PackageReference Include="Microsoft.ML.CpuMath" Version="1.5.0-preview*" />    
    <PackageReference Include="Microsoft.ML.EntryPoints" Version="0.17.0-preview*" />
    <PackageReference Include="Microsoft.ML.Mkl.Components" Version="1.5.0-preview*" />
    <PackageReference Include="Microsoft.ML.Mkl.Redist" Version="1.5.0-preview*" />
    <PackageReference Include="Microsoft.ML.ImageAnalytics" Version="1.5.0-preview*" />
    <PackageReference Include="Microsoft.ML.LightGBM" Version="1.5.0-preview*" />
    <PackageReference Include="Microsoft.ML.OnnxTransformer" Version="1.5.0-preview*" />
    <PackageReference Include="Microsoft.ML.TensorFlow" Version="1.5.0-preview*" />
    <PackageReference Include="Microsoft.ML.Ensemble" Version="0.17.0-preview*" />
    <PackageReference Include="Microsoft.ML.TimeSeries" Version="1.5.0-preview*" />
    

    In certain special cases, the version of ML.Net needs to be specified explicitly. See the notes at the end of this document for more information.

  4. Update the versions in [YOUR_NIMBUSML_ROOT]\src\Platforms\build.csproj. See step (3) for more information.

    <PackageReference Include="Microsoft.ML" Version="1.5.0-preview*" />
    <PackageReference Include="Microsoft.ML.CpuMath" Version="1.5.0-preview*" />    
    <PackageReference Include="Microsoft.ML.EntryPoints" Version="0.17.0-preview*" />
    <PackageReference Include="Microsoft.ML.Mkl.Components" Version="1.5.0-preview*" />
    <PackageReference Include="Microsoft.ML.ImageAnalytics" Version="1.5.0-preview*" />
    <PackageReference Include="Microsoft.ML.LightGBM" Version="1.5.0-preview*" />
    <PackageReference Include="Microsoft.ML.OnnxTransformer" Version="1.5.0-preview*" />
    <PackageReference Include="Microsoft.ML.TensorFlow" Version="1.5.0-preview*" />
    <PackageReference Include="Microsoft.ML.Ensemble" Version="0.17.0-preview*" />
    <PackageReference Include="Microsoft.ML.TimeSeries" Version="1.5.0-preview*" />
    
  5. Build NimbusML and optionally run the tests.

    1. Remove the nuget cache to avoid referencing stale ML.Net nuget packages.

      On Windows,

      rmdir /S %USERPROFILE%\.nuget
      

      On Linux or Mac,

      rm -rf ~/.nuget/
      
    2. Clean out the repository. This step is optional but recommended to make sure all the previous binaries have been discarded.

      git clean -fxd
      

      If there are issues when running the above command, this might be because there are programs which are actively using some of the files that are trying to be deleted. Try closing Visual Studio and stopping with End task in Task Manager any of its worker services (ie. Visual Studio - Python background analyzer) which may be running in the background.

    3. Build NimbusML.

      build
      

      or, (to build and install the NimbusML wheel file in the dependencies python folder)

      build --installPythonPackages
      

      or, (to build, install the NimbusML wheel file and run all the tests)

      build --runTests
      

Notes

  • To verify that NimbusML is using the ml.net binaries that were built locally, right click on any one of Microsoft.ML.*.dll in [YOUR_NIMBUSML_ROOT]\dependencies\Python3.7\Lib\site-packages\nimbusml\internal\libs and select properties->details. The details page should show the updated version of the library (corresponding to step (1)) and it should also show that the library was built locally.

  • To update the versions of the local ML.Net binaries edit [YOUR_MLNET_ROOT]\build\BranchInfo.props. See nuget.org for the latest published versions of the ml.net libraries.

      <PropertyGroup Condition="'$(IsStableProject)' == 'true'">
        <MajorVersion>1</MajorVersion>
        <MinorVersion>5</MinorVersion>
        <PatchVersion>0</PatchVersion>
        <PreReleaseLabel>preview</PreReleaseLabel>
      </PropertyGroup>
      <PropertyGroup Condition="'$(IsStableProject)' != 'true'">
        <MajorVersion>0</MajorVersion>
        <MinorVersion>17</MinorVersion>
        <PatchVersion>0</PatchVersion>
        <PreReleaseLabel>preview</PreReleaseLabel>
      </PropertyGroup>
    

    If a specific version is required when building NimbusML, replace the Version="" attributes with the appended asterix in steps (3) and (4) with the explicit version.