diff options
author | Jingyue Wu <jingyue@google.com> | 2016-12-13 16:02:30 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2016-12-13 16:22:12 -0800 |
commit | 667a023a417f36ff4eabaee77daf374dceaa5ddd (patch) | |
tree | aecdc6132d8a946f29002d29212a897d0af1e5c6 /tensorflow/stream_executor/dso_loader.cc | |
parent | f0a6d1ee02adbf5222cd537d45e510ae3f40844f (diff) |
Find libdevice files in .runfiles when TEST_SRCDIR is not set.
Before this CL, XLA GPU binaries can only be run with "blaze test". After this
CL, they can be run directly via "blaze-bin/<executable>".
Change: 141952101
Diffstat (limited to 'tensorflow/stream_executor/dso_loader.cc')
-rw-r--r-- | tensorflow/stream_executor/dso_loader.cc | 35 |
1 files changed, 3 insertions, 32 deletions
diff --git a/tensorflow/stream_executor/dso_loader.cc b/tensorflow/stream_executor/dso_loader.cc index 2c5ad3d9aa..a539c9a4ae 100644 --- a/tensorflow/stream_executor/dso_loader.cc +++ b/tensorflow/stream_executor/dso_loader.cc @@ -19,22 +19,14 @@ limitations under the License. #include "tensorflow/stream_executor/dso_loader.h" #include <limits.h> -#if defined(__APPLE__) -#include <mach-o/dyld.h> -#endif #include <stdlib.h> -#if defined(PLATFORM_WINDOWS) -#include <windows.h> -#define PATH_MAX MAX_PATH -#else -#include <unistd.h> -#endif #include <initializer_list> #include <vector> #include "tensorflow/core/platform/load_library.h" #include "tensorflow/stream_executor/lib/env.h" #include "tensorflow/stream_executor/lib/error.h" +#include "tensorflow/stream_executor/lib/path.h" #include "tensorflow/stream_executor/lib/str_util.h" #include "tensorflow/stream_executor/lib/strcat.h" #include "tensorflow/stream_executor/lib/stringprintf.h" @@ -130,29 +122,8 @@ string GetCudnnVersion() { return TF_CUDNN_VERSION; } } /* static */ string DsoLoader::GetBinaryDirectory(bool strip_executable_name) { - char exe_path[PATH_MAX] = {0}; -#ifdef __APPLE__ - uint32_t buffer_size(0U); - _NSGetExecutablePath(nullptr, &buffer_size); - char unresolved_path[buffer_size]; - _NSGetExecutablePath(unresolved_path, &buffer_size); - CHECK_ERR(realpath(unresolved_path, exe_path) ? 1 : -1); -#elif defined(PLATFORM_WINDOWS) - HMODULE hModule = GetModuleHandle(NULL); - GetModuleFileName(hModule, exe_path, MAX_PATH); -#else - CHECK_ERR(readlink("/proc/self/exe", exe_path, sizeof(exe_path) - 1)); -#endif - // Make sure it's null-terminated: - exe_path[sizeof(exe_path) - 1] = 0; - - if (strip_executable_name) { - // The exe is the last component of the path, so remove one component. - std::vector<string> components = port::Split(exe_path, '/'); - components.pop_back(); - return port::Join(components, "/"); - } - return exe_path; + string exe_path = port::Env::Default()->GetExecutablePath(); + return strip_executable_name ? port::Dirname(exe_path).ToString() : exe_path; } // Creates a heap-allocated vector for initial rpaths. |