TensorFlow1.13.1 Installation Guide

TensorFlow1.13.1 Installation Guide

Now that TensorFlow has been updated to version 2.8, I wanted to install an old version of TensorFlow on a whim and found that there would be various bugs. I will record it in the opening blog.
The main reason for the problem: that is, the versions of various installation packages or libraries downloaded now are too high, and the compatibility with lower versions of TensorFlow is poor.
Solution: Install the appropriate version of the package and library.

Library version brief description
numpy==1.16.5
grpcio==1.36.1
tensorflow==1.13.1

installation package/library version
numpy 1.16.5
grpcio 1.36.1
tensorflow 1.13.1

It is recommended to execute in the following order in a virtual environment

  1. pip install numpy==1.16.5
  2. pip install --upgrade pip
  3. pip install --upgrade setuptools
  4. pip install --no-cache-dir --force-reinstall -Iv grpcio==1.36.1
  5. pip install tensorflow ==1.13.1

You can add a suffix to install from the Douban mirror library -i http://pypi.douban.com/simple --trusted-host=pypi.douban.com
After installation, find the corresponding version of tensorflow according to error 2, or install the corresponding version of tensorflow directly.

After installation, you can test whether tensorflow is successfully installed.

import tensorflow as tf

hello=tf.constant('hello,world')
sess = tf.Session()
print(sess. run(hello))

There will be many errors during the installation, which are organized as follows:

Error code 1

Question source

When installing Tensorflow, report Error:

 ERROR: Failed building wheel for grpcio
      Running setup.py clean for grpcio
    Failed to build grpcio

The newspaper cannot be packaged into a wheel, installed from setpu.py, and then it will always be stuck

Reason of the problem

Unable to install grpcio using pip install grpcio
The grpcio library cannot be installed

Workaround

Upgrade pip, upgrade setuptools, update appropriate version(grpcio==1.36.1) grpcio library.
pip3 install --upgrade pip
python3 -m pip install --upgrade setuptools
pip3 install --no- cache-dir --force-reinstall -Iv grpcio==
Refer to this URL answer https://stackoverflow.com/questions/56357794/unable-to-install-grpcio-using -pip-install-grpcio

Error code 2

Question source

After installing Tensorflow, when executing import tensorflow as tf, a Warning:

Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2

Reason of the problem

The library directly installed by pip does not match the computer configuration tacitly, and an adapted version can be installed.
Some methods on the Internet are to block the warning.
After a bit of research, I found that it can be completely solved, and it can also increase the CPU computing speed (however, the GPU is still easy to use).

Workaround

Go to this address: https://github.com/lakshayg/tensorflow-build
or this: https://github.com/fo40225/tensorflow-windows-wheel
According to your own python version, gpu capability (or not), cpu support (SSE4.1, SSE4.2, AVX,AVX2, FMA)
Find the corresponding .whl file

After downloading, install the offline package
pip install C:\python ensorflow- 1.13.1-cp37-cp37m-win_amd64
If you run the tensorflow program again, there will be no warning

You can also choose to deceive yourself
You can also choose the second method to block the error message

import os
os.environ["TF_CPP_MIN_LOG_LEVEL"]='1' # This is the default display level, displaying all information
os.environ["TF_CPP_MIN_LOG_LEVEL"]='2' # only display warning and error
os.environ["TF_CPP_MIN_LOG_LEVEL"]='3' # only display Error

Refer to the comments of netizens and explain: This means that the TensorFlow you downloaded is too low, and there is no AVX compatibility to Compile at all. AVX is supported if you download the source code and recompile on that computer. In fact, your computer supports AVX, but the compiled TensorFlow does not support it.
Write at the top line of the code

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

This method can temporarily shield the warning message, which looks more comfortable.

Error code 3

Question source

When installing Tensorflow, report Error:

ModuleNotFoundError: No module named 'pip'

Reason of the problem

Unknown missing for pip.

Workaround

Reinstall pip.
Execute
python -m ensurepip
python -m pip install --upgrade pip
If you need to downgrade pip
python -m pip install pip==8.0.0

Error code 4

Question source

After installing Tensorflow, when executing import tensorflow as tf, a Warning:

FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1 ,)type'.np_resource = np.dtype([("resource", np.ubyte, 1)])

Reason of the problem

The numpy version is too high.

Workaround

Just install a lower version of numpy.
Execute
pip install numpy==1.16.5

Leave a Reply

Your email address will not be published. Required fields are marked *