1 /* Copyright 2019 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/compiler/tf2tensorrt/utils/py_utils.h" 17 18 #if GOOGLE_CUDA && GOOGLE_TENSORRT 19 #include "tensorflow/compiler/tf2tensorrt/common/utils.h" 20 #include "tensorflow/stream_executor/platform/dso_loader.h" 21 #include "third_party/tensorrt/NvInfer.h" 22 #endif 23 24 namespace tensorflow { 25 namespace tensorrt { 26 IsGoogleTensorRTEnabled()27bool IsGoogleTensorRTEnabled() { 28 #if GOOGLE_CUDA && GOOGLE_TENSORRT 29 #if TF_USE_TENSORRT_STATIC 30 LOG(INFO) << "TensorRT libraries are statically linked, skip dlopen check"; 31 return true; 32 #else // TF_USE_TENSORRT_STATIC 33 auto handle_or = se::internal::DsoLoader::TryDlopenTensorRTLibraries(); 34 if (!handle_or.ok()) { 35 LOG_WARNING_WITH_PREFIX 36 << "Cannot dlopen some TensorRT libraries. If you would like " 37 "to use Nvidia GPU with TensorRT, please make sure the " 38 "missing libraries mentioned above are installed properly."; 39 } 40 return handle_or.ok(); 41 #endif // TF_USE_TENSORRT_STATIC 42 #else // GOOGLE_CUDA && GOOGLE_TENSORRT 43 return false; 44 #endif // GOOGLE_CUDA && GOOGLE_TENSORRT 45 } 46 47 } // namespace tensorrt 48 } // namespace tensorflow 49