I install the tensorflow gpu first
pip install tensorflow-gpu.
pip install keras
but when I;m running the gpu task. it does not run with the gpu.
It run with CPU.
import keras
import tensorflow as tf
print(keras.__version__)
print(tf.__version__)
2.3.1
2.1.0
try to user Tensorflow-gpu=2.0.0 and Keras=2.3.1 this will solve your problem.
Related
I had tensorflow gpu 2.10 installed and it was working well. I mistakenly decided to upgrade to 2.11 without knowing it doesnt support gpu in windows. So I uninstalled it and reinstalled tensorflow gpu 2.10. Problem is that now it doesnt detect my gpu.
import tensorflow as tf
from tensorflow.keras.datasets import cifar10
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Conv2D, Flatten, MaxPooling2D, BatchNormalization
print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))
print(tf.__version__)
print(tf.test.is_built_with_gpu_support())
The above code gives the output:
Num GPUs Available: 0
2.10.0
True
So the code detects that I have TF built with gpu support yet its not detecting it. My GPU is GTX960m with CUDA 12.0 and CuDNN 8.7.
Here is a solution (might not be the optimal, but is a solution).
It is a mix between these two sites:
https://towardsdatascience.com/setting-up-tensorflow-gpu-with-cuda-and-anaconda-onwindows-2ee9c39b5c44
https://www.tensorflow.org/install/source_windows
The first one works, but it leaves you with an older version of Tensorflow.
The new configuration should be:
Python: 3.10
Microsoft Visual Studio (MSVS): 2019
CUDA: 11.2
tensorflow_gpu-2.10.0 (for some reason, I couldn't install 2.11, but 2.10 worked ok)
The algorithm is:
Install Anaconda (if it is not already installed)
Go to Anaconda Prompt, and write:
conda create --name tf-gpu
conda activate tf-gpu
conda install python=3.10
conda install -c anaconda cudatoolkit=11.2
conda install pip
pip install tensorflow-gpu==2.10
That's it, hope it works (it did for me).
Remember to activate your tf-gpu environment each time you want to use it.
I am trying to run Tensorflow in Anaconda Navigator. I installed Tensorflow to a new environment which I called tf. Here is my code:
import tensorflow as tf
from tensorflow.keras import layers
from tensorflow.keras.layers import Activation, Dense
The error message is unable to import tensorflow and No module named tensorflow
Follow these steps to install on Anaconda environment.
#Set Up Anaconda Environments
conda create --name tf_env python=3.7
#Activate the new Environment
source activate tf_env
#Install tensorflow
tf_env$pip install tensorflow
#Verify installation
tf_env$python
>import tensorflow as tf
>tf.__version__
I was getting the error "NotFoundError: No algorithm worked!" on an architecture that was developed based on the older versions of tensorflow (pre-2.0.0 versions), and that is run on Colab.
Now, Google Colab has an updated version of Tensorflow (post-2.0.0 versions) and Keras.
Following the question that was asked here I downgraded Tensorflow to 1.15.0 : How to downgrade tensorflow version in colab?
I used this command to downgrade Tensorflow :
!pip install tensorflow==1.15.0
import tensorflow as tf
Still, I have a problem importing Keras.
To solve the problem, I downgraded the Keras version to 2.2.4 using this command :
!pip install keras==2.2.4
I want to ask about compatibility issues between keras and tensorflow.
Specifically, how can I find the latest compatible version of keras and tensorflow? I found a lot of places including the official website of keras and did not find how to find the tensorflow version compatible with the latest keras2.24.
My current version of tensorflow+keras is 1.4.0+2.1.0, which does not support some new features.
If you don't care about having the latest Keras version, you can use the tf.Keras module that is already available with your Tensorflow installation. Check here
As per the doc:
tf.keras can run any Keras-compatible code, but keep in mind:
The tf.keras version in the latest TensorFlow release might not be the
same as the latest keras version from PyPI. Check tf.keras.version.
When saving a model's weights, tf.keras defaults to the checkpoint
format. Pass save_format='h5' to use HDF5.
I have tensorflow 1.12.0 with keras 2.2.4. I got this by downloading the latest (Anaconda3-2018.12-Windows-x86_64.exe) anaconda which has conda 4.6.4 and python 3.6.8.
I believe I then did a conda update conda and a conda update anaconda.
I then did a conda install tensorflow and a conda install keras.
Activate your environment and update your anaconda version using
conda update anaconda
Next uninstall tensorflow and keras as below
pip uninstall keras
pip uninstall tensorflow
Install Keras and tensorflow again
pip install tensorflow
pip install keras
check the version is updated.If it is not possible comment below.
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