@@ -78,12 +78,11 @@ static inline void GetDsoHandleFromDefaultPath(std::string& dso_path,
78
78
*dso_handle = dlopen (dso_path.c_str (), dynload_flags);
79
79
if (nullptr == *dso_handle) {
80
80
if (dso_path == " libcudnn.dylib" ) {
81
- PADDLE_ENFORCE (true ,
82
- " Note: [Recommend] copy cudnn into /usr/local/cuda/ \n "
83
- " For instance, sudo tar -xzf "
84
- " cudnn-7.5-osx-x64-v5.0-ga.tgz -C /usr/local \n sudo "
85
- " chmod a+r /usr/local/cuda/include/cudnn.h "
86
- " /usr/local/cuda/lib/libcudnn*" );
81
+ LOG (WARNING) << " Note: [Recommend] copy cudnn into /usr/local/cuda/ \n "
82
+ " For instance, sudo tar -xzf "
83
+ " cudnn-7.5-osx-x64-v5.0-ga.tgz -C /usr/local \n sudo "
84
+ " chmod a+r /usr/local/cuda/include/cudnn.h "
85
+ " /usr/local/cuda/lib/libcudnn*" ;
87
86
}
88
87
}
89
88
}
@@ -92,7 +91,8 @@ static inline void GetDsoHandleFromDefaultPath(std::string& dso_path,
92
91
93
92
static inline void GetDsoHandleFromSearchPath (const std::string& search_root,
94
93
const std::string& dso_name,
95
- void ** dso_handle) {
94
+ void ** dso_handle,
95
+ bool throw_on_error = true ) {
96
96
int dynload_flags = RTLD_LAZY | RTLD_LOCAL;
97
97
*dso_handle = nullptr ;
98
98
@@ -111,15 +111,19 @@ static inline void GetDsoHandleFromSearchPath(const std::string& search_root,
111
111
GetDsoHandleFromDefaultPath (dlPath, dso_handle, dynload_flags);
112
112
}
113
113
}
114
- PADDLE_ENFORCE (nullptr != *dso_handle,
115
- " Failed to find dynamic library: %s ( %s ) \n Please specify "
116
- " its path correctly using following ways: \n Method. set "
117
- " environment variable LD_LIBRARY_PATH on Linux or "
118
- " DYLD_LIBRARY_PATH on Mac OS. \n For instance, issue command: "
119
- " export LD_LIBRARY_PATH=... \n Note: After Mac OS 10.11, "
120
- " using the DYLD_LIBRARY_PATH is impossible unless System "
121
- " Integrity Protection (SIP) is disabled." ,
122
- dlPath, dlerror ());
114
+ auto error_msg =
115
+ " Failed to find dynamic library: %s ( %s ) \n Please specify "
116
+ " its path correctly using following ways: \n Method. set "
117
+ " environment variable LD_LIBRARY_PATH on Linux or "
118
+ " DYLD_LIBRARY_PATH on Mac OS. \n For instance, issue command: "
119
+ " export LD_LIBRARY_PATH=... \n Note: After Mac OS 10.11, "
120
+ " using the DYLD_LIBRARY_PATH is impossible unless System "
121
+ " Integrity Protection (SIP) is disabled." ;
122
+ if (throw_on_error) {
123
+ PADDLE_ENFORCE (nullptr != *dso_handle, error_msg, dlPath, dlerror ());
124
+ } else if (nullptr == *dso_handle) {
125
+ LOG (WARNING) << string::Sprintf (error_msg, dlPath, dlerror ());
126
+ }
123
127
}
124
128
125
129
void GetCublasDsoHandle (void ** dso_handle) {
@@ -132,9 +136,10 @@ void GetCublasDsoHandle(void** dso_handle) {
132
136
133
137
void GetCudnnDsoHandle (void ** dso_handle) {
134
138
#if defined(__APPLE__) || defined(__OSX__)
135
- GetDsoHandleFromSearchPath (FLAGS_cudnn_dir, " libcudnn.dylib" , dso_handle);
139
+ GetDsoHandleFromSearchPath (FLAGS_cudnn_dir, " libcudnn.dylib" , dso_handle,
140
+ false );
136
141
#else
137
- GetDsoHandleFromSearchPath (FLAGS_cudnn_dir, " libcudnn.so" , dso_handle);
142
+ GetDsoHandleFromSearchPath (FLAGS_cudnn_dir, " libcudnn.so" , dso_handle, false );
138
143
#endif
139
144
}
140
145
0 commit comments