tensorflow - 虽然pc识别gpu,但它使用的是tensorflow-gpu中的CPU

标签 tensorflow machine-learning keras gpu

我正在使用tensorflow-gpu。我想使用GTX1070,但tensorflow-gpu使用我的CPU。我不知道该怎么办。

我使用 CUDA 9.0 和 CUDNN 7.1.4。我的tensorflow-gpu版本是1.9。

在官网运行此命令后

>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()

2018-07-30 10:53:43.369025: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 2018-07-30 10:53:43.829922: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1392] Found device 0 with properties: name: GeForce GTX 1070 major: 6 minor: 1 memoryClockRate(GHz): 1.683 pciBusID: 0000:01:00.0 totalMemory: 8.00GiB freeMemory: 6.63GiB 2018-07-30 10:53:43.919043: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1392] Found device 1 with properties: name: GeForce GTX 1050 major: 6 minor: 1 memoryClockRate(GHz): 1.455 pciBusID: 0000:05:00.0 totalMemory: 2.00GiB freeMemory: 1.60GiB 2018-07-30 10:53:43.926001: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1456] Ignoring visible gpu device (device: 1, name: GeForce GTX 1050, pci bus id: 0000:05:00.0, compute capability: 6.1) with Cuda multiprocessor count: 5. The minimum required count is 8. You can adjust this requirement with the env var TF_MIN_GPU_MULTIPROCESSOR_COUNT. 2018-07-30 10:53:43.934810: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1471] Adding visible gpu devices: 0 2018-07-30 10:53:44.761551: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:952] Device interconnect StreamExecutor with strength 1 edge matrix: 2018-07-30 10:53:44.765678: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:958] 0 1 2018-07-30 10:53:44.768363: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:971] 0: N N 2018-07-30 10:53:44.771773: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:971] 1: N N 2018-07-30 10:53:44.774913: I T:\src\github\tensorflow\tensorflow\coenter code herere\common_runtime\gpu\gpu_device.cc:1084] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 6395 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1070, pci bus id: 0000enter code here:01:00.0, compute capability: 6.1)

最佳答案

正如我从 tensorflow 引擎的日志摘录中看到的 - 它使用 GPU 设备 0

(/job:localhost/replica:0/task:0/device:GPU:0 with 6395 MB memory) -> physical 
GPU (device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0, compute 
capability: 6.1)

但拒绝使用您的 GeForce GTX 1050。这是可能的,因为环境变量 TF_MIN_GPU_MULTIPROCESSOR_COUNT 似乎设置为 8。

尝试按照之前日志中的建议将其设置为值 5:

设置 TF_MIN_GPU_MULTIPROCESSOR_COUNT=5

如果您想确定使用的是哪个设备 - 使用

初始化 session
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))

您可以在 Using GPUs tensorflow 上阅读更多内容文档页面

关于tensorflow - 虽然pc识别gpu,但它使用的是tensorflow-gpu中的CPU,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51586121/

相关文章:

tensorflow - 如何使用tensorflow实现反卷积?

python - 内存减少 Tensorflow TPU v2/v3 bfloat16

java - 具有真正有值(value)特征的斯坦福分类器

python - Keras:使用带有填充序列的 mask_zero 与单序列非填充训练

python - 哪种形状应该具有 LSTM NN 的输入和输出数据?

python-3.x - TensorFlow:dataset.train.next_batch 是如何定义的?

python-2.7 - spyder无法加载 tensorflow

python - 用python机器学习识别声音(单词)

java - 我怎么知道我的神经网络正在被正确训练

python - Keras Embedding 层中的 mask_zero 是如何工作的?