繁体   English   中英

Tf.graph 在 mac m1 中没有属性“graph”

[英]Tf.graph has no attribute 'graph' in mac m1

[Edit-01] 一条评论告诉我运行print(tensorflow.__file__)结果是None

这是 Tensorflow 中最简单的代码(直接来自网站)

import tensorflow as tf
g = tf.Graph()
with g.as_default():
  # Define operations and tensors in `g`.
  c = tf.constant(30.0)
  assert c.graph is g

这就是我得到的

% /usr/local/bin/python3 /Users/-----/Downloads/eye_contact_gaze_correction-master/gaze_correct
ion_system/things.py
Traceback (most recent call last):
  File "/Users/-----/Downloads/eye_contact_gaze_correction-master/gaze_correction_system/things.py", line 2, in <module>
    g = tf.Graph()
AttributeError: module 'tensorflow' has no attribute 'Graph'

附带说明一下,当我尝试执行pip install tensorflow时,它总是会显示以下错误消息:

ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)
ERROR: No matching distribution found for tensorflow

但是,当我执行pip list时,发生了这种情况:

...
SQLAlchemy                    1.4.32
stack-data                    0.2.0
statsmodels                   0.13.2
sympy                         1.10.1
tables                        3.6.1
tabulate                      0.8.9
TBB                           0.2
tblib                         1.7.0
tenacity                      8.0.1
tensorboard                   2.9.1
tensorboard-data-server       0.6.1
tensorboard-plugin-wit        1.8.1
tensorflow                    2.9.1
tensorflow-estimator          2.9.0
tensorflow-io-gcs-filesystem  0.26.0
termcolor                     1.1.0
terminado                     0.13.1
testpath                      0.5.0
text-unidecode                1.3
textdistance                  4.2.1
threadpoolctl                 2.2.0
three-merge                   0.1.1
tifffile                      2021.7.2
tinycss                       0.4
...

显然 tensorflow 已安装,但它无法运行模块? 我尝试了很多东西,例如anaconda,苹果的tensorflow-metal,以及直接下载tensorflow文件,但这些都不起作用。

M1 MacBook Air

Python 3.10.0

我怎样才能让 tf.graph 工作?

我可以解决这个问题

tensorflow-macos        2.9.2
tensorflow-metal        0.5.0 

安装 Tensorflow 金属插件

python -m pip install tensorflow-macos
python -m pip install tensorflow-metal

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM