From de2cc43681c9da49029e557d75894b2d000d1149 Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Wed, 15 Oct 2025 12:28:37 +0200 Subject: [PATCH] Fix MKL BLAS detection It seems that libiomp5.lib has been renamed to libiomp5md.lib, so the detection was failing. Add another search step with the new library name. TODO: is there a more modern approach? Co-authored-by: Luciano Paz --- pytensor/link/c/cmodule.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pytensor/link/c/cmodule.py b/pytensor/link/c/cmodule.py index 4e269f8be5..40253f199e 100644 --- a/pytensor/link/c/cmodule.py +++ b/pytensor/link/c/cmodule.py @@ -2890,7 +2890,7 @@ def default_blas_ldflags() -> str: if rpath is not None: maybe_add_to_os_environ_pathlist("PATH", rpath) try: - # 1. Try to use MKL with INTEL OpenMP threading + # 1a. Try to use MKL with INTEL OpenMP threading _logger.debug("Checking MKL flags with intel threading") return _check_libs( all_libs, @@ -2906,6 +2906,24 @@ def default_blas_ldflags() -> str: ) except Exception as e: _logger.debug(e) + try: + # 1b. Try to use MKL with INTEL OpenMP threading with renamed iomp5 library + # Ref: + _logger.debug("Checking MKL flags with intel threading, iomp5md") + return _check_libs( + all_libs, + required_libs=[ + "mkl_core", + "mkl_rt", + "mkl_intel_thread", + "iomp5md", + "pthread", + ], + extra_compile_flags=[f"-Wl,-rpath,{rpath}"] if rpath is not None else [], + cxx_library_dirs=cxx_library_dirs, + ) + except Exception as e: + _logger.debug(e) try: # 2. Try to use MKL with GNU OpenMP threading _logger.debug("Checking MKL flags with GNU OpenMP threading")