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'

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
@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. :/
We do have pip tests on windows, not sure how we missed this.
Do we only have pip tests for Bazel builds (release we only look at CMake Windows builds)
I guess that means patch release time. Only needed for Windows, I guess?
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
Nice find! @RyenAng can you check whether that solution works for you? We did upgrade our protobuf dependency, and while it's regrettable that the failure is so obscure, it's somewhat beyond our control.
@case540 This didn't work for me. I tried this on Windows 7
We should try to repro this. We'll have to, for any fix anyway. And we
should find out which platforms are affected.
I just reproduced the problem on my windows laptop. I am really surprised, because all the python files are there!
I can manually run that exact line (which fails with a very similar issue) and it is found, but it is not found during import tensorflow. Also, it looks to be specific to keras.
@annarev is it possible we have another API generation problem?
@case540 did we do anything special for keras API generation?
I will see why our tests did not catch this. Maybe our unit tests just do from tensorflow.python.foo import bar and these all pass?
Hm we had a change a couple months ago that removed _impl directory. I don't see _impl directory under
https://github.com/tensorflow/tensorflow/tree/r1.9/tensorflow/python/keras
So, it is strange that an import fails on upgrade.
Could it be that some old file is there after upgrade?
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.
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):
pip uninstall tensorflow protobuf --yes
find $CONDA_PREFIX -name "tensorflow" | xargs -Ipkg rm -rfv pkg
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.9.0-cp36-cp36m-linux_x86_64.whl --no-cache-dir
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?
Having links on windows, I am not so sure.
How about this, without using a symlink?
tensorflow/__init__.py includes only a line that says from
tensorflow.v1.10.0 import *
Then all our versions go to tensorflow/v1.10.0 (or another version).
One downside is with similar pip issues, we will accumulate a ton of files
on users disks, potentially GBs of stale files.
On Sat, Jul 14, 2018 at 7:46 AM Martin Wicke notifications@github.com
wrote:
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?—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/tensorflow/tensorflow/issues/20778#issuecomment-405027903,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHlCOREu1gItVIy393mL04rtQuewUNwCks5uGgRDgaJpZM4VOwSJ
.
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:
1) run Anaconda under Admin
2) via "environements" uninstall Keras
3) Run Anaconda prompt under Admin and pip uninstall tensorflow and then pip uninstall tensorflow-gpu
4) reboot your comp
5) run Anaconda under Admin and via "environements" install Keras 2.2.0 and all available keras packages
6) while solving packages, it'll propose you to install all necessary Tensorflow 1.8. packages.
7) Apply.
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
I don't think that running something under admin could be a solution. Did you try to remove tensorflow from filesystem manually (I mean w/o using pip just all folders in anaconda/env)?
Running under Admin is important cause Anaconda itself does't allow (at least in my case)
to change the environement with simple user rights
Anaconda prompt under user also is not allowed to make changes in some folders.
Also sometimes people have several different environements (as me, for example) so, searching every folder for manually deleting becomes a problem itself.
My way is totally worked for me.
It is simple, effective, and looks to be the same for everyone.
When I update my python version from 3.6.2 to 3.6.6, I meet this problem.
pip install --upgrade keras
did the trick (especially in conda installed tensorflow-gpu)
Env: Windows 10 , CUDA 9 + CUDNN 7, Python3.6(Anaconda5.2)
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...:(
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:
$ pyhthon
> import tensorflow as tf
> tf.__file__
'path/to/your/python/installation/site-packages/tensorflow/__init__.pyc'
From the above command, you need to go and remove the folder
path/to/your/python/installation/site-packages/tensorflow
Finally, you need to run
$ pip uninstall tensorflow # Also add -gpu if you installed the GPU version
$ pip install tensorflow # Also add -gpu if you installed the GPU version
Then it should work.
@gunan's solution worked for me with WinPython 3.5 x64 , TensorFlow 1.10.0 and keras 2.2.2
For me it worked too for my anaconda3 environment!!!
I have deleted \anaconda3envstest\Lib\site-packagestensorflow 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.
In my windows laptop, i get fixed this error by uninstalling tensorflow, remove tensorflow things' files in site-packages and install tensorflow again
Installing 1.8.0 instead of the (currently) latest 1.11.0 worked on the Udacity AMI (Ubuntu 16.0.4).
I got this error after “pip3 install --upgrade tensorflow” .
After I upgraded tensorflow to the latest version 1.12 my keras was still left at 2.1.5 I got this error
So I switched to another conda environment with TF 1.9 and Keras 2.2.4 and it just worked
I got this error after upgrade tensorflow. I uninstall tensorflow after that install tensorflow but I cloudn't fix this problem. Finally I uninstall tensorflow and delete tensorflow folder in python site package ( C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Lib\site-packages ). By the way, The problem is fixed.(OS:Windows 10 ; Using Visual Studio Code)
Hi, I have a similar problem. I am using tf and keras. I found out that do not have some models from keras and decided to install keras in tensorflow environment. After installation, during compilation of the program I've got this ;
"from tensorflow.python.keras._impl.keras.backend import abs
ImportError: cannot import name 'abs' "
System: Win10x64, python 3.6, tensorflow 1-12.0, keras 2.2.4-0
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:
@case540
your suggestion worked for me just fine on Windows 10. Thank you!
This happened to me on Ubuntu Linux.
When I have not install xlearn on my Ubuntu, my tensorflow is ok.
I think the error is relation to the package xlearn and tensorflow.
I also encountered this awful error this afternoon, luckily I made it following the steps:
Am getting the following error trying to run ChatLearner chatbot. Not sure where to get the 'abs' for keras? How to fix this any ideas?
from tensorflow.python.keras._impl.keras.backend import abs
ImportError: cannot import name 'abs'
try uninstalling all dependencies of keras(including some base), and reinstall the keras(pip install). My successful running version of keras is 2.2.4. Plus, I suppose my fault is caused from the version conflict of keras base file and some of its dependencies.
| |
王尤嘉
|
|
[email protected]
|
签名由网易邮箱大师定制
On 03/21/2019 10:43,Brian Voglnotifications@github.com wrote:
Am getting the following error trying to run ChatLearner chatbot. Not sure where to get the 'abs' for keras? How to fix this any ideas?
from tensorflow.python.keras._impl.keras.backend import abs
ImportError: cannot import name 'abs'
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
This happend to me on ubuntu 16.04
It happens on win10. I tried to uninstall tensorflow and reinstall it but this doesn't work.
When i got the error on win10 it helped to uninstall tensorflow and then install version 1.8. this removed the error. I could then without any problem update to version 1.12.0 and 1.13.1
Had the same issue with Ubuntu 18.04 when trying to install 2.0.0-beta1
fixed by uninstalling tensorflow, removing the remaining tensorflow folder from site-packages and reinstalling.
start a new virtualenv without side package and reinstall tensorflow,will solve this problem without wasting your time.
What I did on my Ubuntu container was this, and it worked!
pip3 uninstall tensorflow
pip3 uninstall protobuf
pip3 install https://github.com/lakshayg/tensorflow-build/releases/download/tf1.13.1-ubuntu16.04-py3/tensorflow-1.13.1-cp35-cp35m-linux_x86_64.whl
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...:(
You just saved my life. Thanks for this 😂
Most helpful comment
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