I read your question and i want to answer your question is my answer solve your question then i will be really happy with that.
Basically this is an environment issue so that's why i give you some information when you installing your tensor flow environment in your system.
System requirements
pip 19.0 or later (requires many Linux 2010 support)
Ubuntu 16.04 or later (64-bit)
mac OS 10.12.6 (Sierra) or later (64-bit) (no GPU support)
Windows 7 or later (64-bit) (Python 3 only) Raspbian 9.0 or later
Hardware requirements
Starting with Tensor Flow 1.6, binaries use AVX instructions which may not run on older CPU.
Read the GPU support guide to set up a CUDA -enabled GPU card on Ubuntu or Windows.
Install the Python development environment on your system
Requires Python > 3.4 and pip >= 19.0
- python 3 --version
- pip3 --version
- virtualenv --version
If these packages are already installed, skip to the next step.
Otherwise, install Python, the pip package manager, and Virtualenv:
- sudo apt update
- sudo apt install python 3-dev python 3-pip
- sudo pip3 install -U virtualenv # system-wide install
Caution: Upgrading the system pip can cause problems
If not in a virtual environment, use python 3 -m pip for the commands below. This ensures that you upgrade and use the Python pip instead of the system pip.
Create a virtual environment (recommended)
Python virtual environments are used to isolate package installation from the system.
Create a new virtual environment by choosing a Python interpreter and making a ./venv directory to hold it:
virtualenv --system-site-packages -p python 3 ./venv
Activate the virtual environment using a shell-specific command:
source ./venv/bin/activate # sh, bash, ksh, or zsh
When virtualenv is active, your shell prompt is prefixed with (venv).
Install packages within a virtual environment without affecting the host system setup. Start by upgrading pip:
pip install --upgrade pip
pip list # show packages installed within the virtual environment
And to exit virtualenv later:
deactivate # don't exit until you're done using Tensor Flow
Install the Tensor Flow pip package
Choose one of the following Tensor Flow packages to install from PyPI:
tensor flow —Latest stable release (2.x) for CPU-only (recommended for beginners).
tensor flow-GPU —Latest stable release with GPU support (Ubuntu and Windows).
tf-nightly —Preview build (unstable). Ubuntu and Windows include GPU support.
tensor flow==1.15 —The final version of Tensor Flow 1.x.
Package dependencies are automatically installed. These are listed in the setup.py file under REQUIRED_PACKAGES.
pip install --upgrade tensor flow
python -c "import tensor flow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"