我是ML和Colab的新手。尝试在https://github.com/tkarras/progressive_growing_of_gans处玩这个项目,但是很难在Colab中运行它。
当我从项目中运行import_example.py脚本时,我立即收到与未加载Tensorflow有关的错误。因此,我尝试退后一步,只是做import tensorflow as tf
。运行此命令时,出现以下错误。我已将运行时设置为GPU。我昨天在Colab演示GPU代码中遇到了同样的问题,但是今天可以正常工作。
有人可以给我任何指示吗?似乎应该在环境中正常工作的基本内容。
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py in <module>()
57
---> 58 from tensorflow.python.pywrap_tensorflow_internal import *
59 from tensorflow.python.pywrap_tensorflow_internal import __version__
/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py in <module>()
27 return _mod
---> 28 _pywrap_tensorflow_internal = swig_import_helper()
29 del swig_import_helper
/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py in swig_import_helper()
23 try:
---> 24 _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
25 finally:
/usr/lib/python3.6/imp.py in load_module(name, file, filename, details)
242 else:
--> 243 return load_dynamic(name, filename, file)
244 elif type_ == PKG_DIRECTORY:
/usr/lib/python3.6/imp.py in load_dynamic(name, path, file)
342 name=name, loader=loader, origin=path)
--> 343 return _load(spec)
344
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-8-64156d691fe5> in <module>()
----> 1 import tensorflow as tf
/usr/local/lib/python3.6/dist-packages/tensorflow/__init__.py in <module>()
22
23 # pylint: disable=g-bad-import-order
---> 24 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
25
26 try:
/usr/local/lib/python3.6/dist-packages/tensorflow/python/__init__.py in <module>()
47 import numpy as np
48
---> 49 from tensorflow.python import pywrap_tensorflow
50
51 from tensorflow.python.tools import component_api_helper
/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py in <module>()
72 for some common reasons and solutions. Include the entire stack trace
73 above this error message when asking for help.""" % traceback.format_exc()
---> 74 raise ImportError(msg)
75
76 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
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/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
答案 0 :(得分:2)
即使我也面临同样的问题。后来我意识到我忘了在笔记本设置中启用 GPU 。
我启用了它并安装了 TensorFlow-GPU (GPU版本)。
您可以在编辑> 笔记本设置中找到笔记本设置。
答案 1 :(得分:1)
检查是否已在Colab中安装所需的tensorflow版本? (也许您安装了其他版本的tensorflow-gpu,但尚未安装相应的tensorflow版本。在这种情况下,我遇到了相同的错误)
!pip list
如果列表中没有tensorflow,则应同时安装tensorflow和tensorflow-gpu,如下所示:
!pip install tensorflow=='enter version here'
!pip install tensorflow-gpu=='enter same version as the previous one here'
答案 2 :(得分:0)
您只需要仔细阅读错误即可:
注意:如果由于缺少软件包而导致导入失败,则可以 使用!pip或!apt手动安装依赖项。
尝试运行:
<script
src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="cursor cursor-a"></div>
<div class="cursor cursor-b"><div class="cursor-v"></div></div>
<div class="cont">
<a class="link" href="#">custom link, hover me!</a>
</div>
在笔记本中,然后使用导入重新运行单元格。
答案 3 :(得分:0)
TensorFlow默认包含在Colab中。因此,我怀疑您已经以某种方式破坏了现有安装。
您可以通过选择“运行时->重置所有运行时...”菜单来请求新的后端。然后,再次尝试import tensorflow as tf
。