【发布时间】:2019-07-30 16:11:31
【问题描述】:
我正在尝试从源代码编译 Tensorflow,因为自 2018 年以来预编译包的 AVX 问题:https://github.com/tensorflow/tensorflow/issues/19584
我在 Fitlet2 MiniPC 上运行 Linux Mint。 “uname -a” 说:
Linux john-fitlet2 4.15.0-55-generic #60-Ubuntu SMP Tue Jul 2 18:22:20 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
“cat /proc/cpuinfo”说:Intel(R) Celeron(R) CPU J3455 @ 1.50GHz
编译+安装后,当我尝试在 Python3 中导入 tensorflow 时失败:
ImportError: cannot import name 'resnet'
我做了什么:跟随https://www.tensorflow.org/install/source,但将 pip 更改为 pip3,我执行了如下所示的命令。 “bazel build”行花了大约 24 小时,似乎成功了。
sudo apt install python3-dev python3-pip
pip3 install -U pip six numpy wheel setuptools mock future>=0.17.1
pip3 install -U keras_applications==1.0.6 --no-deps
pip3 install -U keras_preprocessing==1.0.5 --no-deps
git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow
./configure
bazel build --local_ram_resources=2048 --config=opt //tensorflow/tools/pip_package:build_pip_package
./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
sudo -H pip3 install /tmp/tensorflow_pkg/tensorflow-1.14.0-cp36-cp36m-linux_x86_64.whl
看到问题后,基于在这里用“无法导入名称 resnet”搜索其他问题,我做到了:
sudo -H pip3 install --upgrade keras keras-applications
但我仍然遇到同样的错误,如下所示。
Python 3.6.8 (default, Jan 14 2019, 11:02:34)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/tensorflow/__init__.py", line 99, in <module>
from tensorflow_core import *
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/__init__.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/usr/local/lib/python3.6/dist-packages/tensorflow/__init__.py", line 50, in __getattr__
module = self._load()
File "/usr/local/lib/python3.6/dist-packages/tensorflow/__init__.py", line 44, in _load
module = _importlib.import_module(self.__name__)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/__init__.py", line 83, in <module>
from tensorflow.python import keras
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/__init__.py", line 26, in <module>
from tensorflow.python.keras import activations
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/__init__.py", line 27, in <module>
from tensorflow.python.keras import applications
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/applications/__init__.py", line 64, in <module>
from tensorflow.python.keras.applications.resnet import ResNet50
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/applications/resnet.py", line 22, in <module>
from keras_applications import resnet
ImportError: cannot import name 'resnet'
【问题讨论】:
标签: python-3.x tensorflow keras compilation installation