Skip to content

Commit 799ae67

Browse files
committed
Add a workaround for the tests hanging while loading MKL.
The workaround is to ensure the MKL library is loaded very early in the test process, so it doesn't cause the deadlock. Also, undoing the previous test workarounds now that we've narrowed this hang down. Workaround #1073
1 parent 759ac33 commit 799ae67

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

.vsts-dotnet-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ phases:
1010
name: Windows_NT
1111
buildScript: build.cmd
1212
queue:
13-
name: DotNetCore-Windows
13+
name: Hosted VS2017
1414

1515
- template: /build/ci/phase-template.yml
1616
parameters:

test/Microsoft.ML.Predictor.Tests/TestAutoInference.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public TestAutoInference(ITestOutputHelper helper)
2727
[TestCategory("EntryPoints")]
2828
public void TestLearn()
2929
{
30-
using (var env = new LocalEnvironment()
30+
using (var env = new ConsoleEnvironment()
3131
.AddStandardComponents()) // AutoInference.InferPipelines uses ComponentCatalog to read text data
3232
{
3333
string pathData = GetDataPath("adult.train");
@@ -74,7 +74,7 @@ public void TestLearn()
7474
[Fact(Skip = "Need CoreTLC specific baseline update")]
7575
public void TestTextDatasetLearn()
7676
{
77-
using (var env = new LocalEnvironment()
77+
using (var env = new ConsoleEnvironment()
7878
.AddStandardComponents()) // AutoInference uses ComponentCatalog to find all learners
7979
{
8080
string pathData = GetDataPath(@"../UnitTest/tweets_labeled_10k_test_validation.tsv");
@@ -99,7 +99,7 @@ public void TestTextDatasetLearn()
9999
[Fact]
100100
public void TestPipelineNodeCloning()
101101
{
102-
using (var env = new LocalEnvironment()
102+
using (var env = new ConsoleEnvironment()
103103
.AddStandardComponents()) // RecipeInference.AllowedLearners uses ComponentCatalog to find all learners
104104
{
105105
var lr1 = RecipeInference
@@ -142,7 +142,7 @@ public void TestHyperparameterFreezing()
142142
int batchSize = 1;
143143
int numIterations = 10;
144144
int numTransformLevels = 3;
145-
using (var env = new LocalEnvironment()
145+
using (var env = new ConsoleEnvironment()
146146
.AddStandardComponents()) // AutoInference uses ComponentCatalog to find all learners
147147
{
148148
SupportedMetric metric = PipelineSweeperSupportedMetrics.GetSupportedMetric(PipelineSweeperSupportedMetrics.Metrics.Auc);
@@ -191,7 +191,7 @@ public void TestRegressionPipelineWithMinimizingMetric()
191191
int batchSize = 5;
192192
int numIterations = 10;
193193
int numTransformLevels = 1;
194-
using (var env = new LocalEnvironment()
194+
using (var env = new ConsoleEnvironment()
195195
.AddStandardComponents()) // AutoInference uses ComponentCatalog to find all learners
196196
{
197197
SupportedMetric metric = PipelineSweeperSupportedMetrics.GetSupportedMetric(PipelineSweeperSupportedMetrics.Metrics.AccuracyMicro);
@@ -226,7 +226,7 @@ public void TestLearnerConstrainingByName()
226226
int numIterations = 1;
227227
int numTransformLevels = 2;
228228
var retainedLearnerNames = new[] { $"LogisticRegressionBinaryClassifier", $"FastTreeBinaryClassifier" };
229-
using (var env = new LocalEnvironment()
229+
using (var env = new ConsoleEnvironment()
230230
.AddStandardComponents()) // AutoInference uses ComponentCatalog to find all learners
231231
{
232232
SupportedMetric metric = PipelineSweeperSupportedMetrics.GetSupportedMetric(PipelineSweeperSupportedMetrics.Metrics.Auc);

test/Microsoft.ML.TestFramework/GlobalBase.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// }
1212

1313
using System;
14+
using System.Runtime.InteropServices;
1415
using Xunit;
1516

1617
namespace Microsoft.ML.Runtime.Internal.Internallearn.Test
@@ -22,6 +23,28 @@ public static void AssemblyInit()
2223
System.Diagnostics.Debug.WriteLine("*** Setting test assertion handler");
2324
var prev = Contracts.SetAssertHandler(AssertHandler);
2425
Contracts.Check(prev == null, "Expected to replace null assertion handler!");
26+
27+
// HACK: ensure MklImports is loaded very early in the tests so it doesn't deadlock while loading it later.
28+
// See https://github.com/dotnet/machinelearning/issues/1073
29+
Mkl.PptrfInternal(Mkl.Layout.RowMajor, Mkl.UpLo.Up, 0, Array.Empty<double>());
30+
}
31+
32+
private static class Mkl
33+
{
34+
public enum Layout
35+
{
36+
RowMajor = 101,
37+
ColMajor = 102
38+
}
39+
40+
public enum UpLo : byte
41+
{
42+
Up = (byte)'U',
43+
Lo = (byte)'L'
44+
}
45+
46+
[DllImport("MklImports", EntryPoint = "LAPACKE_dpptrf")]
47+
public static extern int PptrfInternal(Layout layout, UpLo uplo, int n, double[] ap);
2548
}
2649

2750
public static void AssemblyCleanup()

0 commit comments

Comments
 (0)