Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TensorFlow upgrade to 1.0.0 breaking import #7980

Closed
MikeTam1021 opened this issue Mar 1, 2017 · 26 comments
Closed

TensorFlow upgrade to 1.0.0 breaking import #7980

MikeTam1021 opened this issue Mar 1, 2017 · 26 comments
Assignees

Comments

@MikeTam1021
Copy link
Contributor

On the Mac OS X El Capitan V 10.11.6 using python 2.7.11 with anaconda

when I run this code:

pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.9.0-py2-none-any.whl

I get a working version of tensorflow 0.9.0. import tensorflow in python throws no errors.

I type in the command:

pip install --upgrade tensorflow

I get a successful install

Collecting tensorflow
  Using cached tensorflow-1.0.0-cp27-cp27m-macosx_10_11_x86_64.whl
Requirement already up-to-date: mock>=2.0.0 in ./anaconda/lib/python2.7/site-packages (from tensorflow)
Requirement already up-to-date: six>=1.10.0 in ./anaconda/lib/python2.7/site-packages (from tensorflow)
Requirement already up-to-date: numpy>=1.11.0 in ./anaconda/lib/python2.7/site-packages (from tensorflow)
Collecting protobuf>=3.1.0 (from tensorflow)
  Using cached protobuf-3.2.0-py2.py3-none-any.whl
Requirement already up-to-date: wheel in ./anaconda/lib/python2.7/site-packages (from tensorflow)
Requirement already up-to-date: funcsigs>=1; python_version < "3.3" in ./anaconda/lib/python2.7/site-packages (from mock>=2.0.0->tensorflow)
Requirement already up-to-date: pbr>=0.11 in ./anaconda/lib/python2.7/site-packages (from mock>=2.0.0->tensorflow)
Requirement already up-to-date: setuptools in ./anaconda/lib/python2.7/site-packages (from protobuf>=3.1.0->tensorflow)
Requirement already up-to-date: appdirs>=1.4.0 in ./anaconda/lib/python2.7/site-packages (from setuptools->protobuf>=3.1.0->tensorflow)
Requirement already up-to-date: packaging>=16.8 in ./anaconda/lib/python2.7/site-packages (from setuptools->protobuf>=3.1.0->tensorflow)
Requirement already up-to-date: pyparsing in ./anaconda/lib/python2.7/site-packages (from packaging>=16.8->setuptools->protobuf>=3.1.0->tensorflow)
Installing collected packages: protobuf, tensorflow
  Found existing installation: protobuf 3.0.0b2
    Uninstalling protobuf-3.0.0b2:
      Successfully uninstalled protobuf-3.0.0b2
  Found existing installation: tensorflow 0.9.0
    Uninstalling tensorflow-0.9.0:
      Successfully uninstalled tensorflow-0.9.0
Successfully installed protobuf-3.2.0 tensorflow-1.0.0

and I get a broken import statement in python (.. modify dir names)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "../anaconda/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "../anaconda/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 124, in <module>
    from tensorflow.python.platform import test
  File "../anaconda/lib/python2.7/site-packages/tensorflow/python/platform/test.py", line 83, in <module>
    import mock                # pylint: disable=g-import-not-at-top,unused-import
  File "../anaconda/lib/python2.7/site-packages/mock/__init__.py", line 2, in <module>
    import mock.mock as _mock
  File "../anaconda/lib/python2.7/site-packages/mock/mock.py", line 71, in <module>
    _v = VersionInfo('mock').semantic_version()
  File "../anaconda/lib/python2.7/site-packages/pbr/version.py", line 460, in semantic_version
    self._semantic = self._get_version_from_pkg_resources()
  File "../anaconda/lib/python2.7/site-packages/pbr/version.py", line 447, in _get_version_from_pkg_resources
    result_string = packaging.get_version(self.package)
  File "../anaconda/lib/python2.7/site-packages/pbr/packaging.py", line 750, in get_version
    name=package_name))
Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name mock was given, but was not able to be found.

when I import again in the same interface, I get a different error which repeats if I do it anymore

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "../anaconda/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "../anaconda/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 72, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "../anaconda/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 61, in <module>
    from tensorflow.python import pywrap_tensorflow
