编写 demo.py
import tensorflow as tf
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
查看日志信息若包含gpu信息,就是使用了gpu。
其他方法:跑计算量大的代码,通过 nvidia-smi 命令查看gpu的内存使用量。
执行 demo.py
执行方式1:在 python-IDLE 中打开文件demo.py 并 Run Model :
>>>
== RESTART: D:下载forGPU--CUDA--TensorFlow--CUDNNtensorflow-gpu_demo_01.py ==
>>>
什么情况?没有 gpu 信息?
执行方式2:在cmd下执行demo.py :
D:下载forGPU--CUDA--TensorFlow--CUDNN>tensorflow-gpu_demo_01.py
2018-11-02 17:25:34.590159: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
Device mapping: no known devices.
2018-11-02 17:25:34.609960: