python - 未能加载原生 TensorFlow 运行时(MrCNN 实现的 tensorflow 兼容性)
问题描述
我目前正在运行 MRCnn 演示笔记本文件,因为我想实现分段。我已将代码片段上传到我的 jupiter 笔记本,该笔记本连接到我在 AWS 上的 ec2 实例。我很难找到哪个版本的 TensorFlow 和 Keras 与 Matterhorn 的 Mrcnn 模型兼容。我一直在安装各种版本的 TensorFlow 和 keras,但我无法获得兼容的确切版本。有人可以指导我吗?我收到以下错误我当前的 tensorflow 版本是 - 1.3.0 (gpu) Keras 版本 - 2.0.8
ImportError Traceback (most recent call last)
~/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py in <module>
40 sys.setdlopenflags(_default_dlopen_flags | ctypes.RTLD_GLOBAL)
---> 41 from tensorflow.python.pywrap_tensorflow_internal import *
42 from tensorflow.python.pywrap_tensorflow_internal import __version__
~/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py in <module>
27 return _mod
---> 28 _pywrap_tensorflow_internal = swig_import_helper()
29 del swig_import_helper
~/.local/lib/python3.6/site-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: libcusolver.so.8.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-3-ebe7095df7bb> in <module>
13 # Import Mask RCNN
14 sys.path.append(ROOT_DIR) # To find local version of the library
---> 15 from mrcnn import utils
16 import mrcnn.model as modellib
17 from mrcnn import visualize
~/MyNotebooks/Mask_RCNN/mrcnn/utils.py in <module>
14 import random
15 import numpy as np
---> 16 import tensorflow as tf
17 import scipy
18 import skimage.color
~/.local/lib/python3.6/site-packages/tensorflow/__init__.py in <module>
22
23 # pylint: disable=wildcard-import
---> 24 from tensorflow.python import *
25 # pylint: enable=wildcard-import
26
~/.local/lib/python3.6/site-packages/tensorflow/python/__init__.py in <module>
47 import numpy as np
48
---> 49 from tensorflow.python import pywrap_tensorflow
50
51 # Protocol buffers
~/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py in <module>
50 for some common reasons and solutions. Include the entire stack trace
51 above this error message when asking for help.""" % traceback.format_exc()
---> 52 raise ImportError(msg)
53
54 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
ImportError: Traceback (most recent call last):
File "/home/ubuntu/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/ubuntu/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/ubuntu/.local/lib/python3.6/site-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: libcusolver.so.8.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
我执行的代码片段如下
import os
import sys
import random
import math
import numpy as np
import skimage.io
import matplotlib
import matplotlib.pyplot as plt
# Root directory of the project
ROOT_DIR = os.path.abspath("../")
# Import Mask RCNN
sys.path.append(ROOT_DIR) # To find local version of the library
from mrcnn import utils
import mrcnn.model as modellib
from mrcnn import visualize
# Import COCO config
sys.path.append(os.path.join(ROOT_DIR, "samples/coco/")) # To find local version
import coco
%matplotlib inline
# Directory to save logs and trained model
MODEL_DIR = os.path.join(ROOT_DIR, "logs")
# Local path to trained weights file
COCO_MODEL_PATH = os.path.join(ROOT_DIR, "mask_rcnn_coco.h5")
# Download COCO trained weights from Releases if needed
if not os.path.exists(COCO_MODEL_PATH):
utils.download_trained_weights(COCO_MODEL_PATH)
# Directory of images to run detection on
IMAGE_DIR = os.path.join(ROOT_DIR, "images")
解决方案
推荐阅读
- asp.net-core - DbContextOptionsBuilder'不包含'usesqlserver'的定义,并且在asp.net core 2.2中没有扩展方法'usesqlserver'?
- python - 在我的自定义 PySide2 UI 中添加 Maya UV Editor 和 UV Toolkit
- sql - SQLite UPDATE ID 删除行
- python - 每次添加 n 行并将结果保存在 pandas 的新数据框中
- python - 将三列之间的数学运算结果附加到下一行
- android - 数字计数器在 +/- 按下 kotlin 时改变数量
- android - SQLDelight - 修改子表时在父表上发出
- rest - GCP 中的 CDAP API 调用失败
- apache-spark - Spark删除重复的单元格值和
- javascript - 从 PayPal SDK 客户端中的 OnError 和 OnApproval 重定向到成功/错误页面