英招

牢骚太盛防肠断,风物长宜放眼量

0%

GPU加速测试

Tensorflow

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import tensorflow as tf

print(tf.__version__)
print(tf.test.gpu_device_name())
print(tf.config.experimental.set_visible_devices)
print('GPU:', tf.config.list_physical_devices('GPU'))
print('CPU:', tf.config.list_physical_devices(device_type='CPU'))
print(tf.config.list_physical_devices('GPU'))
print(tf.test.is_gpu_available())
# 输出可用的GPU数量
print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))
# 查询GPU设备

tf.test.is_gpu_available()

pytorch

1
2
3
4
import torch
print(torch.__version__)
print(torch.version.cuda)
print("gpu", torch.cuda.is_available())