Mac M1 Pro导入TensorFlow报错求助(macOS13.0+Python3.10)
在Mac M1 Pro上Jupyter Lab导入TensorFlow触发NotFoundError错误
环境
- Mac M1 Pro
- macOS 13.0
- Python 3.10
已完成操作
- 下载并安装MiniConda
- 创建Python虚拟环境
- 在虚拟环境内安装
ipykernel,并为Jupyter Lab配置对应新内核
TensorFlow安装流程(遵循Apple官方步骤)
conda install -c apple tensorflow-depspython -m pip install tensorflow-macospython -m pip install tensorflow-metal
错误情况
在Jupyter Lab中选择上述虚拟环境内核,执行import tensorflow as tf时出现以下错误:
NotFoundError Traceback (most recent call last) Cell In[1], line 1 ----> 1 import tensorflow as tf File ~/opt/miniconda3/envs/ImageClassification/lib/python3.10/site-packages/tensorflow/__init__.py:443 441 _plugin_dir = _os.path.join(_s, 'tensorflow-plugins') 442 if _os.path.exists(_plugin_dir): --> 443 _ll.load_library(_plugin_dir) 444 # Load Pluggable Device Library 445 _ll.load_pluggable_device_library(_plugin_dir) File ~/opt/miniconda3/envs/ImageClassification/lib/python3.10/site-packages/tensorflow/python/framework/load_library.py:151, in load_library(library_location) 148 kernel_libraries = [library_location] 150 for lib in kernel_libraries: --> 151 py_tf.TF_LoadLibrary(lib) 153 else: 154 raise OSError( 155 errno.ENOENT, 156 'The file or folder to load kernel libraries from does not exist.', 157 library_location) NotFoundError: dlopen(/Users/felix/opt/miniconda3/envs/ImageClassification/lib/python3.10/site-packages/tensorflow-plugins/libmetal_plugin.dylib, 0x0006): symbol not found in flat namespace '__ZN3tsl8internal10LogMessage16VmoduleActivatedEPKci'
已尝试的解决方案
- 参考Apple开发者论坛及Stack Overflow相关问题的办法并测试
- 重新安装MiniConda,分别尝试TensorFlow最新版本和2.9.0版本
- 曾改用Miniforge,错误依旧
拒绝执行的操作
- 使用Miniforge
- 不安装
tensorflow-deps - 使用mamba
已耗费数小时仍无法解决,求有效解决方法。
内容的提问来源于stack exchange,提问作者Felix Gomez-Guillamon
相关产品推荐
相关产品推荐

