tensorflow 1.15 installation numpy dependency - numpy

When I check the METADATA about the requires of the Numpy version for TensorFlow(tf).
tf 1.15.0 requries 1.16.0 <= numpy < 2.0, and actually installed numpy = 1.19.2
tf 1.15.5 requries 1.16.0 <= numpy < 1.19.0, and actually installed numpy = 1.18.5
However, If I upgrade tf from 1.15.0 to 1.15.5, I need to down the numpy from 1.19.2 to 1.18.5, which is not our intention.
Is there anyone know how to avoid this big gap for numpy if I want to upgrade tf to 1.15.5?
In other words, is the requirement for numpy version strictly conflict with version 1.19 when tf version is 1.15.5?

TF 1.15.0 requires "numpy<2.0,>=1.16.0" and installs numpy-1.19.5 while installing Tensorflow 1.15.0
TF 1.15.5 requires "numpy<1.19.0,>=1.16.0" and installs numpy-1.18.5 while installing Tensorflow 1.15.5
if you have TF 1.15.5 installed in your system and
you want to re-install TF 1.15.0 after uninstalling existing TF 1.15.5 , this TF version will be compatible with existing numpy-1.18.5 as it needs "numpy<2.0,>=1.16.0"
and the same way if you have TF 1.15.0 installed in your system and
you want to re-install TF 1.15.5 after uninstalling TF 1.15.0, this TF version will downgrade the existing numpy-1.19.5 to numpy-1.18.5 as TF 1.15.5 supports "numpy<1.19.0,>=1.16.0"
To answer your question -
TF 1.15.5 requires "numpy<1.19.0,>=1.16.0" and installs numpy-1.18.5
which is suitable for both the Tensrflow versions (1.15.5 or 1.15.0).
Also the compatible numpy version will automatically get installed when
you install any version of Tensorflow.

Related

Tensorflow not detecting my gpu even with all requisite files installed

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.

How to install TensorFlow 1.x on M1 chip?

For legacy reasons, I need to use TensorFlow 1.x. I followed this guide (https://caffeinedev.medium.com/how-to-install-tensorflow-on-m1-mac-8e9b91d93706) to install TensorFlow on my M1 MacBook, however it is only able to install TensorFlow 2.x.
I am also unable to install via conda because M1 only supports Python 3.8+ for conda, whereas TensorFlow 1.x is only supported on Python 3.7 or below.
Any workarounds?
tensorflow-macos is only available from tensorflow v2.5.0 but you can simulate the v1 behaviour using the following code:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

Incompatible scipy and numpy versions

I am trying to install a python package "ezLncPred" which requires a numpy version of 1.15 in my python3.8. While installing it tells that this version of numpy is not compatible with my SciPy version of 1.7.3. I have to upgrade it to numpy1.2 for it.
Any idea on how to resolve this issue ?

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."

Keras requires TensorFlow 2.2 or higher

I want to use keras with the code shown below:
from sklearn.model_selection import train_test_split
from keras.models import Sequential
df = DataReader('AAPL', data_source='yahoo', start='2012-01-01', end=datetime.now())
but I keep getting the error:
ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via `pip install tensorflow
I have both keras 2.4.3 and tensorflow 2.2.0 installed in anaconda environment. I uninstalled and installed jupiter notebook but it didn't help.
From comments
Solved the problem by simply installing different versions of keras
(2.3.1 instead of 2.4.3) and tensorflow (2.0.0 instead of 2.2.0). Keras are integrated with Tensorflow from 2.3 onwards, you can upgrade tensorflow to latest version and use module tf.keras (paraphrased from Vivi and jakub)
To run code in TF 2.4 is as shown below
from sklearn.model_selection import train_test_split
from tensorflow.keras import Sequential
df = DataReader('AAPL', data_source='yahoo', start='2012-01-01', end=datetime.now())