Home | History | Annotate | Download | only in gpu
      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 gpu = ::perftools::gputools;
     30 
     31 namespace tensorflow {
     32 
     33 Status ValidateGPUMachineManager() {
     34   auto result = gpu::MultiPlatformManager::PlatformWithName("CUDA");
     35   if (!result.ok()) {
     36     return StreamExecutorUtil::ConvertStatus(result.status());
     37   }
     38 
     39   return Status::OK();
     40 }
     41 
     42 gpu::Platform* GPUMachineManager() {
     43   auto result = gpu::MultiPlatformManager::PlatformWithName("CUDA");
     44   if (!result.ok()) {
     45     LOG(FATAL) << "Could not find Platform with name CUDA";
     46     return nullptr;
     47   }
     48 
     49   return result.ValueOrDie();
     50 }
     51 
     52 }  // namespace tensorflow
     53