ImportError: cannot import name pywrap_tensorflow


Failed to load the native TensorFlow runtime.

See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.
@xiaoliangbai
Copy link

xiaoliangbai commented Mar 1, 2017

Same issue here.
Tried to reinstall several times using virtualenv with different settings (--no-site-packages, --system-site-packages, update packages, etc.), no difference made.

List of package versions:
adium-theme-ubuntu==0.3.4
appdirs==1.4.2
attrs==15.2.0
backports-abc==0.4
beautifulsoup4==4.4.1
blinker==1.3
certifi==2016.8.31
characteristic==14.3.0
chardet==2.3.0
command-not-found==0.3
cryptography==1.2.3
cycler==0.10.0
Cython==0.23.4
debtags==2.0
decorator==4.0.6
defer==1.0.6
dirspec==13.10
duplicity==0.7.6
enum34==1.1.2
funcsigs==1.0.2
functools32==3.2.3.post2
gevent==1.1.0
greenlet==0.4.9
h5py==2.5.0
html5lib==0.999
httplib2==0.9.1
idna==2.0
ipaddress==1.0.16
ipdb==0.10.1
ipykernel==4.2.2
ipython==4.0.3
ipython-genutils==0.1.0
ipywidgets==5.2.2
Jinja2==2.8
jsonschema==2.5.1
jupyter==1.0.0
jupyter-client==4.1.1
jupyter-console==5.0.0
jupyter-core==4.0.6
leveldb==0.193
lockfile==0.12.2
lxml==3.7.3
M2Crypto==0.22.6rc4
MarkupSafe==0.23
matplotlib==2.0.0
mistune==0.7.1
mock==2.0.0
nbconvert==4.1.0
nbformat==4.0.1
ndg-httpsclient==0.4.0
networkx==1.11
nose==1.3.7
notebook==4.1.0
numpy==1.12.0
oauthlib==1.0.3
olefile==0.44
oneconf==0.3.9
packaging==16.8
PAM==0.4.2
pandas==0.17.1
path.py==8.1.2
pbr==2.0.0
pexpect==4.2.1
pickleshare==0.6
Pillow==4.0.0
piston-mini-client==0.7.5
pkg-resources==0.0.0
prompt-toolkit==1.0.7
protobuf==3.2.0
psutil==3.4.2
ptyprocess==0.5
pyasn1==0.1.9
pyasn1-modules==0.0.7
pycrypto==2.6.1
pycups==1.9.73
Pygments==2.1
pygobject==3.20.0
PyJWT==1.3.0
pyOpenSSL==0.15.1
pyparsing==2.1.10
pyserial==3.0.1
pysqlite==2.7.0
Pyste==0.9.10
python-apt==1.1.0b1
python-dateutil==1.5
python-debian==0.1.27
python-gflags==2.0
pytz==2014.10
pyxdg==0.25
PyYAML==3.11
pyzmq==15.4.0
qtconsole==4.2.1
scikit-image==0.11.3
scikit-learn==0.18.1
scipy==0.18.1
scour==0.32
service-identity==16.0.0
simplegeneric==0.8.1
singledispatch==3.4.0.3
six==1.10.0
software-center-aptd-plugins==0.0.0
subprocess32==3.2.7
tensorflow==1.0.0
terminado==0.6
tornado==4.4.1
traitlets==4.1.0
Twisted==16.0.0
ubuntuone-client-data==14.4
unity-lens-photos==1.0
update==0.4.4
urllib3==1.13.1
virtualenv==15.0.1
wcwidth==0.1.7
widgetsnbextension==1.2.6
wxPython==3.0.2.0
wxPython-common==3.0.2.0
xlrd==1.0.0
zope.interface==4.1.3

@MikeTam1021
Copy link
Contributor Author

Yeah, I wouldn't expect it to break like that if 0.9.0 works fine. Any necessary updates of packages should be handled at installation.

@gunan
Copy link
Contributor

gunan commented Mar 2, 2017

We test our upgrade script from 0.12 to 1.0
0.9 to 1.0 is a substantial upgrade, I don't think we did test for that.
@aselle any ideas?

