如何在Google Colab GPU中安装CUDA

2024-06-06 08:47:50 发布

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

似乎Google Colab GPU没有CUDA工具包,我如何在Google Colab GPU中安装CUDA。我在Google Colab中安装mxnet时遇到了这个错误。

Installing collected packages: mxnet
Successfully installed mxnet-1.2.0

ERROR: Incomplete installation for leveraging GPUs for computations. Please make sure you have CUDA installed and run the following line in your terminal and try again:

pip uninstall -y mxnet && pip install mxnet-cu90==1.1.0

Adjust 'cu90' depending on your CUDA version ('cu75' and 'cu80' are also available). You can also disable GPU usage altogether by invoking turicreate.config.set_num_gpus(0). An exception has occurred, use %tb to see the full traceback.

SystemExit: 1

Tags: pipinstalledandtheforyour工具包gpu
3条回答

如果您切换到使用GPU,那么CUDA将在您的VM上可用。基本上,您需要做的是匹配MXNet的版本和已安装的CUDA版本。

以下是我在Colab上安装MXNet时使用的方法:

首先检查CUDA版本

!cat /usr/local/lib/python3.6/dist-packages/external/local_config_cuda/cuda/cuda/cuda_config.h |\
grep TF_CUDA_VERSION

对我来说它输出了#define TF_CUDA_VERSION "8.0"

然后我安装了MXNet

!pip install mxnet-cu80
  1. 到这里来:https://developer.nvidia.com/cuda-downloads
  2. 选择Linux->;x86_64->;Ubuntu->;16.04->;deb(本地)
  3. 从下载按钮复制链接。
  4. 现在您必须编写命令序列。第一个是对wget的调用,wget将从您在步骤3中保存的链接下载CUDA安装程序
  5. “基础安装程序”部分将提供安装说明。也复制它们,但从所有行中删除sudo
  6. !在每一行前面插入命令,插入单元格并运行
  7. 对我来说,命令序列如下:
    !wget https://developer.nvidia.com/compute/cuda/9.2/Prod/local_installers/cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64 -O cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64.deb !dpkg -i cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64.deb !apt-key add /var/cuda-repo-9-2-local/7fa2af80.pub !apt-get update !apt-get install cuda
  8. 现在终于安装mxnet了。由于上面安装的cuda版本是9.2,我不得不悄悄地更改您的命令:!pip install mxnet-cu92
  9. Successfully installed graphviz-0.8.3 mxnet-cu92-1.2.0

我非常相信Google Colab已经预装了Cuda。。。您可以打开一个新的笔记本并键入!nvcc --version,这将返回已安装的Cuda版本。

这是我的: enter image description here

相关问题 更多 >