Did colab suspend tensorflow 1.x?

Google Colab removed support for Tensorflow 1, and it is not possible to use %tensorflow_version 1.x magic anymore. You must remove this instruction from your code if you have it.

Also the default python version as I update this answer is python 3.8 which is not compatible with tensorflow 1.x.

To make everything work you first have to downgrade python. Python 3.6 should work. As suggested by @s-abbaasi here’s a guide on how to do so:

%%bash

MINICONDA_INSTALLER_SCRIPT=Miniconda3-4.5.4-Linux-x86_64.sh
MINICONDA_PREFIX=/usr/local
wget https://repo.continuum.io/miniconda/$MINICONDA_INSTALLER_SCRIPT
chmod +x $MINICONDA_INSTALLER_SCRIPT
./$MINICONDA_INSTALLER_SCRIPT -b -f -p $MINICONDA_PREFIX

Then add to path:

import sys
_ = (sys.path.append("/usr/local/lib/python3.6/site-packages"))

At this point you can manually uninstall and re-install tensorflow through pip:

!pip uninstall tensorflow
!pip install tensorflow-gpu==1.15

Doing just so I sometimes encounter some errors due to the Cuda version. If this happens to you, you can execute the following:

!apt install --allow-change-held-packages libcudnn7=7.4.1.5-1+cuda10.0

The most appropriate version of cuda and libcudnn to use with the tensorflow version you want to install can be found here.

The versions available of libcudnn can be found with the following command:

!apt list -a libcudnn7

This will list all libcudnn7 versions available.

Leave a Comment