How to upgrade tensorflow with GPU on google colaboratory

血红的双手。 提交于 2020-01-13 07:00:08

问题


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 ?


回答1:


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.




回答2:


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"]



回答3:


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


来源:https://stackoverflow.com/questions/48731124/how-to-upgrade-tensorflow-with-gpu-on-google-colaboratory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!