[英]tensorflow (not tensorflow-gpu): failed call to cuInit: UNKNOWN ERROR (303)
我的測試
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:對 cuInit 的調用失敗:CUDA_ERROR_NO_DEVICE
關鍵的區別是我沒有安裝tensorflow-gpu
包。 普通 TensorFlow 如何引發此錯誤?
您可以嘗試使用tensorflow-cpu
包而不是tensorflow
來在僅使用 cpu 的機器上解決此問題。
pip uninstall tensorflow
pip install tensorflow-cpu
安裝 nvidia-modprobe 可以解決這個問題。
sudo apt install nvidia-modprobe
您可以嘗試的其他解決方案是:
問題也可能是在使用 sudo 運行 Python 之前只存在一些/dev/nvidia*
文件,使用$ ls /dev/nvidia*
,在運行設備節點驗證腳本后, /dev/nvidia-uvm
文件被添加。
我在 Windows 操作系統上遇到了同樣的問題。 我按照 tensorflow 關於安裝 CUDA、cudnn 等的說明進行操作,並嘗試了上述答案中的建議——但沒有成功。 解決我的問題的是更新我的 GPU 驅動程序。 您可以通過以下方式更新它們:
devmgmt.msc
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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.