{"id":43764,"date":"2022-12-22T09:30:00","date_gmt":"2022-12-22T17:30:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/dotnet\/?p=43764"},"modified":"2022-12-22T10:04:36","modified_gmt":"2022-12-22T18:04:36","slug":"accelerate-ml-net-training-with-intel-onedal","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/accelerate-ml-net-training-with-intel-onedal\/","title":{"rendered":"Accelerate ML.NET training with Intel oneDAL"},"content":{"rendered":"<p><a href=\"https:\/\/dot.net\/ml\">ML.NET<\/a> is an open-source, cross-platform machine learning framework for .NET developers that enables integration of custom machine learning models into .NET apps.<\/p>\n<p>Just over a month ago, we released ML.NET 2.0. Thank you for trying it out and giving us feedback.<\/p>\n<p>We&#8217;re not stopping there though and are excited to introduce the first preview release of ML.NET 3.0. This release brings several hardware acceleration improvements that allow you to make the most out of your compute resources during training.<\/p>\n<p>Install the latest <a href=\"https:\/\/aka.ms\/mlnet-3-preview1\" target=\"_blank\" rel=\"noopener\">ML.NET 3.0<\/a> and <a href=\"https:\/\/aka.ms\/mlnet-onedal-nuget\">Intel oneDaL<\/a> preview packages to try out the latest improvements powered by Intel oneDAL and give us feedback.<\/p>\n<h2>What is Intel oneAPI Data Analytics Library (oneDAL)<\/h2>\n<p><a href=\"https:\/\/www.intel.com\/content\/www\/us\/en\/developer\/tools\/oneapi\/onedal.html\">Intel oneAPI Data Analytics Library<\/a> is a library that helps speed up data analysis by providing highly optimized algorithmic building blocks for all stages of the data analytics and machine learning process.<\/p>\n<p>oneDAL makes use of the SIMD extensions in 64-bit architectures, which are featured in Intel and AMD CPUs<\/p>\n<h2>oneDAL components in ML.NET<\/h2>\n<p>oneDAL integrates into ML.NET by accelerating existing trainers during training. Currently, the following ML.NET trainers provide oneDAL support.<\/p>\n<table>\n<thead>\n<tr>\n<th>Trainer<\/th>\n<th>Machine Learning Task<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Ordinary Least Squares<\/td>\n<td>Regression<\/td>\n<\/tr>\n<tr>\n<td>L-BGFS<\/td>\n<td>Classification<\/td>\n<\/tr>\n<tr>\n<td>FastTree<\/td>\n<td>Regression &amp; Classification<\/td>\n<\/tr>\n<tr>\n<td>FastForest<\/td>\n<td>Regression &amp; Classification<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Get started with oneDAL in ML.NET<\/h2>\n<ol>\n<li>Install the latest <a href=\"https:\/\/aka.ms\/mlnet-3-preview1\"><code>Microsoft.ML<\/code> 3.0 preview version<\/a>.\n<pre><code class=\"language-bash\">dotnet add package Microsoft.ML --prerelease<\/code><\/pre>\n<p>If you&#8217;re using <code>OLS<\/code> or <code>FastTree<\/code>, you&#8217;ll have to install additional packages<\/p>\n<pre><code class=\"language-bash\"># Ordinary Least Squares (OLS)\r\ndotnet add package Microsoft.ML.Mkl.Components --prerelease\r\n\r\n# FastTree\r\ndotnet add package Microsoft.ML.FastTree --prerelease<\/code><\/pre>\n<\/li>\n<li>Install the <a href=\"https:\/\/aka.ms\/mlnet-onedal-nuget\">Microsoft.ML.OneDal<\/a> NuGet package.\n<pre><code class=\"language-bash\">dotnet add package Microsoft.ML.OneDal --prerelease\r\n<\/code><\/pre>\n<\/li>\n<li>Set the <code>MLNET_BACKEND<\/code> environment variable to <code>ONEDAL<\/code>. If you&#8217;re using one of the trainers supported by oneDAL, there are no code changes required.<\/li>\n<li>Create a pipeline using one of the oneDAL-supported ML.NET trainers. In this sample, it&#8217;s using <code>LbfgsLogisticRegression<\/code> to train a binary classification model to predict oneDAL support.\n<pre><code class=\"language-csharp\">\/\/ Initialize MLContext\r\nvar ctx = new MLContext();\r\n\r\n\/\/ Define data\r\nvar trainingData = new [] \r\n{\r\n    new {Arch=\"ARM\", Trainer=\"LightGBM\", oneDALSupport=false},\r\n    new {Arch=\"x86\", Trainer=\"FastTree\", oneDALSupport=true},\r\n    new {Arch=\"x86\", Trainer=\"LbfgsLogisticRegression\", oneDALSupport=true},\r\n    new {Arch=\"ARM\", Trainer=\"FastTree\", oneDALSupport=false}\r\n};\r\n\r\n\/\/ Load data into IDataView\r\nvar trainingDv = ctx.Data.LoadFromEnumerable(trainingData);\r\n\r\n\/\/ Define data processing pipeline &amp; trainer\r\nvar pipeline = \r\n    ctx.Transforms.Categorical.OneHotEncoding(new [] {\r\n            new InputOutputColumnPair(\"ArchEncoded\", \"Arch\"),\r\n            new InputOutputColumnPair(\"TrainerEncoded\", \"Trainer\")})\r\n        .Append(ctx.Transforms.Concatenate(\"Features\", \"ArchEncoded\", \"TrainerEncoded\"))\r\n        .Append(ctx.BinaryClassification.Trainers.LbfgsLogisticRegression(labelColumnName:\"oneDALSupport\"));\r\n\r\n\/\/ Train model\r\nvar model = pipeline.Fit(trainingDv)<\/code><\/pre>\n<\/li>\n<li>Train your model.<\/li>\n<\/ol>\n<p>For a more complete example, see this <a href=\"https:\/\/aka.ms\/onedal-sample\">sample<\/a>.<\/p>\n<h2>Known issues<\/h2>\n<p>On Windows, you may see a library loading error. To unblock yourself, add the &#8220;runtimes\\win-x64\\native&#8221; directory in your application &#8220;bin&#8221; directory to the PATH environment variable.<\/p>\n<h2>What&#8217;s next?<\/h2>\n<p>We&#8217;re just getting started with ML.NET 3.0 development and are excited about the improvements and new capabilities we&#8217;re looking to enable. For more details, see the <a href=\"https:\/\/aka.ms\/mlnet-roadmap\">ML.NET roadmap<\/a>.<\/p>\n<h2>Thank you<\/h2>\n<p>We are extremely grateful to our Intel partners as none of these improvements would be possible without them.<\/p>\n<h2>Get started and resources<\/h2>\n<p>Learn more about ML.NET, Model Builder, and the ML.NET CLI in <a href=\"https:\/\/docs.microsoft.com\/dotnet\/machine-learning\/\">Microsoft Docs<\/a>.<\/p>\n<p>If you run into any issues, feature requests, or feedback, please file an issue in the <a href=\"https:\/\/github.com\/dotnet\/machinelearning\/issues\">ML.NET repo<\/a>.<\/p>\n<p>Join the <a href=\"https:\/\/aka.ms\/virtual-mlnet-community-discord\">ML.NET Community Discord<\/a> or #machine-learning channel on the <a href=\"https:\/\/aka.ms\/dotnet-discord\">.NET Development Discord<\/a>.<\/p>\n<p>Tune in to the <a href=\"https:\/\/dotnet.microsoft.com\/live\/community-standup\">Machine Learning .NET Community Standup<\/a> every other Wednesday at 10am Pacific Time.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The first preview release of ML.NET 3.0 brings training hardware acceleration improvements powered by Intel oneDAL.<\/p>\n","protected":false},"author":26108,"featured_media":43765,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[685,328,688,691],"tags":[],"class_list":["post-43764","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dotnet","category-aiml","category-machine-learning","category-ml-dotnet"],"acf":[],"blog_post_summary":"<p>The first preview release of ML.NET 3.0 brings training hardware acceleration improvements powered by Intel oneDAL.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/43764","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/26108"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=43764"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/43764\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/43765"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=43764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=43764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=43764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}