keras version to use with tensorflow-gpu 1.4 - python

I am using ubuntu 16, with python 3, tf-GPU with keras.
I downgraded to tf 1.4 due to cuda errors as explained here
But now I am getting this error
TypeError: softmax() got an unexpected keyword argument 'axis'
Seems that this is an API change in tensorflow and new keras is not suitable for the old tf.
I can't find what is the correct keras version to use with tf 1.4 gpu. What is the correct one?

Keras - Tensorflow versions compatibility is a frequent problem that i have faced many times myself. I am keeping in my bookmarks this compatibility table, with matches of tensorflow and keras versions. It would seem that keras 2.0.8 is compatible with tensorflow 1.4.

If you are using keras exclusively with the tensorflow backend, I would recommend to use the keras implementation found in tf.keras rather than the keras module. That way, you won't scratch your head about possible incompatibilities or bugs (see also that question).

There does not seem to be proper documentation on which Keras version targets which TensorFlow version. The quickest way to solve your problem may be just downgrading Keras one version at a time until you find one that works (or, conversely, upgrading one version at a time from one that you know to work until it breaks). If you find that tedious you can do it as a binary search.
Looking at the releases page, it seems that version 2.0.8 should be compatible with TensorFlow 1.4; it's about a year old already but at least you have an starting point there.

I was able to use the conda package manager to install keras and keras-gpu, with a compatible tensorflow and cuda versions to get past your TypeError: softmax()... error message when I was trying to load the original BERT tensorflow checkpoint using the keras-bert package:
$ conda create -n bert python=3.6
$ conda activate bert
$ conda install keras==2.0.8
$ conda install keras-gpu==2.0.8
$ pip install keras-pos-embd==0.10.0
$ pip install keras-transformer==0.22.0

I am using tensorflow version 1.15.4 and installing Keras version 2.3.1 fixed my problem.
BTW, this page is useful. Find your intended tensorflow version and then click on corresponding Packages and Nvidia Settings.
setuptools==41.0.0
numpy
matplotlib
pandas
pydub
scipy
tensorflow==1.15.4
keras==2.3.1
python_speech_features
praat-parselmouth
pyquaternion

Related

Python package (tensorflow) displays mismatching versions between pip list and .__version__ output

I suddenly encounter this situation today, all below output is under the same environment.
pip show tensorflow, the output gives:
Name: tensorflow
Version: 1.14.0rc1
But, if I enter python
python
>>> import tensorflow as tf
>>> print(tf.__version__) . It gives:
'1.13.1'
I am sure I am using the same python under the environment I need with pure terminal or in IDE. This is weird, cuz I used to not having this issue. I just installed few other packages these two days, but I believe they have nothing to do with tensorflow. And you can also verify this through pip show tensorflow or pip list output to see the version is 1.14.0rc1. So why when I actually use python, the tensorflow is not loaded properly?
Solved it by the following:
(under the same environment)
pip uninstall tensorflow (in order to reinstall tensorflow the right version)
pip install tensorflow==1.14.0rc1
Note during installing, there is a piece of info from the terminal:
Installing collected packages: tensorflow
Attempting uninstall: tensorflow
Found existing installation: tensorflow 1.13.1
Uninstalling tensorflow-1.13.1:
Successfully uninstalled tensorflow-1.13.1
So it seems like the tensorflow 1.13.1 has been accidentally installed previously, and whenever in a python program import tensorflow, during searching stage, it hits the tensorflow==1.13.1 before finding the 1.14.0rc1 version. Altho pip list only displays tensorflow==1.14.0rc1 but not tensorflow==1.13.1 might also be due to its internal search or duplicated package resolve mechanism.

Issue with tensorflow-mkl on CPU

