Intel MKL加载失败求助:无法加载libmkl_intel_thread.dylib
Intel MKL库加载错误解决方案(Keras模型运行场景)
运行LinkedIn Learning Keras课程03模块的
create_model.py时触发Intel MKL错误,报错信息如下:/Users/dozieanazia/.conda/envs/Exercise Files/bin/python" "/Users/dozieanazia/Dropbox/My Mac (Dozie’s MacBook Pro)/Downloads/Ex_Files_Building_Deep_Learning_Apps/Exercise Files/03/create_model.py" INTEL MKL ERROR: dlopen(/Users/dozieanazia/.conda/envs/Exercise Files/lib/libmkl_intel_thread.dylib, 9): Library not loaded: @rpath/libiomp5.dylib Referenced from: /Users/dozieanazia/.conda/envs/Exercise Files/lib/libmkl_intel_thread.dylib Reason: image not found. Intel MKL FATAL ERROR: Cannot load libmkl_intel_thread.dylib. Process finished with exit code 2环境:2012款MacBook,Python 3.10/3.7 Conda环境,预处理数据文件可正常运行,仅模型创建脚本报错。
解决方案
安装缺失的OpenMP依赖库
MKL核心依赖libiomp5.dylib,通过Conda直接安装对应包:conda install -c conda-forge intel-openmp安装完成后重新运行脚本测试。
修复Conda环境库路径
若安装后仍报错,手动指定库路径环境变量:export DYLD_LIBRARY_PATH="/Users/dozieanazia/.conda/envs/Exercise Files/lib:$DYLD_LIBRARY_PATH"也可将该命令添加到
~/.bash_profile或~/.zshrc中,实现永久生效。切换至无MKL依赖的NumPy版本
若前两种方法无效,替换MKL版NumPy为OpenBLAS版,彻底规避MKL依赖问题:conda install numpy=*=openblas安装完成后,重新安装Keras和TensorFlow:
conda install keras tensorflow验证环境配置
运行以下代码确认环境是否配置成功:import numpy print(numpy.__config__.show())输出含
openblas相关信息即代表切换成功;若仍用MKL,需确认libiomp5.dylib存在于环境lib目录下。
内容的提问来源于stack exchange,提问作者Hyperbeast
相关产品推荐
相关产品推荐

