Unable to run Tensorflow's official Tensor2Tensor colab notebook

Viewed 4160

I have zero experience in Tensorflow and recently started studying about NLP. Came across the Tensorflow implementation of the Transformer based on Attention is All You Need paper.

Tensor2Tensor package has a Quick Start section which has a colab link

Quick Start
This iPython notebook explains T2T and runs in your browser using a free VM from Google, no installation needed.

I wanted to run this and it gives the error

ValueError: Tensorflow 1 is unsupported in Colab.

Your notebook should be updated to use Tensorflow 2.
See the guide at https://www.tensorflow.org/guide/migrate#migrate-from-tensorflow-1x-to-tensorflow-2.

Have no clue on what to change.

I'm I not supposed to run the colab but just observe the already printed results. Is there a Tensorflow 2 version which I can run and see.

2 Answers

From the error it looks like that the code you want to use is based on Tensorflow 1. You should know that Colab recently removed support for Tf1. You can still install it manually though. Just remove the previous Tf2 installation and replace it with the previous version like this:

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

This is almost always enough (you could be asked to restart the runtime for the change to take effect). However, if you experience errors due to the version of Cuda, you could try to re-install cuda and libcudnn too with:

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

Update:

After manually installing tensorflow 1 you can remove the instruction %tensorflow_version 1.x, which is called a magic. Before tf1 got discontinued in Colab, that instruction could have been used to activate it instead of doing the installation by hand.

Also inside the QuickStart of the repo, it says that you should also install two packages. So after the installation of tensorflow add:

!pip install tensor2tensor 
!pip install t2t-trainer 

after following the steps above, i encountered this error:

Loaded runtime CuDNN library: 7.4.1 but source was compiled with: 7.6.0.  CuDNN library major and minor version needs to match or have higher minor version in case of CuDNN 7.0 or later version. If using a binary install, upgrade your CuDNN library.  If building from sources, make sure the library loaded at runtime is compatible with the version specified during compile configuration

Seems like even after installing the compatible cudnn version it doesnt work, how can I work around this issue?

Related