@MikeTam1021
Copy link
Contributor Author

Gunan,

I tried all the upgrades in between 0.10.0, 0.11.0, and 0.12.0 and they all have the same problem. 0.9.0 still works when I pip install it though.

@gunan
Copy link
Contributor

gunan commented Mar 2, 2017

Ah, wait now I see.
The issue is you are missing the mock library. Sorry for the confusion.

Could you try running pip install mock and see if that resolves the issue for you?

@tatatodd tatatodd added the stat:awaiting response Status - Awaiting response from author label Mar 2, 2017
@Sergiodiaz53
Copy link

Sergiodiaz53 commented Mar 3, 2017

I'm in macOS 10.12.3 and I have the same error. When I try to install mock it says it is already installed.

Forgot to mention that I'm installing it directly from PIP and not using Anaconda.

@gunan
Copy link
Contributor

gunan commented Mar 3, 2017 via email

@MikeTam1021
Copy link
Contributor Author

No gunan, I have mock. I have used mock before in my own projects. That is not the issue. This appears to be a tensorflow issue and it seems to have appeared when tensorflow went from one version to two versions - one for the CPU and one for the GPU.

@aselle aselle removed the stat:awaiting response Status - Awaiting response from author label Mar 3, 2017
@gunan
Copy link
Contributor

gunan commented Mar 3, 2017

The first stack trace you have in the report is tied to mock.
The 2nd one however, is not.

Tensorflow also had one CPU and one GPU version in 0.9.0, too.
We just renamed the GPU package after 0.9 to help distinguish the pip packages for users.
And the two version thing has been working for thousands of people for months.

I am suspecting pip tool itself may be struggling to update everything correctly. Could you try first uninstalling then reinstalling tensorflow?
Also, with anaconda we see various issues. Can you try the following?

pip uninstall tensorflow
pip install --upgrade --ignore_installed tensorflow

@xiaoliangbai
Copy link

pip install --upgrade --ignore_installed tensorflow

"--ignore_installed" solved the issue in my case. Otherwise some of the packages are using system installed ones instead of in virtual environment.

Thanks!

@MikeTam1021
Copy link
Contributor Author

pip install --upgrade --ignore_installed tensorflow

should be:

pip install --upgrade --ignore-installed tensorflow

and it did not solve my issue... same error as before. But I am not using a virtual environment.

@gunan
Copy link
Contributor

gunan commented Mar 3, 2017

@xiaoliangbai I'm glad the issue is resolved for you.

@MikeTam1021 This is interesting. What is your Anaconda installation located?
Is it possible we need to add "sudo" to all pip commands we have?

@MikeTam1021
Copy link
Contributor Author

My anaconda installation is in my home directory.. I use pip without sudo all the time, so I would imagine we do not need to use sudo. I think I am going to try to start developing in a container. I would really like to get this working though as it would speed my development time.

@gunan
Copy link
Contributor

gunan commented Mar 4, 2017

Sorry for all the inconvenience @MikeTam1021
We are seeing similar issues on Anaconda, I will try to find a macos machine and reproduce your setup.

Have you been using the GPU version, or the CPU version with 0.9?

@MikeTam1021
Copy link
Contributor Author

I believe it is the CPU version

@MikeTam1021
Copy link
Contributor Author

Got it!!!

So, I tried the virtual environment conda install. It worked (but was buggy, as noted). Then I thought "maybe this will work on my native system". It did. Now I can access tensorflow 1.0.0 from my system. Many thanks!

conda install -c conda-forge tensorflow

@ningyuma
Copy link

I encountered the same problem. I tried all the method mentioned but they did not work. How about you? @MikeTam1021

@MikeTam1021
Copy link
Contributor Author

I did a conda install ningyuma. That solved it for me.

@hfranco75
Copy link

hfranco75 commented Apr 12, 2017

@MikeTam1021 the problem is that such solution don't install the GPU version, as it is documented here: https://www.tensorflow.org/install/install_linux

@MikeTam1021
Copy link
Contributor Author

I was not installing the GPU version hfranco. Conda installed worked for me. pip install was breaking on the import statement in the REPL.

@hfranco75
Copy link

