How can I install the latest version of tensorflow? - python

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

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.

Tensorflow install on Mac

I am having a difficult time getting tensorflow to install on a MacBook Pro.
Initially, I tried pip3.8 install tensorflow in my virtual environment. It installed but gives the following error when I try to use it:
This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
I get that this is a warning, but I think it's a serious warning that I am going to have performance issues with any non-trivial work.
Based on this post (Tensorflow on MacOS: Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA), I uninstalled tensorflow and followed the steps. After I installed Bazel, using homebrew, I got an error when I ran ./configure:
Please downgrade your Bazel installation to version 0.26.1.
According to this: (https://github.com/bazelbuild/bazel/releases) the oldest version is 3.2. I had 3.7 installed. So I uninstalled Bazel using homebrew. This felt like a dead end even though compiling from the source seems like the correct way to go. That version it's asking for is not even remotely close to a current version. I think the message is not telling me what I need to know.
Next I tried using pip to install the version recommended by Tensorflow.org. (https://www.tensorflow.org/install/pip.html)
pip3.8 install https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.4.0-cp38-cp38-macosx_10_14_x86_64.whl
This successfully installed as well, but gives me similar errors as my original install and fails the test recommended under the list of installations on the tensorflow.org page.
I think I'm making a novice mistake. Can anyone assist here?
It's not serious warning, you can either wait for macOS 12.0+ to have built-in Apple Metal Acceleration or run Intel optimized wheels for macOS, but it support only TensorFlow 2.0

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.

Tensorflow for mac AVX

I'm using TensorFlow but I'm getting the following warning
The TensorFlow library wasn't compiled to use AVX instructions, but
these are available on your machine and could speed up CPU
computations
I installed it using pip.
How can I fix it?
It's because you installed using pip it's a precompiled package that wasn't precompiled to the architecture you use, you need to build it from the source.
You can refer to he official tensorflow documentation on how to compile it from the source
https://www.tensorflow.org/install/install_sources

TensorFlow fails to use gpu

I'm getting started with TensorFlow, but I cannot make it use GPU instead of CPU with TensorFlow 1.2.1.
I've got a laptop equipped with a NVIDIA GTX 850M which is CUDA 5.0 compatibility.
The CUDA Toolkit is installed with the latest version available.
cuDNN is installed with the latest version available.
I've set up the environment variables just as is shown here : https://nitishmutha.github.io/tensorflow/2017/01/22/TensorFlow-with-gpu-for-windows.html
If I install the latest version of TensorFlow via pip: "pip install tensorflow-gpu" in the cmd prompt, then TensorFlow does not recognize my GPU and acts like I've got none: 'Device mapping: no known device'.
If instead I install tensorflow via 'pip install --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-0.12.1-cp35-cp35m-win_amd64.whl' then everything works fine.
Has anyone an idea why the latest version of TF does that?
In the latest version of Tensorflow, you can check the GPU availability as
gpu_available = tf.test.is_gpu_available()
is_cuda_gpu_available = tf.test.is_gpu_available(cuda_only=True)
is_cuda_gpu_min_3 = tf.test.is_gpu_available(True, (3,0))
tf.test.is_gpu_available will be removed in a future version. Instructions for updating: Use tf.config.list_physical_devices('GPU') instead

Categories