tensorflow-gpu运行测试代码,卡在 I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu

新建一个环境解释器后,想要运行测试代码如下,会发现不管是cmd运行还是pycharm运行,都会卡在“Device mapping”的上一句 I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu devices: 0然后就不动了如下图,我试着重新运行了两次就好了,貌似第一次运行GPU的时候就会卡在这里会很慢,运行卡在那句后就耐心等待即可
 


import tensorflow as tf

a=tf.constant([1,2,3],shape=[3],name="a")

b=tf.constant([1,2,3],shape=[3],name="b")

 

c=a+b

sess=tf.Session(config=tf.ConfigProto(log_device_placement=True))

print(sess.run(c))

sess.close()

 

'''

显示如下,即成功

2019-05-28 09:37:49.590066: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2

2019-05-28 09:37:50.501663: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1433] Found device 0 with properties: 

name: GeForce GTX 960M major: 5 minor: 0 memoryClockRate(GHz): 1.176

pciBusID: 0000:02:00.0

totalMemory: 4.00GiB freeMemory: 3.34GiB

2019-05-28 09:37:50.502165: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu devices: 0

Device mapping:

/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: GeForce GTX 960M, pci bus id: 0000:02:00.0, compute capability: 5.0

add: (Add): /job:localhost/replica:0/task:0/device:GPU:0

a: (Const): /job:localhost/replica:0/task:0/device:GPU:0

b: (Const): /job:localhost/replica:0/task:0/device:GPU:0

2019-05-28 09:37:51.816402: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] Device interconnect StreamExecutor with strength 1 edge matrix:

2019-05-28 09:37:51.816683: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990]      0 

2019-05-28 09:37:51.816848: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1003] 0:   N 

2019-05-28 09:37:51.817173: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 3050 MB memory) -> physical GPU (device: 0, name: GeForce GTX 960M, pci bus id: 0000:02:00.0, compute capability: 5.0)

2019-05-28 09:37:51.819865: I tensorflow/core/common_runtime/direct_session.cc:317] Device mapping:

/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: GeForce GTX 960M, pci bus id: 0000:02:00.0, compute capability: 5.0

 

2019-05-28 09:37:51.822325: I tensorflow/core/common_runtime/placer.cc:1059] add: (Add)/job:localhost/replica:0/task:0/device:GPU:0

2019-05-28 09:37:51.822733: I tensorflow/core/common_runtime/placer.cc:1059] a: (Const)/job:localhost/replica:0/task:0/device:GPU:0

2019-05-28 09:37:51.823151: I tensorflow/core/common_runtime/placer.cc:1059] b: (Const)/job:localhost/replica:0/task:0/device:GPU:0

[2 4 6]

'''

 tensorflow-gpu运行测试代码,卡在 I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu_第1张图片

你可能感兴趣的:(tensorflow-gpu运行测试代码,卡在 I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu)