[英]Why tensorflow not working after installing tensorflow-gpu in Ubuntu 19.10?
我有一个 python 代码,它使用 tensorflow 进行机器学习
需要注意的重要一点是,在安装 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
检查 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
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 驱动程序。 这可能是问题吗?
此 GitHub 问题处理此问题。 这似乎与tf-nightly
冲突。
尝试:
pip uninstall tf-nightly
pip install tensorflow --upgrade --force-reinstall # Or, tensorflow-gpu
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.