[英]Tensorflow Installation M1 Mac fails due to termcolor build not working
I have tried to install tensorflow on my M1 Silicon (macOS 12.4) by setting up a new anaconda environment and forcing it to use arm64 builds:我试图通过设置一个新的 anaconda 环境并强制它使用 arm64 构建在我的 M1 Silicon (macOS 12.4) 上安装 tensorflow:
CONDA_SUBDIR=osx-arm64 conda create -n=NAME python=3.9 -c conda-forge --override-channels
and have then followed the developer instructions to use the M1 GPU:然后按照开发人员说明使用 M1 GPU:
conda install -c apple tensorflow-deps
pip3 install tensorflow-macos
But then I get an error for termcolor:但是后来我收到了 termcolor 的错误:
Building wheel for termcolor (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [34 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/private/var/folders/4n/3tkzf7k15n91rlbqlkh8_3t40000gn/T/pip-install-vihezj4s/termcolor_36abf77c455d4254a5130d8246e91754/setup.py", line 37, in <module>
setup(name='termcolor',
File "/Users/.../opt/anaconda3/envs/c.../lib/python3.9/site-packages/setuptools/_distutils/core.py", line 135, in setup
ok = dist.parse_command_line()
File "/Users/.../opt/anaconda3/envs/.../lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 484, in parse_command_line
args = self._parse_command_opts(parser, args)
File "/Users/.../opt/anaconda3/envs/.../lib/python3.9/site-packages/setuptools/dist.py", line 1104, in _parse_command_opts
nargs = _Distribution._parse_command_opts(self, parser, args)
File "/Users/.../opt/anaconda3/envs/.../lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 540, in _parse_command_opts
cmd_class = self.get_command_class(command)
File "/Users/.../opt/anaconda3/envs/.../lib/python3.9/site-packages/setuptools/dist.py", line 951, in get_command_class
self.cmdclass[command] = cmdclass = ep.load()
File "/Users/.../opt/anaconda3/envs/.../lib/python3.9/site-packages/setuptools/_vendor/importlib_metadata/__init__.py", line 194, in load
module = import_module(match.group('module'))
File "/Users/.../opt/anaconda3/envs/.../lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/Users/.../opt/anaconda3/envs/.../lib/python3.9/site-packages/wheel/bdist_wheel.py", line 26, in <module>
from .macosx_libfile import calculate_macosx_platform_tag
File "/Users/.../opt/anaconda3/envs/.../lib/python3.9/site-packages/wheel/macosx_libfile.py", line 41, in <module>
import ctypes
File "/Users/.../opt/anaconda3/envs/.../lib/python3.9/ctypes/__init__.py", line 8, in <module>
from _ctypes import Union, Structure, Array
ImportError: dlopen(/Users/nils/opt/anaconda3/envs/care-reconstruction/lib/python3.9/lib-dynload/_ctypes.cpython-39-darwin.so, 0x0002): Library not loaded: @rpath/libffi.7.dylib
Referenced from: /Users/.../opt/anaconda3/envs/.../lib/python3.9/lib-dynload/_ctypes.cpython-39-darwin.so
Reason: tried: '/Users/.../opt/anaconda3/envs/.../lib/libffi.7.dylib' (no such file), '/Users/.../opt/anaconda3/envs/.../lib/libffi.7.dylib' (no such file), '/Users/.../opt/anaconda3/envs/.../lib/python3.9/lib-dynload/../../libffi.7.dylib' (no such file), '/Users/nils/opt/anaconda3/envs/.../lib/libffi.7.dylib' (no such file), '/Users/.../opt/anaconda3/envs/.../lib/libffi.7.dylib' (no such file), '/Users/.../opt/anaconda3/envs/.../lib/python3.9/lib-dynload/../../libffi.7.dylib' (no such file), '/Users/.../opt/anaconda3/envs/.../lib/libffi.7.dylib' (no such file), '/Users/.../opt/anaconda3/envs/.../bin/../lib/libffi.7.dylib' (no such file), '/Users/.../opt/anaconda3/envs/.../lib/libffi.7.dylib' (no such file), '/Users/.../opt/anaconda3/envs/.../bin/../lib/libffi.7.dylib' (no such file), '/usr/local/lib/libffi.7.dylib' (no such file), '/usr/lib/libffi.7.dylib' (no such file)
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for termcolor
Running setup.py clean for termcolor
Failed to build termcolor
Finishing the installation by adding pip3 install tensorflow-metal
and then loading the module tensorflow in the python3 shell produces the following error:通过添加
pip3 install tensorflow-metal
然后在 python3 shell 中加载模块 tensorflow 来完成安装会产生以下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/.../opt/anaconda3/envs/.../lib/python3.9/site-packages/tensorflow/__init__.py", line 37, in <module>
from tensorflow.python.tools import module_util as _module_util
File "/Users/.../opt/anaconda3/envs/.../lib/python3.9/site-packages/tensorflow/python/__init__.py", line 24, in <module>
import ctypes
File "/Users/.../opt/anaconda3/envs/care-reconstruction/lib/python3.9/ctypes/__init__.py", line 8, in <module>
from _ctypes import Union, Structure, Array
ImportError: dlopen(/Users/.../opt/anaconda3/envs/.../lib/python3.9/lib-dynload/_ctypes.cpython-39-darwin.so, 0x0002): Library not loaded: @rpath/libffi.7.dylib
Referenced from: /Users/.../opt/anaconda3/envs/.../lib/python3.9/lib-dynload/_ctypes.cpython-39-darwin.so
Reason: tried: '/Users/.../opt/anaconda3/envs/.../lib/libffi.7.dylib' (no such file), '/Users/.../opt/anaconda3/envs/.../lib/libffi.7.dylib' (no such file), '/Users/.../opt/anaconda3/envs/.../lib/python3.9/lib-dynload/../../libffi.7.dylib' (no such file), '/Users/.../opt/anaconda3/envs/.../lib/libffi.7.dylib' (no such file), '/Users/.../opt/anaconda3/envs/.../lib/libffi.7.dylib' (no such file), '/Users/.../opt/anaconda3/envs/.../lib/python3.9/lib-dynload/.../libffi.7.dylib' (no such file), '/Users/.../opt/anaconda3/envs/.../lib/libffi.7.dylib' (no such file), '/Users/.../opt/anaconda3/envs/care-reconstruction/bin/../lib/libffi.7.dylib' (no such file), '/Users/.../opt/anaconda3/envs/.../lib/libffi.7.dylib' (no such file), '/Users/.../opt/anaconda3/envs/.../bin/../lib/libffi.7.dylib' (no such file), '/usr/local/lib/libffi.7.dylib' (no such file), '/usr/lib/libffi.7.dylib' (no such file)
Running pip3 uninstall termcolor
and pip3 install termcolor
produces the same installation error.运行
pip3 uninstall termcolor
和pip3 install termcolor
会产生相同的安装错误。
Am I just lost here and there is no functioning M1 Silicon built for termcolor at the moment?我是不是迷路了,目前没有为 termcolor 构建的功能正常的 M1 Silicon? Or did I mess up somewhere?
还是我在某个地方搞砸了?
Ok got it.好的,我知道了。 Somehow the issue was with pip:
不知何故,问题出在 pip 上:
conda uninstall termcolor
conda install termcolor
solved all issues and tensorflow appears to be working (finger's crossed!)解决了所有问题,张量流似乎正在工作(手指交叉!)
Note that tensorflow-macos can only be installed via pip at the moment, so I first need to let the pip built of termcolor fail, remove it with conda and then re-install it.注意tensorflow-macos目前只能通过pip安装,所以我首先需要让termcolor构建的pip失效,用conda去掉,然后重新安装。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.