为什么 import cntk as C 在 google colab 中不起作用
Why is import cntk as C not working in google colab
我安装了opencv 3.4.4版本,安装了cntk,导入到google collab中得到如下结果。
import cntk as C
/usr/local/lib/python3.6/dist-packages/cntk/cntk_py_init.py:56: UserWarning: Unsupported Linux distribution (ubuntu-18.04). CNTK supports Ubuntu 16.04 and above, only.
warnings.warn('Unsupported Linux distribution (%s-%s). CNTK supports Ubuntu 16.04 and above, only.' % (__my_distro__, __my_distro_ver__))
/usr/local/lib/python3.6/dist-packages/cntk/cntk_py_init.py:102: UserWarning:
################################################ Missing optional dependency ( OpenCV ) ################################################
CNTK may crash if the component that depends on those dependencies is loaded.
Visit https://docs.microsoft.com/en-us/cognitive-toolkit/Setup-Linux-Python#optional-opencv for more information.
############################################################################################################################################
warnings.warn(WARNING_MSG % (' OpenCV ', 'https://docs.microsoft.com/en-us/cognitive-toolkit/Setup-Linux-Python#optional-opencv'))
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/cntk/cntk_py.py in swig_import_helper()
17 try:
---> 18 return importlib.import_module(mname)
19 except ImportError:
/usr/lib/python3.6/importlib/__init__.py in import_module(name, package)
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)
127
/usr/lib/python3.6/importlib/_bootstrap.py in _gcd_import(name, package, level)
/usr/lib/python3.6/importlib/_bootstrap.py in _find_and_load(name, import_)
/usr/lib/python3.6/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)
ModuleNotFoundError: No module named 'cntk._cntk_py'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-29-f8cc57397495> in <module>()
----> 1 import cntk as c
/usr/local/lib/python3.6/dist-packages/cntk/__init__.py in <module>()
20 import numpy as np
21
---> 22 from . import cntk_py
23
24 #
/usr/local/lib/python3.6/dist-packages/cntk/cntk_py.py in <module>()
19 except ImportError:
20 return importlib.import_module('_cntk_py')
---> 21 _cntk_py = swig_import_helper()
22 del swig_import_helper
23 elif _swig_python_version_info >= (2, 6, 0):
/usr/local/lib/python3.6/dist-packages/cntk/cntk_py.py in swig_import_helper()
18 return importlib.import_module(mname)
19 except ImportError:
---> 20 return importlib.import_module('_cntk_py')
21 _cntk_py = swig_import_helper()
22 del swig_import_helper
/usr/lib/python3.6/importlib/__init__.py in import_module(name, package)
124 break
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)
127
128
我安装了opencv。版本是cv2。我希望在 google 协作实验室中将 RNN 和 LSTM 网络用于序列到序列模型。
如何纠正这个错误?
一般来说,在寻求有关 colab 的帮助时,最好分享一个可以重现问题的最小笔记本,这样试图帮助的人就可以清楚地知道您到底做了什么(例如 "I installed opencv version 3.4.4" 不如提供信息的查看您使用过的精确命令,以及它们生成的任何输出,等等)。
至少第一个警告可能无法解决,因为 colab 的虚拟机 运行 ubuntu:18.04 但 CNTK 正式不支持 16.04 以外的任何内容:"Note that only Ubuntu 16.04 is officially supported." (来自 https://docs.microsoft.com/en-us/cognitive-toolkit/setup-linux-python?tabs=cntkpy26)
我不熟悉 CNTK 或其部门,但这似乎成功导入(尽管有警告)并成功显示模块的界面:
!apt-get install --no-install-recommends openmpi-bin libopenmpi-dev libopencv-dev python3-opencv python-opencv && ln -sf /usr/lib/x86_64-linux-gnu/libmpi_cxx.so /usr/lib/x86_64-linux-gnu/libmpi_cxx.so.1 && ln -sf /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so.12 && ln -sf /usr/lib/x86_64-linux-gnu/libmpi.so /usr/lib/x86_64-linux-gnu/libmpi.so.12 && pip install cntk
import cntk as C
help(C)
(在 py3/CPU colab notebook 中;遗憾的是,第一行需要将近 2m 到 运行,所以请耐心等待)
我安装了opencv 3.4.4版本,安装了cntk,导入到google collab中得到如下结果。
import cntk as C
/usr/local/lib/python3.6/dist-packages/cntk/cntk_py_init.py:56: UserWarning: Unsupported Linux distribution (ubuntu-18.04). CNTK supports Ubuntu 16.04 and above, only.
warnings.warn('Unsupported Linux distribution (%s-%s). CNTK supports Ubuntu 16.04 and above, only.' % (__my_distro__, __my_distro_ver__))
/usr/local/lib/python3.6/dist-packages/cntk/cntk_py_init.py:102: UserWarning:
################################################ Missing optional dependency ( OpenCV ) ################################################
CNTK may crash if the component that depends on those dependencies is loaded.
Visit https://docs.microsoft.com/en-us/cognitive-toolkit/Setup-Linux-Python#optional-opencv for more information.
############################################################################################################################################
warnings.warn(WARNING_MSG % (' OpenCV ', 'https://docs.microsoft.com/en-us/cognitive-toolkit/Setup-Linux-Python#optional-opencv'))
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/cntk/cntk_py.py in swig_import_helper()
17 try:
---> 18 return importlib.import_module(mname)
19 except ImportError:
/usr/lib/python3.6/importlib/__init__.py in import_module(name, package)
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)
127
/usr/lib/python3.6/importlib/_bootstrap.py in _gcd_import(name, package, level)
/usr/lib/python3.6/importlib/_bootstrap.py in _find_and_load(name, import_)
/usr/lib/python3.6/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)
ModuleNotFoundError: No module named 'cntk._cntk_py'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-29-f8cc57397495> in <module>()
----> 1 import cntk as c
/usr/local/lib/python3.6/dist-packages/cntk/__init__.py in <module>()
20 import numpy as np
21
---> 22 from . import cntk_py
23
24 #
/usr/local/lib/python3.6/dist-packages/cntk/cntk_py.py in <module>()
19 except ImportError:
20 return importlib.import_module('_cntk_py')
---> 21 _cntk_py = swig_import_helper()
22 del swig_import_helper
23 elif _swig_python_version_info >= (2, 6, 0):
/usr/local/lib/python3.6/dist-packages/cntk/cntk_py.py in swig_import_helper()
18 return importlib.import_module(mname)
19 except ImportError:
---> 20 return importlib.import_module('_cntk_py')
21 _cntk_py = swig_import_helper()
22 del swig_import_helper
/usr/lib/python3.6/importlib/__init__.py in import_module(name, package)
124 break
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)
127
128
我安装了opencv。版本是cv2。我希望在 google 协作实验室中将 RNN 和 LSTM 网络用于序列到序列模型。 如何纠正这个错误?
一般来说,在寻求有关 colab 的帮助时,最好分享一个可以重现问题的最小笔记本,这样试图帮助的人就可以清楚地知道您到底做了什么(例如 "I installed opencv version 3.4.4" 不如提供信息的查看您使用过的精确命令,以及它们生成的任何输出,等等)。
至少第一个警告可能无法解决,因为 colab 的虚拟机 运行 ubuntu:18.04 但 CNTK 正式不支持 16.04 以外的任何内容:"Note that only Ubuntu 16.04 is officially supported." (来自 https://docs.microsoft.com/en-us/cognitive-toolkit/setup-linux-python?tabs=cntkpy26)
我不熟悉 CNTK 或其部门,但这似乎成功导入(尽管有警告)并成功显示模块的界面:
!apt-get install --no-install-recommends openmpi-bin libopenmpi-dev libopencv-dev python3-opencv python-opencv && ln -sf /usr/lib/x86_64-linux-gnu/libmpi_cxx.so /usr/lib/x86_64-linux-gnu/libmpi_cxx.so.1 && ln -sf /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so.12 && ln -sf /usr/lib/x86_64-linux-gnu/libmpi.so /usr/lib/x86_64-linux-gnu/libmpi.so.12 && pip install cntk
import cntk as C
help(C)
(在 py3/CPU colab notebook 中;遗憾的是,第一行需要将近 2m 到 运行,所以请耐心等待)