简体   繁体   中英

tensorflow (not tensorflow-gpu): failed call to cuInit: UNKNOWN ERROR (303)

My Test

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

My Error

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

My Environment

Ubunutu 18

tensorflow 1.15.0/1.14.0

My Question

I have reviewed similar issues for example TensorFlow : failed call to cuInit: CUDA_ERROR_NO_DEVICE

The key difference is I do not have the tensorflow-gpu package installed. How can this error be raised by normal TensorFlow?

You can attempt to work around this problem on cpu-only machines by using the tensorflow-cpu package instead of tensorflow .

pip uninstall tensorflow
pip install tensorflow-cpu

Installing nvidia-modprobe can solve this issue.

sudo apt install nvidia-modprobe

Other solutions you can try are :

  • Uninstall and install CUDA and cuDNN.
  • Install tensorflow-gpu.
  • Uninstall and install different Nvidia driver versions.

The problem also could be that only some /dev/nvidia* files are present before running Python with sudo, check using $ ls /dev/nvidia* , after running the Device Node verification script the /dev/nvidia-uvm file gets added.

I experienced the same problem on my Windows OS. I followed tensorflow's instructions on installing CUDA, cudnn, etc., and tried the suggestions in the answers above - with no success. What solved my issue was to update my GPU drivers. You can update them via:

  1. Pressing windows-button + r
  2. Entering devmgmt.msc
  3. Right-Clicking on "Display adapters" and clicking on the "Properties" option
  4. Going to the "Driver" tab and selecting "Updating Driver".
  5. Finally, click on "Search automatically for updated driver software"
  6. Restart your machine and run the following check again:
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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM