【问题标题】:tensorflow (not tensorflow-gpu): failed call to cuInit: UNKNOWN ERROR (303)tensorflow(不是 tensorflow-gpu):调用 cuInit 失败:未知错误(303)
【发布时间】:2019-12-27 10:58:54
【问题描述】:

我的测试

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()

我的错误

2019-12-27 10:51:17.887009: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/openmpi/lib:
2019-12-27 10:51:17.888489: E tensorflow/stream_executor/cuda/cuda_driver.cc:318] failed call to cuInit: UNKNOWN ERROR (303)
2019-12-27 10:51:17.888992: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (3e7d899714a9): /proc/driver/nvidia/version does not exist
2019-12-27 10:51:17.890608: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-12-27 10:51:17.915554: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2904000000 Hz
2019-12-27 10:51:17.918061: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x56101fca67e0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2019-12-27 10:51:17.918228: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version

我的环境

乌布努图 18

张量流 1.15.0/1.14.0

我的问题

我已经查看过类似的问题,例如 TensorFlow : failed call to cuInit: CUDA_ERROR_NO_DEVICE

主要区别是我没有安装tensorflow-gpu 包。普通的TensorFlow怎么会出现这个错误?

【问题讨论】:

  • 我在 Windows 上使用 tensorflow:1.15.0 docker 映像 as seen here 收到相同的消息。

标签: python tensorflow


【解决方案1】:

您可以尝试通过使用tensorflow-cpu 包而不是tensorflow 在仅cpu 的机器上解决此问题。

pip uninstall tensorflow
pip install tensorflow-cpu

【讨论】:

  • 这样做有什么缺点吗?
  • @Jitin 嗯,如果您在 gpu 和非 gpu 机器上使用某种类型的模型自动部署,则只有在机器之间没有一致的包要求的明显缺点。否则,如果你没有使用 tensorflow 的 gpu 特性,AFAIK 没有缺点。
【解决方案2】:

安装 nvidia-modprobe 可以解决这个问题。

sudo apt install nvidia-modprobe

您可以尝试的其他解决方案是:

  • 卸载并安装 CUDA 和 cuDNN。
  • 安装 tensorflow-gpu。
  • 卸载并安装不同的 Nvidia 驱动程序版本。

问题还可能是在使用 sudo 运行 Python 之前只存在一些 /dev/nvidia* 文件,使用 $ ls /dev/nvidia* 检查,在运行 Device Node verification script 之后添加了 /dev/nvidia-uvm 文件。

【讨论】:

    【解决方案3】:

    我在 Windows 操作系统上遇到了同样的问题。我按照 tensorflow 关于安装 CUDA、cudnn 等的说明进行操作,并尝试了上述答案中的建议——但没有成功。 解决我的问题是更新我的 GPU 驱动程序。您可以通过以下方式更新它们:

    1. 按 windows-button + r
    2. 输入devmgmt.msc
    3. 右键单击“显示适配器”并单击“属性”选项
    4. 转到“驱动程序”选项卡并选择“更新驱动程序”。
    5. 最后,点击“自动搜索更新的驱动软件”
    6. 重新启动计算机并再次运行以下检查:
    import tensorflow as tf
    hello = tf.constant('Hello, TensorFlow!')
    sess = tf.Session()
    
    Sample output:
    2022-01-17 14:01:54.999571: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1640] Found device 0 with properties:
    name: GeForce 940MX major: 5 minor: 0 memoryClockRate(GHz): 1.189
    pciBusID: 0000:01:00.0
    2022-01-17 14:01:54.999820: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU libraries are statically linked, skip dlopen check.
    2022-01-17 14:01:55.000888: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1763] Adding visible gpu devices: 0
    2022-01-17 14:01:55.006480: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1640] Found device 0 with properties:
    name: GeForce 940MX major: 5 minor: 0 memoryClockRate(GHz): 1.189
    pciBusID: 0000:01:00.0
    2022-01-17 14:01:55.006696: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU libraries are statically linked, skip dlopen check.
    2022-01-17 14:01:55.007744: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1763] Adding visible gpu devices: 0
    2022-01-17 14:01:55.008511: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1181] Device interconnect StreamExecutor with strength 1 edge matrix:
    2022-01-17 14:01:55.009162: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1187]      0
    2022-01-17 14:01:55.009876: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1200] 0:   N
    2022-01-17 14:01:55.010857: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1326] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 1391 MB memory) -> physical GPU (device: 0, name: GeForce 940MX, pci bus id: 0000:01:00.0, compute capability: 5.0)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-06
      • 2018-07-17
      • 2021-10-04
      • 2017-10-14
      • 2021-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多