跳转至

12.5.可用性测试

Linux 5.4.0-74-generic
Python 3.9.5 @ GCC 7.3.0
Latest build date 2021.06.20
tensorflow version:  2.5.0

GPU 可用性

tf.test.is_gpu_available()
False
tf.config.list_physical_devices('GPU')
[]

列出机器的设备

from tensorflow.python.client import device_lib

device_lib.list_local_devices()
[name: "/device:CPU:0"
 device_type: "CPU"
 memory_limit: 268435456
 locality {
 }
 incarnation: 4888993433448823416]

tf.version 模块

# GCC 或其他编译器的版本
print(tf.version.COMPILER_VERSION)
print(tf.version.GIT_VERSION)
# tensorflow的版本
print(tf.version.VERSION)
# tensorflow GraphDef 的版本
print(tf.version.GRAPH_DEF_VERSION)
print(tf.version.GRAPH_DEF_VERSION_MIN_CONSUMER)
print(tf.version.GRAPH_DEF_VERSION_MIN_PRODUCER)
8.2.1 20180905
unknown
2.5.0
716
0
0

tf.sysconfig 模块

# 获取tensorflow构建环境的信息
print(tf.sysconfig.get_build_info())
# Get the compilation flags for custom operators.
print(tf.sysconfig.get_compile_flags())
# 获取包含 TensorFlow C++ header 文件的目录
print(tf.sysconfig.get_include())
# tensorflow library 的位置
print(tf.sysconfig.get_lib())
# Get the link flags for custom operators.
print(tf.sysconfig.get_link_flags())
OrderedDict([('is_cuda_build', False), ('is_rocm_build', False), ('is_tensorrt_build', False)])
['-I/home/.../lib/python3.9/site-packages/tensorflow/include', '-D_GLIBCXX_USE_CXX11_ABI=0']
/home/.../lib/python3.9/site-packages/tensorflow/include
/home/.../lib/python3.9/site-packages/tensorflow
['-L/home/.../lib/python3.9/site-packages/tensorflow', '-l:libtensorflow_framework.so.2']