From ce413674e189a68c0074b0730c73de49ce24a62a Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Wed, 16 May 2018 09:26:51 -0700 Subject: [PATCH] Don't initialize GPUs if none will be used. PiperOrigin-RevId: 196838739 --- tensorflow/core/common_runtime/gpu/gpu_device.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tensorflow/core/common_runtime/gpu/gpu_device.cc b/tensorflow/core/common_runtime/gpu/gpu_device.cc index c84fe48..b3deab6 100644 --- a/tensorflow/core/common_runtime/gpu/gpu_device.cc +++ b/tensorflow/core/common_runtime/gpu/gpu_device.cc @@ -879,7 +879,8 @@ Status BaseGPUDeviceFactory::CreateDevices(const SessionOptions& options, if (num_gpus_to_use > valid_cuda_gpu_ids.size()) { num_gpus_to_use = valid_cuda_gpu_ids.size(); } - if (!valid_cuda_gpu_ids.empty()) { + // If we aren't going to use any GPUs, don't initialize them. + if (num_gpus_to_use > 0 && !valid_cuda_gpu_ids.empty()) { // Save the original device. int original_device = 0; cudaError_t err = cudaGetDevice(&original_device); -- 2.7.4