You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ResourceManagerUtils.DownloadResource aquires mutex on one thread and releases from another #6980
System Information (please complete the following information):
OS & Version: [e.g. Windows 10] Win 11
ML.NET Version: [e.g. ML.NET v1.5.5] latest
.NET Version: [e.g. .NET 5.0] .NET 6.0
Describe the bug
I noticed an exception during local testing. The error from the test was DownloadFailed with exception One or more errors occurred. (Object synchronization method was called from an unsynchronized block of code.) This is happening because we are using a Mutex within an async method.
However an async method that uses ConfigureAwait(false) will not necessarily resume on the same thread.
To Reproduce
Steps to reproduce the behavior:
Delete local copies of ML.NET resources (eg from %TEMP%\mlnet)
Run dotnet test on Microsoft.ML.TorchSharp.Tests
Observe failure, if not observed then repeat from step 1.
Expected behavior
Tests run to completion.
Screenshots, Code, Sample Projects
System.InvalidOperationException : Error downloading resource from 'https://aka.ms/mlnet-resources/models/pretrained_Roberta_encoder.tsm': DownloadFailed with exception One or more errors occurred. (Object synchronization method was called from an unsynchronized block of code.)\\nDownloadFailed with exception One or more errors occurred. (A task was canceled.)\\nDownloadFailed with exception One or more errors occurred. (The wait completed due to an abandoned mutex.)\\nDownloadFailed with exception One or more errors occurred. (A task was canceled.)\\nDownloadFailed with exception One or more errors occurred. (The wait completed due to an abandoned mutex.)\\n\nmodel file could not be downloaded!
at Microsoft.ML.TorchSharp.Roberta.QATrainer.Trainer.GetModelPath() in C:\src\dotnet\machinelearning\src\Microsoft.ML.TorchSharp\Roberta\QATrainer.cs:line 260
changed the title [-]ResourceManagerUtils.DownloadResource aquires mutex on one thread and releases from antother[/-][+]ResourceManagerUtils.DownloadResource aquires mutex on one thread and releases from another[/+]on Feb 8, 2024
I appreciate the effort you put into making nice API's but sooner rather than later, we'll need to be able to use different models for i.e. embedding generation or multilingual scenarios. Having APIs for that would be awesome. For now, I'll follow the Python to ONNX approaches.
& clarity on CUDA compatibility would help a ton! It works in Python but not in my Interactive (Polyglot) notebooks.
For now, the newest GloVe resolved my Semantic Search (Match) case.
Activity
[-]ResourceManagerUtils.DownloadResource aquires mutex on one thread and releases from antother[/-][+]ResourceManagerUtils.DownloadResource aquires mutex on one thread and releases from another[/+]augustevn commentedon Dec 12, 2025
Still happening on the QuestionAnswer trainer.
Packages & versions:
I appreciate the effort you put into making nice API's but sooner rather than later, we'll need to be able to use different models for i.e. embedding generation or multilingual scenarios. Having APIs for that would be awesome. For now, I'll follow the Python to ONNX approaches.
& clarity on CUDA compatibility would help a ton! It works in Python but not in my Interactive (Polyglot) notebooks.
For now, the newest GloVe resolved my Semantic Search (Match) case.
fix: say how to fetch pretrained weights ML.NET could not download
rosebyte commentedon Oct 22, 2026
Triage: it's a bug, we will address it when we have time. It's hitting even our tests sporadically.