您正在使用GPU版本。您可以列出可用的tensorflow设备(也请检查此问题):
from tensorflow.python.client import device_libprint(device_lib.list_local_devices()) # list of DeviceAttributes
编辑:
使用tensorflow> =1.4时,您可以运行以下功能:
import tensorflow as tftf.test.is_gpu_available() # True/False# Or only check for gpu's with cuda supporttf.test.is_gpu_available(cuda_only=True)
编辑2:
上面的功能在中已弃用
tensorflow > 2.1。相反,您应该使用以下功能:
import tensorflow as tftf.config.list_physical_devices('GPU')注意:
在您的情况下,cpu和gpu均可用,如果使用tensorflow的cpu版本,则不会列出gpu。在您的情况下,无需设置tensorflow设备(
withtf.device("..")),tensorflow将自动选择您的GPU!此外,您
sudo pip3 list清楚地表明您正在使用tensorflow-gpu。如果您拥有tensoflow
cpu版本,则名称将类似于
tensorflow(1.1.0)。
检查此问题以获取有关警告的信息。



