开发者
资源
我要评分
获取效率
正确性
完整性
易理解
在线提单
论坛求助

开发验证

执行以下命令进行验证。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
python3 - <<'PY'
import tensorflow as tf  

print("tensorflow_version=" + tf.__version__) 
print("physical_gpus=" + repr(tf.config.list_physical_devices("GPU"))) 
print("built_with_cuda=" + str(tf.test.is_built_with_cuda()))  
assert tf.config.list_physical_devices("GPU") 
assert tf.test.is_built_with_cuda()  
with tf.device("/GPU:0"):     
    a = tf.constant([[1.0, 2.0], [3.0, 4.0]])     
    b = tf.constant([[1.0, 2.0], [3.0, 4.0]])     
    c = tf.matmul(a, b)  

print("tensorflow_gpu_matmul=" + str(c.numpy().tolist())) 
PY

预期输出如下信息:

1
2
3
physical_gpus=[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')] 
built_with_cuda=True 
tensorflow_gpu_matmul=[[7.0, 10.0], [15.0, 22.0]]