【发布时间】:2020-11-09 03:27:17
【问题描述】:
deviceQuery confirms Computer has Cuda capable device 在似乎加载 cuda 文件后出现此错误:
2020-07-19 17:18:41.922056: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2020-07-19 17:18:56.392936: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2020-07-19 17:18:56.969124: E tensorflow/stream_executor/cuda/cuda_driver.cc:313] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
2020-07-19 17:18:56.976577: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: SURFACE-
2020-07-19 17:18:56.980572: I tensorflow/core/platform/cpu_feature_guard.cc:143] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2020-07-19 17:18:57.018199: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x25fbcf00ee0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-07-19 17:18:57.018616: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
我签入了我的 Python 代码:tf.test.gpu_device_name(),但什么也没返回。
另外,print(device_lib.list_local_devices())中没有列出GPU
要测试的代码是:
from tensorflow.python.client import device_lib
with tf.device('/gpu: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)
tf.print(c)
print('Default GPU Device: {}'.format(tf.test.gpu_device_name()))
if tf.test.is_built_with_cuda():
print("Built with cuda")
if tf.test.is_built_with_gpu_support():
print('Built with GPU support')
if tf.test.gpu_device_name():
print('Default GPU Device: {}'.format(tf.test.gpu_device_name()))
else:
print("No Installed GPU version of TF")
print(device_lib.list_local_devices())
【问题讨论】:
-
Wadood,欢迎来到 Stackoverflow。请向我们展示您使用的导致初始错误的代码。
-
这是 Tensorflow 2.2,Cuda 10.1。
-
如果你已经安装了 CUDA 10.1,首先要做的就是verify the installation。
-
安装@RobertCrovella 已验证。 deviceQuery 和 bandwidthTest 都返回 pass。
-
我猜你的 Surface Book 正在关闭 GPU。你不妨学习一下optimus profiles的使用方法,或者有a surface book setting or control panel that allows you to force the GPU on。
标签: python tensorflow deep-learning gpu