tensorflow: ImportError: cannot import name 'abs'
Windows 10 , CUDA 9 + CUDNN 7, Python3.6(Anaconda5.2)
install the TensorFlow 1.9:
pip install --upgrade tensorflow-gpu
when I import the TensorFlow in ipyhon:
from tensorflow.python.keras._impl.keras.backend import abs ImportError: cannot import name 'abs'
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 66
- Comments: 46 (15 by maintainers)
Thank you for your post. We noticed you have not filled out the following field in the issue template. Could you update them if they are relevant in your case, or leave them as N/A? Thanks. Have I written custom code OS Platform and Distribution TensorFlow installed from TensorFlow version Bazel version CUDA/cuDNN version GPU model and memory Exact command to reproduce
This issue seems to suggest a fix… https://github.com/tensorflow/probability/issues/46
Not sure if these issues have same root cause, but maybe something to try before a patch release
The full solution to this issue is to clean up all TF installation files from your system. Here is how to do that. Run the following first:
From the above command, you need to go and remove the folder
Finally, you need to run
Then it should work.
You are exactly right! On my personal machine, even when I did “pip uninstall tensorflow” it did not fix things. I had to go into my site-packages directory, and delete all “tensorflow” directory manually and then reinstall. Then it just worked.
So, Id say this is a pip bug. the workaround is to purge all TF files your python distribution has. then reinstall TF.
I’ve dealt with this problem (in conda env on Ubuntu 18.04):
All the solutions above have been tried and none of them worked , I just downgraded to tensorflow 1.8.0 and the problem is solved…😦
For me it worked too for my anaconda3 environment!!! I have deleted \anaconda3\envs\test\Lib\site-packages\tensorflow folder and run:
pip uninstall tensorflow
pip uninstall tensorflow-gpu
conda install tensorflow-gpu
The problem is that you updated the tensorflow but not tensorflow_gpu.
pip install --upgrade tensorflow pip install --upgrade tensorflow-gpu
The above-mentioned commands will uninstall and reinstall the tensorflow correctly. Best wishes.
I got this error after “pip3 install --upgrade tensorflow” .
#Got the same issue Win 10 + CUDA 9.2 + Anaconda 1.8.7 Upgrated from Tensorflow 1.8 to Tensorflow 1.9 Uninstalling/reinstalling doesn’t work.
Even complete remove Tensorflow GPU witn only CPU version left doesn’t help. Seems that this is not just GPU ver. but the general tensorflow/keras api problem. What ver of keras should be installed with this release?
Now i’m thinking of complete remove an Anaconda to rebuild everything again (((
UPD: Found partial solution for win 10 - Anaconda:
Now i have tensorflow GPU devices listed and Keras finally found proper GPU backend Checked it via monitoring devices usage.
Hope it’ll be helpful for someone
Installing 1.8.0 instead of the (currently) latest 1.11.0 worked on the Udacity AMI (Ubuntu 16.0.4).
We do have pip tests on windows, not sure how we missed this.
@gunan @case540 @amitpatankar
I this is a widespread problem we should have seen it in the windows tests, no? Or do we not have Windows pip tests? Maybe we should for release. 😕
Hi, just had the same problem while installing tensorflow 1.12.0 and keras 2.2.4 on Windows 10. I managed the installations with Anaconda3.
PROBLEM SOLVED after reading the answers above and doing the following steps:
Grrrr pip.
Can we either add a short (python?) snippet to our install docs that people can run to upgrade safely?
Alternatively, could we (going forward) put the python files into a versioned directory, and have “tensorflow” be a link in site-packages? Would that work on Windows? Would it work in pip?
Could it be an issue similar to https://github.com/pypa/pip/issues/5020? We have --ignore-installed in documentation: https://www.tensorflow.org/install/install_windows According to the thread at that link, if this argument was passed some time in the past it could cause files from old versions to stay in site-packages.