Python tensorflow(非tensorflow gpu):调用cuInit失败:未知错误(303)

Python tensorflow(非tensorflow gpu):调用cuInit失败:未知错误(303),python,tensorflow,Python,Tensorflow,我的测试 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: libcu

我的测试

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
我的环境

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
乌布努图18

tensorflow 1.15.0/1.14.0

我的问题

例如,我已经回顾了类似的问题


关键区别在于我没有安装
tensorflow gpu
软件包。正常的TensorFlow怎么会引发此错误?

安装nvidia modprobe可以解决此问题

sudo apt install nvidia-modprobe
您可以尝试的其他解决方案有:

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

问题还可能是,在使用sudo运行Python之前,只有一些
/dev/nvidia*
文件存在,请使用
$ls/dev/nvidia*
进行检查,运行后,会添加
/dev/nvidia uvm
文件。

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

pip uninstall tensorflow
pip install tensorflow-cpu

使用windows上的
tensorflow:1.15.0
docker映像,我得到了相同的信息。这有什么缺点吗?@Jitin Hmmm,唯一明显的缺点是,如果您在gpu和非gpu机器上使用某种自动部署模型,则不同机器之间的包要求不一致。否则,如果您不使用tensorflow的gpu功能,AFAIK就没有缺点。