Python:如何获取 GPU 数量

标签 python tensorflow keras gpu

我使用 Keras 和 Tensorflow 来复制 DQN。实际上我使用的是 2 个 GPU,但我想让我的代码在每台机器上都可执行,无论它有多少个 GPU。所以我的问题是:如何获取我的 PC 中存在的 GPU 数量?我检查了this但它给了我很多我不需要的信息。还有其他方法可以获取 GPU 数量吗?

最佳答案

如果您想知道有多少个 GPU 正在运行,tf.contrib.eager.num_gpus() 将为您提供答案。

关于Python:如何获取 GPU 数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55643308/

相关文章:

python - 了解 scrapy 重命名图像的工作原理

python - Keras 双向 LSTM : initial_state` was passed that is not compatible with `cell. state_size

python - 如何计算tensorflow中RNN的困惑度

tensorflow - tf.segment_max 错误 : segment ids are not increasing by 1

python - Adam在keras中是如何实现学习率衰减的

python - Dockerize Flask : Error: While importing 'app' , 引发了 ImportError

python - matplotlib 中的十六进制 X 轴?

python - 使用不同的优化器运行 Keras Sequential 模型

python - 自定义 TensorFlow 指标 : true positive rate at given false positive rate

python - 如何获取 current_app 以便在多部署可重用 Django 应用程序中反向使用?