I am new to tensorflow. In fact using it because the server code I am writing calls that.
I am using conda to setup the various packages. I did conda install -c anaconda tensorflow-mkl. (Note: I dont have a GPU - using a CPU)
I always get this error:
Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX
The specific line of code where this happens:
tensorflow.contrib.predictor.from_saved_model(path)
On further research, I figured out that this is because the tensorflow package I have does not support this above instruction and needs to have support for the same.
Some questions:
1. How do we ensure the tensorflow package I have does support the above function? Any source from which I can download?
If it is not important, is there a way to suppress this instruction or any errors from it?
Thanks in advance!
You can use conda or pip installations to download the tensorflow that supports cpu. You can use the following commands from your terminal
conda install tensorflow -c anaconda
or
pip install tensorflow==1.13.1
You can use this link if you havent installed pip yet
How to install pip3 on Windows?
Hope this helps..
Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX
This is just a warning.Not an error.
To suppress this warning please add the following lines before your actual code:
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
import tensorflow as tf
As per the tensorflow official documentation,starting with TensorFlow 1.6, binaries use AVX instructions which may not run on older CPUs.
You can refer the below url for more details on Intel Optimized tensorflow installation:
https://software.intel.com/en-us/articles/intel-optimization-for-tensorflow-installation-guide
Hope this answer your query.Thank you.

How can I install the latest version of tensorflow?

I want to install the latest version of tensorflow (1.12.0) in my machine and installed it using pip install tensorflow. The 1.12.0 version of the tensorflow installed in my linux machine without any error but when I tried to import tensorflow in my python shell its giving this error and aborting the tensorflow import.
>>> import tensorflow as tf
F tensorflow/core/platform/cpu_feature_guard.cc:37] The TensorFlow library was compiled to use AVX instructions, but these aren't available on your machine.
Aborted
In this answer it is said that its a simple warning but mine is not a warning its aborting the import of tensorflow completely. I tried uninstalling and reinstalling tensorflow multiple times but the same problem persists. I then tried to install the lowest version of tensorflow pip install tensorflow==1.0.0 this works and able to to install an older version of tensorflow.
How can I install the latest version of tensorflow?
Seem your CPU doesn't not support AVX instructions.
Since version 1.6 use AVX instructions, thus TF cannot be used on "old" CPUs.
However there is some unofficial built. But you will probably not find built on latest version of tensorflow.
Here is a thread about it : https://github.com/tensorflow/tensorflow/issues/18689

Keras 2.0.3 compatibility

Is keras 2.0.3 (latest version) compatible with latest Anaconda version (4.3.1, python version 3.6) ? Or keras is only compatible with python 3.5, so I must choose older version of Anaconda?
EDIT: I have some problems when I use this method:
prediction = np_utils.categorical_probas_to_classes(prediction)
Error: "keras.utilis.np_utilis" has no attribute "categorical_probas_to_classes"
Also I have other errors with keras's methods. So I thought that problem is python version, that is incompatible with keras's version
At least on Windows, Tensorflow wants Python 3.5. You can easily change your Python version without reinstalling Anaconda; you just create a new conda environment:
conda create -n myenv python=3.5 anaconda
activate myenv
(myenv) pip install tensorflow
(myenv) conda install keras
That said, keras.np_utils does not have the function you describe, regardless of Python version. And as it seems that you can already import some Keras functions, it is more likely that you need to adjust your code to the Keras 2 API than that you have a problem with your Python version.
if you used activation="softmax",
use:
prediction = model.predict(x_test)
prediction = ***prediction.round(0)***
print(prediction[:15])

How to install keras on Win10?

I know there are a lot of tutorials of installing keras on win. But I am faced with a weird problem and I cannot find a solution on Google.
The version of python I used is 2.7(anaconda 64bit).
When I typed 'pip install keras' in cmd, an error occurred.
It is said that no matching distribution found for tensorflow(from keras).
I googled it and one saying goes that this problem occurred when python is 32bit on windows. However, my python is 64-bit, so this saying does not hold.
I want to know how to handle this, given that I want to use theano as keras backend instead of tensorflow.
I think the problem is that TensorFlow on Windows only support Python 3.5.X.
You should try installing anaconda3.
Source: https://www.tensorflow.org/install/install_windows
using commad pip install -v -v -v keras may offer you more information about this
and I find this commad may download Keras tar file in site https://pypi.python.org/simple/keras/
and after download file, it will check the requires.txt in Keras.egg-info
then i find in Keras 2.0.0 it require tensorflow instead of theano in this version, otherwise you may fail to install
so the solution is, download the other keras in site which requires theano not tensorflow, and unpack it, then cd its directory, and use python setup.py install to install this version of keras

Categories