diff options
author | 2018-05-16 09:26:51 -0700 | |
---|---|---|
committer | 2018-05-16 09:29:30 -0700 | |
commit | ce413674e189a68c0074b0730c73de49ce24a62a (patch) | |
tree | 8258fdecedf2ee614b525465b44f9168041c537b | |
parent | f8d92d7688d494d0f0a867c2040ae1a0948bc0c3 (diff) |
Don't initialize GPUs if none will be used.
PiperOrigin-RevId: 196838739
-rw-r--r-- | tensorflow/core/common_runtime/gpu/gpu_device.cc | 3 |
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); |