官术网_书友最值得收藏!

Using eager execution

Eager execution is the default in TensorFlow 2 and, as such, needs no special setup.

The following code can be used to find out whether a CPU or GPU is in use and if it's a GPU, whether that GPU is #0.

We suggest typing the code in rather than using copy and paste; this way you will get a feel for the commands:

var = tf.Variable([3, 3])

if tf.test.is_gpu_available():
print('Running on GPU')
print('GPU #0?')
print(var.device.endswith('GPU:0'))
else:
print('Running on CPU')
主站蜘蛛池模板: 平乐县| 寻甸| 乌拉特中旗| 惠水县| 赣榆县| 斗六市| 营口市| 公安县| 阜城县| 濉溪县| 黑龙江省| 大竹县| 司法| 山阳县| 靖江市| 华容县| 泽州县| 本溪| 洞口县| 兖州市| 沙洋县| 射阳县| 义马市| 犍为县| 平遥县| 江川县| 雷波县| 敦化市| 汉中市| 荥经县| 宝清县| 霍城县| 任丘市| 乐都县| 慈利县| 湟源县| 上犹县| 隆化县| 田阳县| 阳曲县| 应城市|