Skip to content

[BUG] Tests and examples hang on MinGW (Windows) #1720

Closed

Description

@stemann

Describe the bug

C++ tests and examples hang when executed on Windows using MinGW.

To Reproduce

There's a build (which includes tests and examples) of the recent main branch available for download from https://buildkite.com/julialang/yggdrasil/builds/15678#0193d95c-e190-48eb-b664-f0e384591eb5:

Other builds (without examples and tests) are available from https://github.com/JuliaBinaryWrappers/MLX_jll.jl/releases

Dependencies:

tutorial.exe, distributed.exe etc. hangs, and other executables segfault:

~/Downloads/mlx/julia-1.11.2/bin$ ls -la ../../bin/
total 16724
drwx------+ 1 Administrator None        0 Dec 18 19:25 .
drwxr-xr-x+ 1 Administrator None        0 Dec 18 19:20 ..
-rwx------+ 1 Administrator None   134288 Jan  1  1970 distributed.exe
-rwx------+ 1 Administrator None 13080004 Jan  1  1970 libmlx.dll
-rwx------+ 1 Administrator None   177271 Jan  1  1970 linear_regression.exe
-rwx------+ 1 Administrator None   177768 Jan  1  1970 logistic_regression.exe
-rwx------+ 1 Administrator None   133560 Jan  1  1970 metal_capture.exe
-rwx------+ 1 Administrator None  3219625 Jan  1  1970 tests.exe
-rwx------+ 1 Administrator None   180219 Jan  1  1970 tutorial.exe

~/Downloads/mlx/julia-1.11.2/bin $ ../../bin/tests.exe
[doctest] doctest version is "2.4.11"
[doctest] run with "--help" for options
Segmentation fault

~/Downloads/mlx/julia-1.11.2/bin $ ../../bin/tutorial.exe
array([[1, 1],
       [1, 1]], dtype=float32)

# HANG

~/Downloads/mlx/julia-1.11.2/bin $ ../../bin/linear_regression.exe
Segmentation fault

~/Downloads/mlx/julia-1.11.2/bin $ ../../bin/logistic_regression.exe
Segmentation fault

~/Downloads/mlx/julia-1.11.2/bin $ ../../bin/metal_capture.exe
terminate called after throwing an instance of 'std::invalid_argument'
  what():  [new_stream] Cannot make gpu stream without gpu backend.

# HANG

~/Downloads/mlx/julia-1.11.2/bin $ ../../bin/distributed.exe
No communication backend found

# HANG

Expected behavior

Tests to pass, examples to terminate.

Desktop (please complete the following information):

  • OS Version: Windows 2019
  • Version git main @ 070bd43

Additional context

N/A

Activity

  1. awni commented on Dec 18, 2024

    @awni
    Member

    If you're able to figure out where it's hanging or segfaulting.. we might be able to point you in the right direction for debugging / fixing.

  2. stemann commented on Feb 1, 2025

    @stemann
    ContributorAuthor

    The segfaults was due to user error - the MLX libraries built for Julia (except for the macOS ones) are linked to libblastrampoline rather than OpenBLAS; libblastrampoline must be initialised properly, e.g. by setting the env. var. LBT_DEFAULT_LIBS to the path to libopenblas, e.g., LBT_DEFAULT_LIBS=libopenblas.dll, cf. https://github.com/JuliaLinearAlgebra/libblastrampoline/tree/v5.4.0?tab=readme-ov-file#basic-usage

    E.g. using libopenblas from the MinGW set-up in #1806

    ~/Downloads/mlx/julia-1.11.2/bin $ unset LBT_DEFAULT_LIBS
    
    ~/Downloads/mlx/julia-1.11.2/bin $ ../../bin/examples/linear_regression.exe
    Segmentation fault
    
    ~/Downloads/mlx/julia-1.11.2/bin $ export LBT_DEFAULT_LIBS=/c/msys64/ucrt64/bin/libopenblas.dll
    
    ~/Downloads/mlx/julia-1.11.2/bin $ ../../bin/examples/linear_regression.exe
    Loss array(4.53227e-05, dtype=float32), |w - w*| = 0.00336903, Throughput 3689.93 (it/s).
    
    # HANG
    
    ~/Downloads/mlx/julia-1.11.2-win64/julia-1.11.2/bin $ ../../bin/examples/logistic_regression.exe
    Loss array(0.0265936, dtype=float32), Accuracy, array(1, dtype=float32), Throughput 3039 (it/s).
    
    # HANG
    
    ~/Downloads/mlxjulia-1.11.2/bin $ ../../bin/tests.exe
    [doctest] doctest version is "2.4.11"
    [doctest] run with "--help" for options
    C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot open output file 'C:\msys64\tmp\libCf4BroadcastBDf4AddAC_VS_f4f4_6142509188972423790_contiguous.so': Invalid argument
    collect2.exe: error: ld returned 1 exit status
    terminate called after throwing an instance of 'std::runtime_error'
      what():  [Compile::eval_cpu] Failed to compile function Cf4BroadcastBDf4AddAC_VS_f4f4_6142509188972
    

    The MLX v0.21 binaries for Julia on Windows continue to hang though...

    The issue with running gcc on the MinGW system (Invalid argument collect2.exe: error: ld returned 1 exit status) is remedied by the jit_compiler build_command fix in #1806.

  3. stemann commented on Feb 1, 2025

    @stemann
    ContributorAuthor

    Closing this as the hangs does not seem to be an MLX-proper issue, but rather an issue with the binaries built for Julia on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions