I'm using keras/tensorflow on google colaboratory and I need to go back to previous versions of them.
The problem is when I run !pip install q keras==1.2.2
, the kernel shows keras 1.2.2 installed but when I check it using keras.__version_
it shows 2.1.6 . And same case is with tensorflow.
How do I fix this?
I had this issue yesterday. I was rather surprised that installing packages did not have an effect.
But I realised then that I needed to restart the kernel. In Colab this is called Restart runtime
. After restart the new version should be available for you.
Here you find the restart:
Your command !pip install q keras==1.2.2
for Keras is okay, just you need to restart runtime as other answers mentioned.
but for tensorflow you should use %tensorflow_version 1.x
.
as they said here:
Avoid Using pip install with GPUs and TPUs We recommend against using pip install to specify a particular TensorFlow version for both GPU and TPU backends. Colab builds TensorFlow from source to ensure compatibility with our fleet of accelerators. Versions of TensorFlow fetched from PyPI by pip may suffer from performance problems or may not work at all.
and as it says, when I tried to downgrade my TensorFlow to 1.5 with pip, it does not recognize GPU and just trained my model with cpu.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With