【发布时间】:2020-10-21 15:24:12
【问题描述】:
我有一个使用 tensorflow 进行机器学习的 python 代码
需要注意的重要一点是,在安装 tensorflow-gpu 之前,代码在 tensorflow 上运行良好。
安装tensorflow-gpu后运行文件报如下错误
File "fileName.py", line 1, in <module>
import tensorflow as tf
File "/home/<xyz>/.local/lib/python3.7/site-packages/tensorflow/__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "/home/<xyz>/.local/lib/python3.7/site-packages/tensorflow/python/__init__.py", line 84, in <module>
from tensorflow.python import keras
File "/home/<xyz>/.local/lib/python3.7/site-packages/tensorflow/python/keras/__init__.py", line 27, in <module>
from tensorflow.python.keras import models
File "/home/<xyz>/.local/lib/python3.7/site-packages/tensorflow/python/keras/models.py", line 24, in <module>
from tensorflow.python.keras import metrics as metrics_module
File "/home/<xyz>/.local/lib/python3.7/site-packages/tensorflow/python/keras/metrics.py", line 37, in <module>
from tensorflow.python.keras.engine import base_layer
File "/home/<xyz>/.local/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py", line 51, in <module>
from tensorflow.python.keras import initializers
File "/home/<xyz>/.local/lib/python3.7/site-packages/tensorflow/python/keras/initializers/__init__.py", line 127, in <module>
populate_deserializable_objects()
File "/home/<xyz>/.local/lib/python3.7/site-packages/tensorflow/python/keras/initializers/__init__.py", line 85, in populate_deserializable_objects
generic_utils.populate_dict_with_module_objects(
AttributeError: module 'tensorflow.python.keras.utils.generic_utils' has no attribute 'populate_dict_with_module_objects'
使用 pip 成功安装了 tensorflow 和 tensorflow-gpu
使用pip show tensorflow检查张量流的安装
Name: tensorflow
Version: 2.2.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages@tensorflow.org
License: Apache 2.0
Location: /home/<xyz>/.local/lib/python3.7/site-packages
Requires: scipy, astunparse, termcolor, tensorboard, grpcio, opt-einsum, tensorflow-estimator, google-pasta, h5py, absl-py, protobuf, six, wheel, gast, wrapt, keras-preprocessing, numpy
Required-by:
使用pip show tensorflow-gpu检查tensorflow-gpu的安装
Name: tensorflow-gpu
Version: 2.2.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages@tensorflow.org
License: Apache 2.0
Location: /home/<xyz>/.local/lib/python3.7/site-packages
Requires: google-pasta, tensorflow-estimator, wrapt, absl-py, termcolor, opt-einsum, keras-preprocessing, six, scipy, h5py, protobuf, wheel, numpy, tensorboard, gast, grpcio, astunparse
Required-by:
我还没有安装 CUDA 驱动程序。会不会是这个问题?
【问题讨论】:
标签: python-3.x tensorflow machine-learning deep-learning pip