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

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')
主站蜘蛛池模板: 曲阳县| 康乐县| 乾安县| 达州市| 洞口县| 运城市| 嵩明县| 烟台市| 比如县| 建德市| 山阳县| 阜宁县| 宜都市| 伊春市| 和田县| 建平县| 周宁县| 玉山县| 宜城市| 政和县| 上蔡县| 高密市| 平阳县| 顺平县| 贵定县| 雷波县| 来凤县| 当涂县| 普格县| 宁国市| 金门县| 北票市| 铜川市| 石棉县| 如皋市| 轮台县| 和平县| 呼玛县| 杭州市| 安康市| 呼伦贝尔市|