Tensorflow import error: Naive Pip Windows 10 - tensorflow

having problems while
screenshot given below. I want the solution badly.
import tensorflow as tf
https://i.stack.imgur.com/jgghK.png

You're using tensorflow-gpu but do not have CUDA / cuDNN installed on your computer.
Shor answer: run pip unintall tensorflow-gpu and pip install tensorflow.
Long answer: Install CUDA / cuDNN

Related

GPU not captured by TensorFlow

I installed tensorflow using pip install tensorflow within Anaconda virtual environment on Windows.
I tried to test whether GPU is enabled, and type
import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))
and got
Num GPUs Available: 0
My system does have CUDA and CUDNN enabled, as I do not have a problem installing PyTorch GPU version. How do I enable GPU for TensorFlow?
At first, uninstall tensorflow using,
pip uninstall tensorflow
Install tensorflow-gpu version,
pip install tensorflow-gpu==2.2.0
If using pip did't work you can try with conda install command.
conda install -c anaconda tensorflow-gpu
This will automatically install CUDA & cuDNN.
Hope this will solve your issue.
Remove the cpu version tensorflow using pip uninstall tensorflow and install the gpu version of the tensorflow, pip install tensorflow-gpu.
You can check this tutorial link as well.
It can be summarized by the following steps:
Uninstall your old tensorflow
Install tensorflow-gpu pip install tensorflow-gpu
Install Nvidia Graphics Card & Drivers (you probably already have)
Download & Install CUDA
Download & Install cuDNN
Verify with your program.

problem with importing tensorflow probability

I am using Anaconda and Ubuntu 18.04. I installed TensorFlow probability base on Anaconda's command:
conda install -c conda-forge tensorflow-probability
but when I wanted to import TensorFlow probability, I faced with below error:
ImportError: cannot import name 'compiler' from 'tensorflow.python.autograph.pyct' (/home/alireza/anaconda3/envs/tf-gpu/lib/python3.8/site-packages/tensorflow/python/autograph/pyct/init.py)
I check Anaconda by conda list tensorflow and TensorFlow probability version 0.8 was installed.
I appreciate your suggestion.
I think it's been a long time since the conda recipe for TFP was updated (TFP is now at 0.12), so you would need to ensure the version of TensorFlow you have is compatible. FWIW from the 0.8 release notes: "It is tested and stable against TensorFlow version 2.0.0 and 1.15.0rc1."

Run Tensorflow 2.0 code on Tensorflow 1.x

I have a code that was running on colab with Tensorflow 2.0 and now I am trying to run it on a GPU with Tensorflow 1.14 and facing several errors. Is there an easy way to upgrade to tensorflow 2.0 or is it better to modify the code and make it working on the current version?
If your code is working on colab with TF 2.0, then you can uninstall TF-GPU 1.14 and install latest version of TF 2.4.
# Uninstall tensorflow
pip uninstall tensorflow-gpu == 1.14
# Requires the latest pip
pip install --upgrade pip
# Current stable release for CPU and GPU
pip install tensorflow (which install latest version of TF 2.4)
To know more details you can refer here

Downgrading TensorFlow from 1.15 to 1.14 not working

I have a colab notebook which was running tf1.15.0. I need to downgrade it to 1.14.0. In a cell, it run the following:
!pip uninstall tensorflow==1.15.0
!pip install tensorflow==1.14.0
import tensorflow as tf
print(tf.__version__)
However, it outputs:
> 1.15.0
What am I doing wrong please?
CS
IF you have import tensorflow cell before uninstall, you may need to restart notebook to make it effective.
IF you have not, make sure you are running the correct pip in the same python environment as the notebook, such as:
import sys
!{sys.executable} -m pip install xx
Do you have TensorFlow-GPU installed in the system? Because this is the same issue I was facing earlier, so try downgrading TensorFlow-GPU.
pip install tensorflow-gpu==1.14
or any other version of tensorflow-gpu.

How to use Tensorflow-gpu when both Tensorflow and Tensorflow-gpu are installed?

I have both TF and TF-GPU installed in the same virtual environment. when I test it in iPython terminal, it shows that TensorFlow, not TensorFlow-GPU is used. However, I want the GPU version to be used.
How to do that? Shouldn't I installed both in the same environment? Thanks.
I can recommend this:
pip uninstall tensorflow
pip uninstall tensorflow-gpu
pip install tensorflow
pip install tensorflow-gpu
Wish I knew a better answer