【问题标题】:How to install Cuda and cudnn on google colab?如何在 google colab 上安装 Cuda 和 cudnn?
【发布时间】:2018-11-06 04:48:04
【问题描述】:

我使用 google colab 训练 may 数据集。我将我的数据集上传到谷歌驱动器并从谷歌 colab 中召回。但运行 train.py 脚本意味着以下错误。更准确地说,我运行:

!python3  /content/drive/tensorflow1/models/research/object_detection/train.py --logtostderr --train_dir=/content/drive/tensorflow1/models/research/object_detection/training/ --pipeline_config_path=/content/drive/tensorflow1/models/research/object_detection/training/faster_rcnn_inception_v2_pets.config

我得到了这些错误:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/usr/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/usr/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/content/drive/tensorflow1/models/research/object_detection/train.py", line 47, in <module>
    import tensorflow as tf
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/usr/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/usr/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

我需要先安装或上传 Cuda9 或 Cudnn 到谷歌驱动器来解决 colab 上的主题吗?我怎样才能通过这些错误?

【问题讨论】:

    标签: cuda training-data google-colaboratory cudnn


    【解决方案1】:

    请记住,您必须先在笔记本上明确启用 GPU,然后才能使用 tensorflow-gpu。我怀疑缺少这一步。

    为了启用GPU,请尝试菜单'runtime->change runtime->硬件加速器->gpu'

    如果有帮助,请将其标记为解决方案,以便其他人受益。

    【讨论】:

    • 谢谢 Adnan Y。我通过在 colab 上安装 tensorflow 而不是 tensorflow-gpu 解决了这个问题。虽然我不确定我是否需要在 colab 上安装 tensorflow。
    • 你不应该这样做。并不是说它会阻止您安装任何东西,因为它只是一个 docker 容器。
    • 我怀疑 Farshad 在他的 colab 笔记本中已经有了 libcublas,但是 libcublas 的版本不同。可以用这样的find /usr -regex ".*libcublas.*"来计算。即使使用 GPU,我也有同样的问题。您可以使用pip install tensorflow-gpu 轻松重现此问题。预装 tensorflow 不会出现此问题。
    • @Farshad - Tensorflow 新手。安装 tensorflow-gpu 对我来说很有意义,因为您使用的是 GPU,为什么在这种情况下安装 tensorflow 有效?非常混乱。
    【解决方案2】:

    由于 tensorflow-gpu>=1.5.0 需要 CUDA 9,您应该安装 tensorflow-gpu==1.4.0。
    pip install --upgrade tensorflow-gpu==1.4

    请参考以下两个链接。
    https://github.com/tensorflow/tensorflow/issues/15604 https://www.tensorflow.org/install/install_sources#tested_source_configurations

    【讨论】:

    • 不要按照你的逻辑。首先,你怎么知道这个人使用的是什么版本的 CUDA? Tensorfow 版本与 cuDNN 和 CUDA 版本有非常敏感的关系。您是否还需要知道 cuDNN 版本来推荐使用哪个 tensoflow-gpu 版本?
    【解决方案3】:

    首先,在 Google Colab Notebook 上启用 GPU

    Go to Menu &gt; Runtime &gt; Change runtime.

    Change hardware acceleration to GPU.

    How to install CUDA in Google Colab GPU's

    【讨论】:

    • 我不明白这是如何被允许的,因为 colab 具有默认的 gpu 及其相应的 cuda lib 和 cudnn lib。如果您对此进行更改,由于更改发生在 /usr/lib 级别,这不会影响全局吗?这根本没有意义。
    • 我的回答描述了如何启动 GPU 协作实例,我没有告诉如何安装 CUDA。有些人不知道如何获取 GPU 协作实例,所以他们认为可能是软件安装问题,但实际上他们没有使用 google 官方方法启用 GPU。
    • 好的。我明白了。 google collab 在 imo 推出 gpu 及其相应的 cuda.cudnn lib 方面做得很糟糕。我看到很多情况下它昨天工作但它停止工作了。所以代码没有改变,但系统库已经改变,这对编码器来说是一个黑匣子。
    猜你喜欢
    • 2020-01-07
    • 2018-11-06
    • 2021-05-05
    • 2020-05-30
    • 2020-06-07
    • 2018-09-25
    • 2021-11-09
    • 1970-01-01
    相关资源
    最近更新 更多