@MikeTam1021 Good approach if you are not using CUDA. The other side has the nightmare of installing tensorflow and anaconda alongside

@ajtvsv07
Copy link

ajtvsv07 commented Apr 21, 2017

Still facing the same problem..

i did try the all the above mentioned solution. Nothing worked for me..
tried all in "MacOS 10.12.1" and using virtual environment ...
i am installing CPU version of tensorflow.

@gayathri-menath
Copy link

gayathri-menath commented May 11, 2017

I am also facing the issue. Tensorflow was working fine in my system, but suddenly this problem appears. I am using ubuntu 16.04 and installation is running on virtualenv. My tensorflow verson is tensorflow==1.1.0

from pbr.version import VersionInfo ...: _v = VersionInfo('mock').semantic_version()
The problem is with mock, and my mock version is mock==2.0.0

@imanabbasnejad
Copy link

imanabbasnejad commented May 25, 2017

try this
pip install -U protobuf==3.0.0b2
and in my case it solved the problem

@gayathri-menath
Copy link

@imanabbasnejad Thanks, it solved my problem.

@sevenguin
Copy link

export PBR_VERSION='your pbr version', it's will be worked, but i don't know why VersionInfo('mock') is wrong, maybe setup.cfg in mock has some problem.

copybara-service bot pushed a commit that referenced this issue Jan 5, 2024
Imported from GitHub PR openxla/xla#7980

This PR is originally submited as part of openxla/xla#7940.
It aims to make load/store logic more general so that it can be optimized to vector load/store pattern. It changes IR from
```llvm
%linear_index_plus_base = add nuw nsw i32 %linear_index_base, %loop.indvar
%linear_index1 = add nuw nsw i32 %linear_index_plus_base, 1
%linear_index2 = add nuw nsw i32 %linear_index_plus_base, 2
%linear_index3 = add nuw nsw i32 %linear_index_plus_base, 3

%21 = getelementptr inbounds float, ptr %0, i32 %linear_index_plus_base
%22 = load float, ptr %21, align 4, !invariant.load !4
%26 = getelementptr inbounds float, ptr %0, i32 %linear_index1
%27 = load float, ptr %26, align 4, !invariant.load !4
%31 = getelementptr inbounds float, ptr %0, i32 %linear_index2
%32 = load float, ptr %31, align 4, !invariant.load !4
%36 = getelementptr inbounds float, ptr %0, i32 %linear_index3
%37 = load float, ptr %36, align 4, !invariant.load !4
```
to
```llvm
%linear_index_plus_base = add nuw nsw i32 %linear_index_base, %loop.indvar

%21 = getelementptr float, ptr %0, i32 %linear_index_plus_base
%22 = getelementptr inbounds float, ptr %21, i32 0
%23 = load float, ptr %22, align 4, !invariant.load !4
%29 = getelementptr float, ptr %0, i32 %linear_index_plus_base
%30 = getelementptr inbounds float, ptr %29, i32 1
%31 = load float, ptr %30, align 4, !invariant.load !4
%37 = getelementptr float, ptr %0, i32 %linear_index_plus_base
%38 = getelementptr inbounds float, ptr %37, i32 2
%39 = load float, ptr %38, align 4, !invariant.load !4
%45 = getelementptr float, ptr %0, i32 %linear_index_plus_base
%46 = getelementptr inbounds float, ptr %45, i32 3
%47 = load float, ptr %46, align 4, !invariant.load !4
```
The former one does not always work for different backends since it needs additional pass to handle GEP pattern.

There are only ~20 lines of core code changes, the others are all UTs changes.
Copybara import of the project:

--
df1286a48461dd6337c841d4a353b694ce60bf86 by Sheng, Yang <yang.sheng@intel.com>:

Make vector load/store logic more general

--
66f0782ad62e90e01fd8de7b41d20d607f974844 by Sheng, Yang <yang.sheng@intel.com>:

fix IR in UTs

--
b944ee015c177d4180f9cba6b564cf72e1c80bbc by Sheng, Yang <yang.sheng@intel.com>:

Add comments

Merging this change closes #7980

PiperOrigin-RevId: 595953368
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests