Tensorflow 2.0 -gpu运行问题

时间:2020-04-12 21:45:58

标签: tensorflow

我为gpu 2.0版安装了Tensorflow 我尝试运行上面的代码,但出现以下错误。我该如何解决?

我有: -Windows 10 -蟒蛇3.6.10使用蟒蛇 -TF-gpu 2.0.0 -CUDA 10.0 -cudnn 7.4.2 for cuda 10.0

 import tensorflow as to
 a = tf.constant(2)
 b = tf.constant(3)
 x = tf.add(a, b)
 with tf.Session() as Sess:
 print(sess.run(x))

'''

错误:

2020?? 23:06:56.385298: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully 
opened dynamic library cudart64_100.dll
2020?? 23:07:23.072127: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports 
instructions that this TensorFlow binary was not compiled to use: AVX2
2020?? 23:07:23.079988: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully 
opened dynamic library nvcuda.dll
2020?? 23:07:23.378916: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] Found device 0 with 
properties: 
name: GeForce GTX 950M major: 5 minor: 0 memoryClockRate(GHz): 0.928
pciBusID: 0000:01:00.0
2020?? 23:07:23.387796: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU 
libraries are statically linked, skip dlopen check.
2020?? 23:07:23.389364: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1746] Adding visible gpu 
devices: 0
2020?? 23:07:26.257619: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1159] Device interconnect 
StreamExecutor with strength 1 edge matrix:
2020?? 23:07:26.258569: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1165] 0 
2020?? 23:07:26.259127: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1178] 0: N 
2020?? 23:07:26.260279: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1304] Created TensorFlow 
device (/device:GPU:0 with 3040 MB memory) ‑> physical GPU (device: 0, name: GeForce GTX 950M, pic 
bus id: 0000:01:00.0, compute capability: 5.0)
2020?? 23:07:26.263039: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] Found device 0 with 
properties: 
name: GeForce GTX 950M major: 5 minor: 0 memoryClockRate(GHz): 0.928
pciBusID: 0000:01:00.0
2020?? 23:07:26.264325: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU 
libraries are statically linked, skip dlopen check.
2020?? 23:07:26.265572: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1746] Adding visible gpu 
devices: 0
2020?? 23:07:26.266429: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1159] Device interconnect 
StreamExecutor with strength 1 edge matrix:
2020?? 23:07:26.267356: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1165] 0 
2020?? 23:07:26.267893: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1178] 0: N 
2020?? 23:07:26.268819: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1304] Created TensorFlow 
device (/device:GPU:0 with 3040 MB memory) ‑> physical GPU (device: 0, name: GeForce GTX 950M, pic 
bus id: 0000:01:00.0, compute capability: 5.0)
2020?? 23:07:28.316610: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] Found device 0 with 
properties: 
name: GeForce GTX 950M major: 5 minor: 0 memoryClockRate(GHz): 0.928
pciBusID: 0000:01:00.0
2020?? 23:07:28.317996: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU 
libraries are statically linked, skip dlopen check.
2020?? 23:07:28.319204: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1746] Adding visible gpu 
devices: 0
2020?? 23:07:28.319987: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1159] Device interconnect 
StreamExecutor with strength 1 edge matrix:
2020?? 23:07:28.320886: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1165] 0 
2020?? 23:07:28.321428: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1178] 0: N 
2020?? 23:07:28.322387: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1304] Created TensorFlow 
device (/device:GPU:0 with 3040 MB memory) ‑> physical GPU (device: 0, name: GeForce GTX 950M, pic 
bus id: 0000:01:00.0, compute capability: 5.0)
2020?? 23:07:45.885048: F tensorflow/stream_executor/lib/statusor.cc:34] Attempting to fetch value 
instead of handling error Internal: failed to get device attribute 13 for device 0: 
CUDA_ERROR_UNKNOWN: unknown errorenter code here

此外,这部分代码可以正常工作:

from tensorflow.python.client import device_lib


def get_available_devices():
        local_device_protos = device_lib.list_local_devices()
        return [x.name for x in local_device_protos]
print(get_available_devices())

0 个答案:

没有答案