tao liang
tao liang

Reputation: 51

I want to install tensorflow version 1.14 in Google colab but failed

I need to test a code in Google colab which is not supported in tf2(for tf.ceil is not supported in tf2), so I want to install tensorflow in version 1.14. I use pip3 and pip to install tensorflow, all of them install tf successfully, but as I do this:

import tensorflow as tf
tf.__version__

It returns:

'2.2.0-rc3'

And I have clear sys.path:

import sys
sys.path

It returns:

[]

How can I install tensorflow in version 1.14?

Upvotes: 5

Views: 8975

Answers (2)

jakevdp
jakevdp

Reputation: 86330

Edit: as of 2023, it is no longer possible to install Tensorflow 1 in a standard Colab runtime. This is because Tensorflow 1.X requires Python 3.7 or older, and the standard Colab runtime now uses Python 3.10.


Previous answer:

If sys.path is empty, your Python environment is in a very bad state. You should reset your VM (Runtime -> Factory reset Runtime) and then run the following:

!pip install tensorflow==1.14

Once you do this, you will have tensorflow 1.14 installed:

import tensorflow
print(tensorflow.__version__)
1.14.0

Be aware that reseting your VM will cause you to lose all program state from your current session.

Upvotes: 1

dreamwalkeranderson
dreamwalkeranderson

Reputation: 108

The easiest way to ensure you work with TF v1 is to simply run the

%tensorflow_version 1.x

line before you import TensorFlow.

Colab already builds TF from source so Google recommends against using pip to install TF as you may incur performance problems.

Upvotes: 8

Related Questions