Re: compiled TF from source. ImportError: cannot import name 'resnet'

984 views
Skip to first unread message

Alexandre Passos

unread,
Jul 30, 2019, 12:02:50 PM7/30/19
to John Beale, Yifei Feng, Discuss
+Yifei Feng do you know what can cause this?

On Tue, Jul 30, 2019 at 8:51 AM John Beale <beale...@gmail.com> wrote:
I am trying to compile Tensorflow from source, because of the AVX issue https://github.com/tensorflow/tensorflow/issues/19584

I'm running Linux Mint on Fitlet2 MiniPC. "uname -a" says:
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" says: Intel(R) Celeron(R) CPU J3455 @ 1.50GHz

Following https://www.tensorflow.org/install/source I did the commands shown below. The "bazel build" line took about 24 hours, and seemed to succeed.

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

However my installation has some problem, as you see below.

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'

 After seeing this error, I then tried:

sudo -H pip3 install --upgrade keras keras-applications

however Ithe same error when loading tensorflow in Python3 results. Any suggestions would be welcome, thank you!

--
You received this message because you are subscribed to the Google Groups "Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss+u...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/discuss/1aa7c368-2537-4538-b036-c09bc40d646a%40tensorflow.org.


--
 - Alex

Paras Patidar

unread,
Jul 30, 2019, 12:32:33 PM7/30/19
to Discuss
Hey Alex,
you can use keras_applications module directly to import all ResNet, ResNetV2 and ResNeXt models.
To unsubscribe from this group and stop receiving emails from it, send an email to dis...@tensorflow.org.


--
 - Alex

John Beale

unread,
Jul 30, 2019, 12:44:29 PM7/30/19
to Discuss
I deleted my original question right after posting, after I saw a notice in this forum that bug reports etc. should go to StackOverflow instead of here. But I guess it was too late! So I put the question here https://stackoverflow.com/questions/57275893/tf-compileinstall-for-python3-cannot-import-name-resnet but I'll still welcome any assistance here :-)

Simply opening Python3 and typing "import keras"  has same error: ImportError: cannot import name 'resnet'
So there's something just plain wrong with my install, but I'm too much of a newbie to understand what.

John Beale

unread,
Jul 30, 2019, 8:50:17 PM7/30/19
to Discuss
FWIW: now solved. I had some still-unknown conflict or misconfiguration. I just installed the same .whl file into a virtual environment, and it's all good now.
Reply all
Reply to author
Forward
0 new messages