From 8c56f10c37dc5442055fac4d0d4fffe8f0a25f50 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Mon, 11 Sep 2023 11:35:08 +0200 Subject: [PATCH] Use netlib libblas on macOS to avoid openmp conflicts in MATLAB (#1474) --- README.md | 13 +++++++++++++ scripts/install_robotology_packages.m | 7 ++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8d72a169c..34b22fb81 100644 --- a/README.md +++ b/README.md @@ -319,6 +319,19 @@ and again, specify your MATLAB installation directory and when there is the ques If the problem persists even after following this steps, please [open a new issue in the robotology-superbuild issue tracker](https://github.com/robotology/robotology-superbuild/issues/new). +### How to I solved the "Initializing libomp.dylib, but found libiomp5.dylib already initialized." when using MATLAB libraries? + +If you are on macOS and you encounter errors similar to: +~~~ +OMP: Error #15: Initializing libomp.dylib, but found libiomp5.dylib already initialized. +OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to continue to execute, but that may cause crashes or silently produce incorrect results. For more information, please see http://openmp.llvm.org/ +~~~ +when running MATLAB libraries installed by the robotology-superbuild, a simple workaround is to install the netlib version of libblas via: +~~~ +mamba install libblas=*=*netlib +~~~ + +See https://github.com/robotology/idyntree/issues/1109 for more details. diff --git a/scripts/install_robotology_packages.m b/scripts/install_robotology_packages.m index ca45c7da7..95275d0cf 100644 --- a/scripts/install_robotology_packages.m +++ b/scripts/install_robotology_packages.m @@ -80,7 +80,12 @@ function install_robotology_packages(varargin) % Install all the robotology packages related to MATLAB or Simulink fprintf('Installing robotology packages\n'); - system(sprintf('"%s" install -y -c conda-forge -c robotology yarp-matlab-bindings idyntree-matlab-bindings wb-toolbox osqp-matlab casadi-matlab-bindings whole-body-controllers matlab-whole-body-simulator icub-models', conda_full_path)); + packages_to_install = 'yarp-matlab-bindings idyntree-matlab-bindings wb-toolbox osqp-matlab casadi-matlab-bindings whole-body-controllers matlab-whole-body-simulator icub-models'; + if ismac + % Workaround for https://github.com/robotology/idyntree/issues/1109 + packages_to_install = packages_to_install + " libblas=*=*netlib"; + end + system(sprintf('"%s" install -y -c conda-forge -c robotology %s', conda_full_path, packages_to_install)); fprintf('Installation of robotology packages completed\n'); fprintf('Creating setup script in %s\n', setup_script);