tensorflow获取可用GPU设备
来源:互联网 发布:怎么注册网络域名 编辑:程序博客网 时间:2024/06/04 18:59
主要内容:
- 使用tensorflow查询机器上是否存在可用的gpu设备
- 使用tensorflow获取可用的gpu设备编号
- tensorflow对GPU设备的编码
使用tensorflow查询机器上是否存在可用的gpu设备
def is_gpu_available(cuda_only=True): """ code from https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/platform/test.py Returns whether TensorFlow can access a GPU. Args: cuda_only: limit the search to CUDA gpus. Returns: True iff a gpu device of the requested kind is available. """ from tensorflow.python.client import device_lib as _device_lib if cuda_only: return any((x.device_type == 'GPU') for x in _device_lib.list_local_devices()) else: return any((x.device_type == 'GPU' or x.device_type == 'SYCL') for x in _device_lib.list_local_devices())
使用tensorflow获取可用的gpu设备编号
def get_available_gpus(): """ code from http://stackoverflow.com/questions/38559755/how-to-get-current-available-gpus-in-tensorflow """ from tensorflow.python.client import device_lib as _device_lib local_device_protos = _device_lib.list_local_devices() return [x.name for x in local_device_protos if x.device_type == 'GPU']
完整代码见 tf.py
, 测试代码见test_util_tf.py
.
tensorflow对GPU设备的编码
执行:
CUDA_VISIBLE_DEVICES=1,2 python test_util_tf.py
输出为:
/gpu:0/gpu:1
可以看出, 无论CUDA可见的设备是哪几个, tensorflow都会对它们从0开始重新编码。
1 1
- tensorflow获取可用GPU设备
- tensorflow获取可用GPU设备
- tensorflow获取GPU设备
- 使用tensorflow查询机器上是否存在可用的gpu设备
- Windows 10 64 tensorflow gpu 安装 一种可用的情况
- 获取当前设备可用内存
- tensorflow-gpu
- 获取当前设备可用内存(单位:MB)
- 2.Android进阶:获取设备可用空间
- 获取android 设备的cpu gpu信息 mac地址
- tensorflow gpu使用说明
- 安装windows tensorflow-gpu
- Install GPU Tensorflow
- Tensorflow gpu 安装
- windows gpu tensorflow anaconda
- TensorFlow(GPU) 安装
- win10+ubutun+tensorflow+gpu
- TensorFlow GPU版安装
- oracle spool 用法
- nodejs 使用uuid
- oracle 导入csv文件
- mybatis大于小于的转义
- Unity GameObject.activeSelf, GameObject.activeInHierarchy,GameObject.SetActive和SetActiveRecursively
- tensorflow获取可用GPU设备
- Java 命名约定
- springmvc 入门
- 常用排序算法的分析与实现
- TOMCAT环境安装,以及eclipse中配置tomcat
- RTMP规范简单分析
- TypeScript
- css动画优化笔记
- angula2 引入第三方js