Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
f291abfc
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
f291abfc
编写于
12月 07, 2017
作者:
Y
Yu Yang
提交者:
GitHub
12月 07, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add HasCUDNN to detect if CUDNN is installed or not (#6349)
* Add HasCUDNN to detect if CUDNN is installed or not * Fix CI
上级
a34fc8b3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
43 addition
and
19 deletion
+43
-19
paddle/platform/dynload/cudnn.cc
paddle/platform/dynload/cudnn.cc
+17
-1
paddle/platform/dynload/cudnn.h
paddle/platform/dynload/cudnn.h
+3
-0
paddle/platform/dynload/dynamic_loader.cc
paddle/platform/dynload/dynamic_loader.cc
+23
-18
未找到文件。
paddle/platform/dynload/cudnn.cc
浏览文件 @
f291abfc
...
...
@@ -12,7 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include <paddle/platform/dynload/cudnn.h>
#include "paddle/platform/dynload/cudnn.h"
#include "paddle/platform/enforce.h"
namespace
paddle
{
namespace
platform
{
...
...
@@ -41,6 +42,21 @@ CUDNN_DNN_ROUTINE_EACH_R5(DEFINE_WRAP);
CUDNN_DNN_ROUTINE_EACH_R7
(
DEFINE_WRAP
);
#endif
#ifdef PADDLE_USE_DSO
bool
HasCUDNN
()
{
std
::
call_once
(
cudnn_dso_flag
,
GetCudnnDsoHandle
,
&
cudnn_dso_handle
);
return
cudnn_dso_handle
!=
nullptr
;
}
void
EnforceCUDNNLoaded
(
const
char
*
fn_name
)
{
PADDLE_ENFORCE
(
cudnn_dso_handle
!=
nullptr
,
"Cannot load cudnn shared library. Cannot invoke method %s"
,
fn_name
);
}
#else
bool
HasCUDNN
()
{
return
true
;
}
#endif
}
// namespace dynload
}
// namespace platform
}
// namespace paddle
paddle/platform/dynload/cudnn.h
浏览文件 @
f291abfc
...
...
@@ -25,9 +25,11 @@ namespace dynload {
extern
std
::
once_flag
cudnn_dso_flag
;
extern
void
*
cudnn_dso_handle
;
extern
bool
HasCUDNN
();
#ifdef PADDLE_USE_DSO
extern
void
EnforceCUDNNLoaded
(
const
char
*
fn_name
);
#define DECLARE_DYNAMIC_LOAD_CUDNN_WRAP(__name) \
struct DynLoad__##__name { \
template <typename... Args> \
...
...
@@ -36,6 +38,7 @@ extern void* cudnn_dso_handle;
std::call_once(cudnn_dso_flag, \
paddle::platform::dynload::GetCudnnDsoHandle, \
&cudnn_dso_handle); \
EnforceCUDNNLoaded(#__name); \
void* p_##__name = dlsym(cudnn_dso_handle, #__name); \
return reinterpret_cast<cudnn_func>(p_##__name)(args...); \
} \
...
...
paddle/platform/dynload/dynamic_loader.cc
浏览文件 @
f291abfc
...
...
@@ -78,12 +78,11 @@ static inline void GetDsoHandleFromDefaultPath(std::string& dso_path,
*
dso_handle
=
dlopen
(
dso_path
.
c_str
(),
dynload_flags
);
if
(
nullptr
==
*
dso_handle
)
{
if
(
dso_path
==
"libcudnn.dylib"
)
{
PADDLE_ENFORCE
(
true
,
"Note: [Recommend] copy cudnn into /usr/local/cuda/
\n
"
"For instance, sudo tar -xzf "
"cudnn-7.5-osx-x64-v5.0-ga.tgz -C /usr/local
\n
sudo "
"chmod a+r /usr/local/cuda/include/cudnn.h "
"/usr/local/cuda/lib/libcudnn*"
);
LOG
(
WARNING
)
<<
"Note: [Recommend] copy cudnn into /usr/local/cuda/
\n
"
"For instance, sudo tar -xzf "
"cudnn-7.5-osx-x64-v5.0-ga.tgz -C /usr/local
\n
sudo "
"chmod a+r /usr/local/cuda/include/cudnn.h "
"/usr/local/cuda/lib/libcudnn*"
;
}
}
}
...
...
@@ -92,7 +91,8 @@ static inline void GetDsoHandleFromDefaultPath(std::string& dso_path,
static
inline
void
GetDsoHandleFromSearchPath
(
const
std
::
string
&
search_root
,
const
std
::
string
&
dso_name
,
void
**
dso_handle
)
{
void
**
dso_handle
,
bool
throw_on_error
=
true
)
{
int
dynload_flags
=
RTLD_LAZY
|
RTLD_LOCAL
;
*
dso_handle
=
nullptr
;
...
...
@@ -111,15 +111,19 @@ static inline void GetDsoHandleFromSearchPath(const std::string& search_root,
GetDsoHandleFromDefaultPath
(
dlPath
,
dso_handle
,
dynload_flags
);
}
}
PADDLE_ENFORCE
(
nullptr
!=
*
dso_handle
,
"Failed to find dynamic library: %s ( %s )
\n
Please specify "
"its path correctly using following ways:
\n
Method. set "
"environment variable LD_LIBRARY_PATH on Linux or "
"DYLD_LIBRARY_PATH on Mac OS.
\n
For instance, issue command: "
"export LD_LIBRARY_PATH=...
\n
Note: After Mac OS 10.11, "
"using the DYLD_LIBRARY_PATH is impossible unless System "
"Integrity Protection (SIP) is disabled."
,
dlPath
,
dlerror
());
auto
error_msg
=
"Failed to find dynamic library: %s ( %s )
\n
Please specify "
"its path correctly using following ways:
\n
Method. set "
"environment variable LD_LIBRARY_PATH on Linux or "
"DYLD_LIBRARY_PATH on Mac OS.
\n
For instance, issue command: "
"export LD_LIBRARY_PATH=...
\n
Note: After Mac OS 10.11, "
"using the DYLD_LIBRARY_PATH is impossible unless System "
"Integrity Protection (SIP) is disabled."
;
if
(
throw_on_error
)
{
PADDLE_ENFORCE
(
nullptr
!=
*
dso_handle
,
error_msg
,
dlPath
,
dlerror
());
}
else
if
(
nullptr
==
*
dso_handle
)
{
LOG
(
WARNING
)
<<
string
::
Sprintf
(
error_msg
,
dlPath
,
dlerror
());
}
}
void
GetCublasDsoHandle
(
void
**
dso_handle
)
{
...
...
@@ -132,9 +136,10 @@ void GetCublasDsoHandle(void** dso_handle) {
void
GetCudnnDsoHandle
(
void
**
dso_handle
)
{
#if defined(__APPLE__) || defined(__OSX__)
GetDsoHandleFromSearchPath
(
FLAGS_cudnn_dir
,
"libcudnn.dylib"
,
dso_handle
);
GetDsoHandleFromSearchPath
(
FLAGS_cudnn_dir
,
"libcudnn.dylib"
,
dso_handle
,
false
);
#else
GetDsoHandleFromSearchPath
(
FLAGS_cudnn_dir
,
"libcudnn.so"
,
dso_handle
);
GetDsoHandleFromSearchPath
(
FLAGS_cudnn_dir
,
"libcudnn.so"
,
dso_handle
,
false
);
#endif
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录