目录
1.查看当前Tensorflow版本
2.查看当前主机运行的设备
3.查看GPU是否可用,指定在CPU/GPU运行
4.比较CPU和GPU上的运行时间
1.查看当前Tensorflow版本
import tensorflow as tf
print(tf.__version__)
会得到自己的tensorflow的版本号
2.查看当前主机运行的设备
import tensorflow as tf
gpus = tf.config.experimental.list_physical_devices(device_type='GPU')
cpus = tf.config.experimental.list_physical_devices(device_type='CPU')
print(gpus)
print(cpus)
3.查看GPU是否可用,指定在CPU/GPU运行
import tensorflow as tf
# 指定在cpu上运行
with tf.device