Google Colab:GPU不使用tensorflow 1.12.0加载



我正在尝试使用GPU 在Google Colab中训练一个模型

我做到了:

Edit→Notebook Settings
select GPU from the Hardware Accelerator drop-down

我安装了我的项目所需的这个特定版本:

tensorboard==1.12.2
tensorflow==1.12.0
Keras==2.2.4
Keras-Applications==1.0.6
Keras-Preprocessing==1.0.5

然后,当我运行时:

from tensorflow.python.client import device_lib
import tensorflow as to
print(device_lib.list_local_devices())
tf.test.is_gpu_available()

我得到:

[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 14765383507671724357
, name: "/device:XLA_CPU:0"
device_type: "XLA_CPU"
memory_limit: 17179869184
locality {
}
incarnation: 9874560735213287977
physical_device_desc: "device: XLA_CPU device"
]
False

如何使用GPU?

安装以下程序可以解决问题:

!wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
!wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb
!wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7-dev_7.0.5.15-1+cuda9.0_amd64.deb
!wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libnccl2_2.1.4-1+cuda9.0_amd64.deb
!wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libnccl-dev_2.1.4-1+cuda9.0_amd64.deb
!wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7_7.1.4.18-1+cuda9.0_amd64.deb
!sudo dpkg -i cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
!sudo dpkg -i libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb
!sudo dpkg -i libcudnn7-dev_7.0.5.15-1+cuda9.0_amd64.deb
!sudo dpkg -i libnccl2_2.1.4-1+cuda9.0_amd64.deb
!sudo dpkg -i libnccl-dev_2.1.4-1+cuda9.0_amd64.deb
!sudo apt-get update
!sudo apt-get install cuda=9.0.176-1
!sudo apt-get install libcudnn7-dev
!sudo dpkg -i libcudnn7_7.1.4.18-1+cuda9.0_amd64.deb
!sudo apt-get install libnccl-dev

最新更新