• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 #include "tensorflow/core/common_runtime/gpu/gpu_init.h"
17 
18 #include <string>
19 
20 #include "tensorflow/core/lib/core/errors.h"
21 #include "tensorflow/core/lib/strings/numbers.h"
22 #include "tensorflow/core/lib/strings/str_util.h"
23 #include "tensorflow/core/lib/strings/strcat.h"
24 #include "tensorflow/core/platform/logging.h"
25 #include "tensorflow/core/platform/stream_executor.h"
26 #include "tensorflow/core/platform/types.h"
27 #include "tensorflow/core/util/stream_executor_util.h"
28 
29 namespace tensorflow {
30 
ValidateGPUMachineManager()31 Status ValidateGPUMachineManager() {
32   return se::MultiPlatformManager::PlatformWithName(GpuPlatformName()).status();
33 }
34 
GPUMachineManager()35 se::Platform* GPUMachineManager() {
36   auto result = se::MultiPlatformManager::PlatformWithName(GpuPlatformName());
37   if (!result.ok()) {
38     LOG(FATAL) << "Could not find Platform with name " << GpuPlatformName();
39     return nullptr;
40   }
41 
42   return result.ValueOrDie();
43 }
44 
GpuPlatformName()45 string GpuPlatformName() {
46 #if TENSORFLOW_USE_ROCM
47   return "ROCM";
48 #else
49   // This function will return "CUDA" even when building TF without GPU support
50   // This is done to preserve existing functionality
51   return "CUDA";
52 #endif
53 }
54 
55 }  // namespace tensorflow
56