Python torch.cuda.is_available()在colab中返回false
我试图在谷歌colab中使用GPU。下面是安装在my colab中的pytorch和cuda版本的详细信息Python torch.cuda.is_available()在colab中返回false,python,pytorch,google-colaboratory,Python,Pytorch,Google Colaboratory,我试图在谷歌colab中使用GPU。下面是安装在my colab中的pytorch和cuda版本的详细信息 Torch 1.3.1 CUDA 10.1.243 nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2018 NVIDIA Corporation Built on Sat_Aug_25_21:08:01_CDT_2018 Cuda compilation tools, release 10.0, V10.0.130 我
Torch 1.3.1 CUDA 10.1.243
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130
我对在pytorch模型上使用GPU进行迁移学习非常陌生。My torch.cuda.is_available()返回false,我无法使用GPU。torch.backends.cudnn.enabled返回true。这里可能出了什么问题?暂时的解决方案可能是尝试Cuda 10.0 as 大概是这样的:
conda install pytorch torchvision cudatoolkit=10.0 -c pytorch
在未来的版本中,这可能会起作用。与上面提到的所有版本一起工作,我不必将CUDA降级到10.0。更新后,我重新启动了colab,将我正在运行的机器重新设置为CPU,我只需将其更改为GPU 确保硬件加速器设置为GPU
Runtime>Change Runtime type>Hardware Accelerator
以防其他人来到这里,犯下与我相同的错误:
如果您试图检查GPU是否可用,并且您确实:
if torch.cuda.is_available:
print('GPU available')
else:
print('Please set GPU via Edit -> Notebook Settings.')
GPU似乎总是可用的。注意:您需要使用torch.cuda.is_available()
而不是torch.cuda.is_available
(这项工作于2021年1月完成)
和我的爱人:
!nvcc --version
# nvcc: NVIDIA (R) Cuda compiler driver
# Copyright (c) 2005-2019 NVIDIA Corporation
# Built on Sun_Jul_28_19:07:16_PDT_2019
# Cuda compilation tools, release 10.1, V10.1.243
您还需要确保您的colab实例中确实有一个GPU。它仍然不能工作
!nvcc --version
# nvcc: NVIDIA (R) Cuda compiler driver
# Copyright (c) 2005-2019 NVIDIA Corporation
# Built on Sun_Jul_28_19:07:16_PDT_2019
# Cuda compilation tools, release 10.1, V10.1.243