aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--tensorflow/core/common_runtime/gpu/gpu_device.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/tensorflow/core/common_runtime/gpu/gpu_device.cc b/tensorflow/core/common_runtime/gpu/gpu_device.cc
index c84fe48084..b3deab6f60 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);