Skip to content

Tensorflow Tips #248

@junxnone

Description

@junxnone

获取当前版本 tensorflow 编译信息

import tensorflow as tf
build_info = tf.sysconfig.get_build_info()
for key in build_info:
    print(f'{key}: {build_info[key]}')
cpu_compiler: /usr/bin/gcc-5
cuda_compute_capabilities: ['sm_35', 'sm_50', 'sm_60', 'sm_70', 'sm_75', 'compute_80']
cuda_version: 11.2
cudnn_version: 8
is_cuda_build: True
is_rocm_build: False
is_tensorrt_build: True

获取主机可用的 GPU

for gpu_n in tf.config.experimental.list_physical_devices('GPU'):
    print(f'Num GPUs Available: {gpu_n}')
Num GPUs Available: PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')
Num GPUs Available: PhysicalDevice(name='/physical_device:GPU:1', device_type='GPU')
Num GPUs Available: PhysicalDevice(name='/physical_device:GPU:2', device_type='GPU')
Num GPUs Available: PhysicalDevice(name='/physical_device:GPU:3', device_type='GPU')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions