如何在google colaboratory上用GPU升级tensorflow

2024-05-16 09:15:27 发布

您现在位置:Python中文网/ 问答频道 /正文

目前google colaboratory使用tensorflow 1.4.1。我想把它升级到1.5.0版本。每次我执行!pip install --upgrade tensorflow命令时,笔记本实例都会成功地将tensorflow版本升级到1.5.0。但升级后的tensorflow实例只支持“CPU”。

当我执行此命令时,它不显示任何内容:

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

是否应该有其他方法来升级tensorflow?比如升级到tensorflow gpu包?笔记本什么时候会升级tensorflows?


Tags: installpip实例命令版本内容devicelib
3条回答

编辑:这不起作用。看看萨尔瓦多的回答。

卸载tensorflow

!pip uninstall tensorflow -y

安装tensorflow-gpu

!pip install tensorflow-gpu==1.5.0

Google Colaboratory现在似乎支持tensorflow到1.6.0rc1版本。

import tensorflow as tf
tf.__version__

#'1.6.0-rc1'

如果你enable the GPU hardware accelerator,gpu应该可以工作。然后,您可以测试工作是否正常:

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

输出:

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

即使您要安装gpu版本!pip install tensorflow-gpu==1.5.0,由于cuda库的原因,它仍然无法导入。目前我还没有找到一种方式使用1.5版本的GPU。所以我宁愿用带gpu的1.4.1而不是没有gpu的1.5。

您可以向他们发送反馈(主页-发送反馈),如果有足够的人发送类似的内容,他们将更新新的gpu版本。

相关问题 更多 >