Tensorflow 知识

版权声明:我写的东西都是我的你不能拿走(转载请说明 (╥﹏╥) ) https://blog.csdn.net/qq_326324545/article/details/85007460

查看已安装tensorflow版本

import tensorflow as tf

tf.__version__

tf.__path__

确定自己的TensorFlow是CPU还是GPU的版本

import numpy
import tensorflow as tf
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)
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
print(sess.run(c))

之后就会出现详细的信息:

Device mapping:
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: Tesla K40c, pci bus
id: 0000:05:00.0
b: /job:localhost/replica:0/task:0/device:GPU:0
a: /job:localhost/replica:0/task:0/device:GPU:0
MatMul: /job:localhost/replica:0/task:0/device:GPU:0
[[ 22.  28.]
 [ 49.  64.]]

GPU用完不关的问题

InternalError: Blas SGEMM launch failed : 。。。。。

if 'session' in locals() and session is not None:
    print('Close interactive session')
    session.close()

shutdown kernel or 重启计算机 亦可释放归还.

猜你喜欢

转载自blog.csdn.net/qq_326324545/article/details/85007460