GPU版TensorFlow安装后测试遇异常日志,求解决方法
TensorFlow GPU日志问题说明
你贴出的这条日志并非错误信息,而是TensorFlow成功识别并初始化GPU设备的正常提示:
2023-01-03 18:26:00.103847: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1616] Created device /device:GPU:0 with 5453 MB memory: -> device: 0, name: NVIDIA GeForce RTX 3070, pci bus id: 0000:09:00.0, compute capability: 8.6
日志关键信息解读:
/device:GPU:0:TensorFlow已将你的RTX 3070标记为可用GPU设备5453 MB memory:TensorFlow当前分配到的GPU显存(剩余显存会留给系统及其他程序使用)compute capability: 8.6:你的显卡算力符合TensorFlow 2.10的要求(TF2.10支持算力3.5至8.6的NVIDIA显卡)
如果要确认GPU是否真的参与计算,可以运行以下测试代码:
import tensorflow as tf # 查看可用GPU设备 print(tf.config.list_physical_devices('GPU')) # 验证计算是否在GPU上执行 with tf.device('/GPU:0'): a = tf.constant([1.0, 2.0, 3.0]) b = tf.constant([4.0, 5.0, 6.0]) c = tf.matmul(tf.reshape(a, (3,1)), tf.reshape(b, (1,3))) print(c)
运行后若能正常输出计算结果,且tf.config.list_physical_devices('GPU')返回包含RTX 3070的列表,就说明GPU版本TensorFlow已正常工作。
内容的提问来源于stack exchange,提问作者Peter Jurák
相关产品推荐
相关产品推荐

