首页 > 解决方案 > TensorFlow 共享库错误;ImportError:libcuda.so.1:无法打开共享对象文件:没有这样的文件或目录

问题描述

我认为我的 cudatoolkit 版本有问题,即。10.0.130。我不明白这个错误信息。我想在 X 射线图像上使用 Gradcam(热图生成器)。这是来自 deeplearning.ai 的 AI for Medicine 的相同代码,我想在我的机器上运行它,我正在尝试为这个模型创建一个 REST API。

import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

from keras.preprocessing.image import ImageDataGenerator
from keras.applications.densenet import DenseNet121
from keras.layers import Dense, GlobalAveragePooling2D
from keras.models import Model
from keras import backend as K
import keras.backend.tensorflow_backend as K
from keras.models import load_model
K.set_session
import util

文件 util.py 定义在同一目录中。

Using Theano backend.
Traceback (most recent call last):
  File "/media/macarov/Volume_H/Anacond3-Linux/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/media/macarov/Volume_H/Anacond3-Linux/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/media/macarov/Volume_H/Anacond3-Linux/lib/python3.7/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 "/media/macarov/Volume_H/Anacond3-Linux/lib/python3.7/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/media/macarov/Volume_H/Anacond3-Linux/lib/python3.7/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: libcuda.so.1: 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 "test.py", line 11, in <module>
    import keras.backend.tensorflow_backend as K
  File "/media/macarov/Volume_H/Anacond3-Linux/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py", line 5, in <module>
    import tensorflow as tf
  File "/media/macarov/Volume_H/Anacond3-Linux/lib/python3.7/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "/media/macarov/Volume_H/Anacond3-Linux/lib/python3.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/media/macarov/Volume_H/Anacond3-Linux/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/media/macarov/Volume_H/Anacond3-Linux/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/media/macarov/Volume_H/Anacond3-Linux/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/media/macarov/Volume_H/Anacond3-Linux/lib/python3.7/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 "/media/macarov/Volume_H/Anacond3-Linux/lib/python3.7/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/media/macarov/Volume_H/Anacond3-Linux/lib/python3.7/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: libcuda.so.1: 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.

标签: keraspython-3.7tensorflow2.0

解决方案


问题是我的虚拟环境中的 python 3.7。我降级到 python 3.6.5,一切似乎都很好。


推荐阅读