对cuInit的调用失败:CUDA_ERROR_INVALID_DEVICE:无效的设备序号

时间:2019-05-24 09:25:46

标签: python tensorflow

Tensorflow停止识别我的GPU(以前可以工作)。

代码:

import os
import tensorflow as tf

os.environ["CUDA_VISIBLE_DEVICES"] = "0"

a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)

print(c)

输出:

2019-05-24 10:16:30.726799: 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-05-24 10:16:30.740369: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcuda.so.1
2019-05-24 10:16:30.777178: E tensorflow/stream_executor/cuda/cuda_driver.cc:318] failed call to cuInit: CUDA_ERROR_INVALID_DEVICE: invalid device ordinal
2019-05-24 10:16:30.777232: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:166] retrieving CUDA diagnostic information for host: joao-Yoga730
2019-05-24 10:16:30.777242: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:173] hostname: joao-Yoga730
2019-05-24 10:16:30.777331: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:197] libcuda reported version is: 410.48.0
2019-05-24 10:16:30.777364: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:201] kernel reported version is: 410.48.0
2019-05-24 10:16:30.777371: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:308] kernel version seems to match DSO: 410.48.0
2019-05-24 10:16:30.799754: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 1992000000 Hz
2019-05-24 10:16:30.801312: I tensorflow/compiler/xla/service/service.cc:162] XLA service 0x55e937b11800 executing computations on platform Host. Devices:
2019-05-24 10:16:30.801384: I tensorflow/compiler/xla/service/service.cc:169]   StreamExecutor device (0): <undefined>, <undefined>
tf.Tensor(
[[22. 28.]
 [49. 64.]], shape=(2, 2), dtype=float32)

Process finished with exit code 0

nvidia-smi输出:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 410.48                 Driver Version: 410.48                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 1050    Off  | 00000000:3B:00.0 Off |                  N/A |
| N/A   52C    P3    N/A /  N/A |    500MiB /  4042MiB |      4%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1474      G   /usr/lib/xorg/Xorg                           296MiB |
|    0      1650      G   /usr/bin/gnome-shell                         145MiB |
|    0      2107      G   ...uest-channel-token=16113907172495644879    55MiB |
|    0      4229      G   /snap/pycharm-community/128/jre64/bin/java     2MiB |
+-----------------------------------------------------------------------------+

Ubuntu 18.04 Tensorflow'2.0.0-alpha0'

有什么想法吗?

p.s。我尝试做sudo apt install nvidia-modprobe。没用。

0 个答案:

没有答案