Utilisation de Tensorflow-GPU

Peut faire référence à

Comment tensorflow utilise le GPU


import tensorflow as tf
# 查看gpu和cpu的数量
gpus = tf.config.experimental.list_physical_devices(device_type='GPU')
cpus = tf.config.experimental.list_physical_devices(device_type='CPU')
print(gpus, cpus)

tf.config.experimental.list_physical_devices(device_type='GPU')


## 设置GPU方法2
import os
os.environ['CUDA_VISIBLE_DEVICES'] = "0,1"

Guess you like

Origin blog.csdn.net/qq_30330061/article/details/127807703