6

Currently google colaboratory uses tensorflow 1.4.1. I want to upgrade it to 1.5.0 version. Each time when i executed !pip install --upgrade tensorflow command, notebook instance succesfully upgrades the tensorflow version to 1.5.0. But after upgrade operation tensorflow instance only supports "CPU".

When i have executed this command it shows nothing :

from tensorflow.python.client import device_lib device_lib.list_local_devices()

Should there be another way for upgrading tensorflow ? such as upgrading to tensorflow-gpu package ? Also when will notebooks will come with upgraded tensorflows ?

AGP
  • 459
  • 1
  • 6
  • 20

4 Answers4

7

As of 2020, Colab can run Tensorflow 2.0. Uninstall the current version of Tensorflow:

!pip uninstall tensorflow

and simply reinstall using pip.

!pip install tensorflow==2.0.0

If you so choose, you can also install the beta version with

!pip install tensorflow==2.0.0-beta1

Once you've reinstalled Tensorflow, make sure you don't forget to restart the runtime under the Runtime tab.

A native solution is to start your code with

%tensorflow_version 2.x
DickyBrown
  • 93
  • 1
  • 6
  • I did it, but after I restart the runtime and import tensorflow, it is not the version 2.0.0 I tried to reinstall – AleB Mar 03 '20 at 09:25
  • From my understanding, Colab has one version of tensorflow which it updates time to time, under the umbrella term 2.x. If there was a specific version you wanted, I'm not sure if there is a solution, although I would appreciate input from other users – DickyBrown Mar 04 '20 at 00:57
4

Even if you will install gpu version !pip install tensorflow-gpu==1.5.0 it will still fail to import it because of the cuda libraries. Currently I have not found a way to use 1.5 version with GPU. So I would rather use 1.4.1 with gpu than 1.5 without gpu.

You can send them a feedback ( Home - Send Feedback ) and hopefully if enough people will send something similar, they will update the new gpu version.

Salvador Dali
  • 214,103
  • 147
  • 703
  • 753
4

Google Colaboratory seems to now support tensorflow up to version 1.6.0rc1.

import tensorflow as tf
tf.__version__

#'1.6.0-rc1'

And the gpu should work if you enable the GPU hardware accelerator. Then, you can test if things are working:

from tensorflow.python.client import device_lib
device_lib.list_local_devices()

Output:

[name: "/device:CPU:0"
 device_type: "CPU"
 memory_limit: 268435456
 locality {
 }
 incarnation: 14621691266205111434, name: "/device:GPU:0"
 device_type: "GPU"
 memory_limit: 198836224
 locality {
   bus_id: 1
 }
 incarnation: 17821632640358169265
 physical_device_desc: "device: 0, name: Tesla K80, pci bus id: 0000:00:04.0, compute capability: 3.7"]
weiji14
  • 477
  • 7
  • 14
  • Yes, i also confirm that, thanks. Giving feed back just get the job done :) – AGP Feb 20 '18 at 19:53
  • Don't require to execute "!pip install -U tensorflow-gpu". If GPU acceleration is enabled it just works. – AGP Feb 20 '18 at 20:12
  • I see, edited to remove pip install tensorflow-gpu :) – weiji14 Feb 20 '18 at 20:40
  • 1
    downgrading to `v1.4.1` because I can't seem to load pre-trained weights with `v1.6.0`. anyone else having this problem? see:https://github.com/tensorflow/tensorflow/issues/17269 – michael Mar 05 '18 at 13:38
2

Edit: this will not work. Look at Salvador's answer.

Uninstall tensorflow

!pip uninstall tensorflow -y

install tensorflow-gpu

!pip install tensorflow-gpu==1.5.0
Shoeboom
  • 88
  • 1
  • 6
  • i'll try and give you the feedback. But what about CUDA 9 and cudnn 7 ?? tensorflow 1.5.0 requires these packages – AGP Feb 11 '18 at 18:01