Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
5a86891f
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5a86891f
编写于
8月 16, 2019
作者:
S
silingtong123
提交者:
liuwei1031
8月 16, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cherry pick #18761 (#19199)
* fix warpctc dynamic library not found issue on mac and windows platform
上级
de5dec84
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
56 addition
and
34 deletion
+56
-34
paddle/fluid/platform/dynload/CMakeLists.txt
paddle/fluid/platform/dynload/CMakeLists.txt
+0
-1
paddle/fluid/platform/dynload/dynamic_loader.cc
paddle/fluid/platform/dynload/dynamic_loader.cc
+16
-7
paddle/fluid/platform/dynload/dynamic_loader.h
paddle/fluid/platform/dynload/dynamic_loader.h
+2
-0
paddle/fluid/platform/dynload/warpctc_lib_path.h.in
paddle/fluid/platform/dynload/warpctc_lib_path.h.in
+0
-17
paddle/fluid/pybind/pybind.cc
paddle/fluid/pybind/pybind.cc
+3
-0
paddle/scripts/paddle_build.sh
paddle/scripts/paddle_build.sh
+3
-2
python/paddle/fluid/core.py
python/paddle/fluid/core.py
+24
-2
python/setup.py.in
python/setup.py.in
+8
-5
未找到文件。
paddle/fluid/platform/dynload/CMakeLists.txt
浏览文件 @
5a86891f
...
@@ -16,7 +16,6 @@ if (CUPTI_FOUND)
...
@@ -16,7 +16,6 @@ if (CUPTI_FOUND)
list
(
APPEND CUDA_SRCS cupti.cc
)
list
(
APPEND CUDA_SRCS cupti.cc
)
endif
(
CUPTI_FOUND
)
endif
(
CUPTI_FOUND
)
nv_library
(
dynload_cuda SRCS
${
CUDA_SRCS
}
DEPS dynamic_loader
)
nv_library
(
dynload_cuda SRCS
${
CUDA_SRCS
}
DEPS dynamic_loader
)
configure_file
(
warpctc_lib_path.h.in
${
CMAKE_CURRENT_BINARY_DIR
}
/warpctc_lib_path.h
)
cc_library
(
dynload_warpctc SRCS warpctc.cc DEPS dynamic_loader warpctc
)
cc_library
(
dynload_warpctc SRCS warpctc.cc DEPS dynamic_loader warpctc
)
if
(
WITH_MKLML
)
if
(
WITH_MKLML
)
cc_library
(
dynload_mklml SRCS mklml.cc DEPS dynamic_loader mklml
)
cc_library
(
dynload_mklml SRCS mklml.cc DEPS dynamic_loader mklml
)
...
...
paddle/fluid/platform/dynload/dynamic_loader.cc
浏览文件 @
5a86891f
...
@@ -20,7 +20,6 @@ limitations under the License. */
...
@@ -20,7 +20,6 @@ limitations under the License. */
#include "gflags/gflags.h"
#include "gflags/gflags.h"
#include "glog/logging.h"
#include "glog/logging.h"
#include "paddle/fluid/platform/dynload/cupti_lib_path.h"
#include "paddle/fluid/platform/dynload/cupti_lib_path.h"
#include "paddle/fluid/platform/dynload/warpctc_lib_path.h"
#include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/port.h"
#include "paddle/fluid/platform/port.h"
...
@@ -34,8 +33,6 @@ DEFINE_string(cuda_dir, "",
...
@@ -34,8 +33,6 @@ DEFINE_string(cuda_dir, "",
"libcurand. For instance, /usr/local/cuda/lib64. If default, "
"libcurand. For instance, /usr/local/cuda/lib64. If default, "
"dlopen will search cuda from LD_LIBRARY_PATH"
);
"dlopen will search cuda from LD_LIBRARY_PATH"
);
DEFINE_string
(
warpctc_dir
,
""
,
"Specify path for loading libwarpctc.so."
);
DEFINE_string
(
nccl_dir
,
""
,
DEFINE_string
(
nccl_dir
,
""
,
"Specify path for loading nccl library, such as libcublas, "
"Specify path for loading nccl library, such as libcublas, "
"libcurand. For instance, /usr/local/cuda/lib64. If default, "
"libcurand. For instance, /usr/local/cuda/lib64. If default, "
...
@@ -52,8 +49,15 @@ DEFINE_string(mklml_dir, "", "Specify path for loading libmklml_intel.so.");
...
@@ -52,8 +49,15 @@ DEFINE_string(mklml_dir, "", "Specify path for loading libmklml_intel.so.");
namespace
paddle
{
namespace
paddle
{
namespace
platform
{
namespace
platform
{
namespace
dynload
{
namespace
dynload
{
struct
PathNode
{
PathNode
()
{}
std
::
string
path
=
""
;
};
static
constexpr
char
cupti_lib_path
[]
=
CUPTI_LIB_PATH
;
static
constexpr
char
cupti_lib_path
[]
=
CUPTI_LIB_PATH
;
static
constexpr
char
warpctc_lib_path
[]
=
WARPCTC_LIB_PATH
;
static
PathNode
s_py_site_pkg_path
;
#if defined(_WIN32) && defined(PADDLE_WITH_CUDA)
#if defined(_WIN32) && defined(PADDLE_WITH_CUDA)
static
constexpr
char
*
win_cublas_lib
=
"cublas64_"
PADDLE_CUDA_BINVER
".dll"
;
static
constexpr
char
*
win_cublas_lib
=
"cublas64_"
PADDLE_CUDA_BINVER
".dll"
;
...
@@ -78,6 +82,11 @@ static inline std::string join(const std::string& part1,
...
@@ -78,6 +82,11 @@ static inline std::string join(const std::string& part1,
return
ret
;
return
ret
;
}
}
void
SetPaddleLibPath
(
const
std
::
string
&
py_site_pkg_path
)
{
s_py_site_pkg_path
.
path
=
py_site_pkg_path
;
VLOG
(
3
)
<<
"Set paddle lib path : "
<<
py_site_pkg_path
;
}
static
inline
void
*
GetDsoHandleFromDefaultPath
(
const
std
::
string
&
dso_path
,
static
inline
void
*
GetDsoHandleFromDefaultPath
(
const
std
::
string
&
dso_path
,
int
dynload_flags
)
{
int
dynload_flags
)
{
VLOG
(
3
)
<<
"Try to find library: "
<<
dso_path
VLOG
(
3
)
<<
"Try to find library: "
<<
dso_path
...
@@ -214,9 +223,9 @@ void* GetCurandDsoHandle() {
...
@@ -214,9 +223,9 @@ void* GetCurandDsoHandle() {
}
}
void
*
GetWarpCTCDsoHandle
()
{
void
*
GetWarpCTCDsoHandle
()
{
std
::
string
warpctc_dir
=
warpctc_lib_path
;
std
::
string
warpctc_dir
=
""
;
if
(
!
FLAGS_warpctc_dir
.
empty
())
{
if
(
!
s_py_site_pkg_path
.
path
.
empty
())
{
warpctc_dir
=
FLAGS_warpctc_dir
;
warpctc_dir
=
s_py_site_pkg_path
.
path
;
}
}
#if defined(__APPLE__) || defined(__OSX__)
#if defined(__APPLE__) || defined(__OSX__)
return
GetDsoHandleFromSearchPath
(
warpctc_dir
,
"libwarpctc.dylib"
);
return
GetDsoHandleFromSearchPath
(
warpctc_dir
,
"libwarpctc.dylib"
);
...
...
paddle/fluid/platform/dynload/dynamic_loader.h
浏览文件 @
5a86891f
...
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
...
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#pragma once
#pragma once
#include <string>
namespace
paddle
{
namespace
paddle
{
namespace
platform
{
namespace
platform
{
...
@@ -33,6 +34,7 @@ void* GetNCCLDsoHandle();
...
@@ -33,6 +34,7 @@ void* GetNCCLDsoHandle();
void
*
GetTensorRtDsoHandle
();
void
*
GetTensorRtDsoHandle
();
void
*
GetMKLMLDsoHandle
();
void
*
GetMKLMLDsoHandle
();
void
SetPaddleLibPath
(
const
std
::
string
&
);
}
// namespace dynload
}
// namespace dynload
}
// namespace platform
}
// namespace platform
}
// namespace paddle
}
// namespace paddle
paddle/fluid/platform/dynload/warpctc_lib_path.h.in
已删除
100644 → 0
浏览文件 @
de5dec84
/* Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
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. */
#pragma once
#define WARPCTC_LIB_PATH "@WARPCTC_INSTALL_DIR@/lib/"
paddle/fluid/pybind/pybind.cc
浏览文件 @
5a86891f
...
@@ -47,6 +47,7 @@ limitations under the License. */
...
@@ -47,6 +47,7 @@ limitations under the License. */
#include "paddle/fluid/operators/reader/lod_tensor_blocking_queue.h"
#include "paddle/fluid/operators/reader/lod_tensor_blocking_queue.h"
#include "paddle/fluid/platform/cpu_helper.h"
#include "paddle/fluid/platform/cpu_helper.h"
#include "paddle/fluid/platform/cpu_info.h"
#include "paddle/fluid/platform/cpu_info.h"
#include "paddle/fluid/platform/dynload/dynamic_loader.h"
#include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/init.h"
#include "paddle/fluid/platform/init.h"
#include "paddle/fluid/platform/place.h"
#include "paddle/fluid/platform/place.h"
...
@@ -197,6 +198,8 @@ PYBIND11_MODULE(core_noavx, m) {
...
@@ -197,6 +198,8 @@ PYBIND11_MODULE(core_noavx, m) {
m
.
def
(
"print_mem_usage"
,
m
.
def
(
"print_mem_usage"
,
[]()
{
return
memory
::
allocation
::
GPUMemMonitor
.
PrintMemUsage
();
});
[]()
{
return
memory
::
allocation
::
GPUMemMonitor
.
PrintMemUsage
();
});
m
.
def
(
"_set_paddle_lib_path"
,
&
paddle
::
platform
::
dynload
::
SetPaddleLibPath
);
BindImperative
(
&
m
);
BindImperative
(
&
m
);
py
::
class_
<
Tensor
>
(
m
,
"Tensor"
,
py
::
buffer_protocol
())
py
::
class_
<
Tensor
>
(
m
,
"Tensor"
,
py
::
buffer_protocol
())
...
...
paddle/scripts/paddle_build.sh
浏览文件 @
5a86891f
...
@@ -418,8 +418,6 @@ EOF
...
@@ -418,8 +418,6 @@ EOF
#remove proxy here to fix dist error on mac
#remove proxy here to fix dist error on mac
export
http_proxy
=
export
http_proxy
=
export
https_proxy
=
export
https_proxy
=
# TODO: jiabin need to refine this part when these tests fixed on mac
ctest
--output-on-failure
-j
$2
# make install should also be test when unittest
# make install should also be test when unittest
make
install
-j
8
make
install
-j
8
...
@@ -447,6 +445,9 @@ EOF
...
@@ -447,6 +445,9 @@ EOF
pip3.7
install
--user
${
INSTALL_PREFIX
:-
/paddle/build
}
/opt/paddle/share/wheels/
*
.whl
pip3.7
install
--user
${
INSTALL_PREFIX
:-
/paddle/build
}
/opt/paddle/share/wheels/
*
.whl
fi
fi
# TODO: jiabin need to refine this part when these tests fixed on mac
ctest
--output-on-failure
-j
$2
paddle version
paddle version
fi
fi
}
}
...
...
python/paddle/fluid/core.py
浏览文件 @
5a86891f
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
from
__future__
import
print_function
from
__future__
import
print_function
import
site
import
sys
import
sys
import
os
import
os
...
@@ -34,8 +35,8 @@ if os.path.exists(current_path + os.sep + 'core_noavx.' + core_suffix):
...
@@ -34,8 +35,8 @@ if os.path.exists(current_path + os.sep + 'core_noavx.' + core_suffix):
try
:
try
:
if
os
.
name
==
'nt'
:
if
os
.
name
==
'nt'
:
third_lib_path
=
current_path
+
os
.
sep
+
'..'
+
os
.
sep
+
'libs'
third_lib_path
=
current_path
+
os
.
sep
+
'..'
+
os
.
sep
+
'libs'
os
.
environ
[
'path'
]
+=
';'
+
third_lib_path
os
.
environ
[
'path'
]
=
third_lib_path
+
';'
+
os
.
environ
[
'path'
]
sys
.
path
.
append
(
third_lib_path
)
sys
.
path
.
insert
(
0
,
third_lib_path
)
except
ImportError
as
e
:
except
ImportError
as
e
:
from
..
import
compat
as
cpt
from
..
import
compat
as
cpt
...
@@ -175,6 +176,7 @@ if avx_supported():
...
@@ -175,6 +176,7 @@ if avx_supported():
from
.core_avx
import
_set_fuse_parameter_memory_size
from
.core_avx
import
_set_fuse_parameter_memory_size
from
.core_avx
import
_is_dygraph_debug_enabled
from
.core_avx
import
_is_dygraph_debug_enabled
from
.core_avx
import
_dygraph_debug_level
from
.core_avx
import
_dygraph_debug_level
from
.core_avx
import
_set_paddle_lib_path
except
Exception
as
e
:
except
Exception
as
e
:
if
has_avx_core
:
if
has_avx_core
:
raise
e
raise
e
...
@@ -203,9 +205,29 @@ if load_noavx:
...
@@ -203,9 +205,29 @@ if load_noavx:
from
.core_noavx
import
_set_fuse_parameter_memory_size
from
.core_noavx
import
_set_fuse_parameter_memory_size
from
.core_noavx
import
_is_dygraph_debug_enabled
from
.core_noavx
import
_is_dygraph_debug_enabled
from
.core_noavx
import
_dygraph_debug_level
from
.core_noavx
import
_dygraph_debug_level
from
.core_noavx
import
_set_paddle_lib_path
except
Exception
as
e
:
except
Exception
as
e
:
if
has_noavx_core
:
if
has_noavx_core
:
sys
.
stderr
.
write
(
sys
.
stderr
.
write
(
'Error: Can not import noavx core while this file exists '
+
'Error: Can not import noavx core while this file exists '
+
current_path
+
os
.
sep
+
'core_noavx.'
+
core_suffix
+
'
\n
'
)
current_path
+
os
.
sep
+
'core_noavx.'
+
core_suffix
+
'
\n
'
)
raise
e
raise
e
# set paddle lib path
def
set_paddle_lib_path
():
site_dirs
=
site
.
getsitepackages
()
if
hasattr
(
site
,
'getsitepackages'
)
else
[
x
for
x
in
sys
.
path
if
'site-packages'
in
x
]
for
site_dir
in
site_dirs
:
lib_dir
=
os
.
path
.
sep
.
join
([
site_dir
,
'paddle'
,
'libs'
])
if
os
.
path
.
exists
(
lib_dir
):
_set_paddle_lib_path
(
lib_dir
)
return
if
hasattr
(
site
,
'USER_SITE'
):
lib_dir
=
os
.
path
.
sep
.
join
([
site
.
USER_SITE
,
'paddle'
,
'libs'
])
if
os
.
path
.
exists
(
lib_dir
):
_set_paddle_lib_path
(
lib_dir
)
set_paddle_lib_path
()
python/setup.py.in
浏览文件 @
5a86891f
...
@@ -3,13 +3,14 @@ import subprocess
...
@@ -3,13 +3,14 @@ import subprocess
import os
import os
import re
import re
import shutil
import shutil
import sys
class BinaryDistribution(Distribution):
class BinaryDistribution(Distribution):
def has_ext_modules(foo):
def has_ext_modules(foo):
return True
return True
RC = 0
RC = 0
ext_name = '.dll' if os.name == 'nt' else
'.so'
ext_name = '.dll' if os.name == 'nt' else
('.dylib' if sys.platform == 'darwin' else '.so')
def git_commit():
def git_commit():
try:
try:
...
@@ -145,9 +146,9 @@ if '${CMAKE_SYSTEM_PROCESSOR}' not in ['arm', 'armv7-a', 'aarch64']:
...
@@ -145,9 +146,9 @@ if '${CMAKE_SYSTEM_PROCESSOR}' not in ['arm', 'armv7-a', 'aarch64']:
paddle_bins = ''
paddle_bins = ''
if not '${WIN32}':
if not '${WIN32}':
paddle_bins = ['${PADDLE_BINARY_DIR}/paddle/scripts/paddle']
paddle_bins = ['${PADDLE_BINARY_DIR}/paddle/scripts/paddle']
package_data={'paddle.fluid': ['${FLUID_CORE_NAME}' + (
ext_name
if os.name != 'nt' else '.pyd')]}
package_data={'paddle.fluid': ['${FLUID_CORE_NAME}' + (
'.so'
if os.name != 'nt' else '.pyd')]}
if '${HAS_NOAVX_CORE}' == 'ON':
if '${HAS_NOAVX_CORE}' == 'ON':
package_data['paddle.fluid'] += ['core_noavx' + (
ext_name
if os.name != 'nt' else '.pyd')]
package_data['paddle.fluid'] += ['core_noavx' + (
'.so'
if os.name != 'nt' else '.pyd')]
package_dir={
package_dir={
'': '${PADDLE_BINARY_DIR}/python',
'': '${PADDLE_BINARY_DIR}/python',
...
@@ -223,9 +224,9 @@ if '${CMAKE_BUILD_TYPE}' == 'Release':
...
@@ -223,9 +224,9 @@ if '${CMAKE_BUILD_TYPE}' == 'Release':
if os.name != 'nt':
if os.name != 'nt':
# only change rpath in Release mode, since in Debug mode, ${FLUID_CORE_NAME}.xx is too large to be changed.
# only change rpath in Release mode, since in Debug mode, ${FLUID_CORE_NAME}.xx is too large to be changed.
if "@APPLE@" == "1":
if "@APPLE@" == "1":
command = "install_name_tool -id \"@loader_path/../libs/\" ${PADDLE_BINARY_DIR}/python/paddle/fluid/${FLUID_CORE_NAME}" +
ext_name
command = "install_name_tool -id \"@loader_path/../libs/\" ${PADDLE_BINARY_DIR}/python/paddle/fluid/${FLUID_CORE_NAME}" +
'.so'
else:
else:
command = "patchelf --set-rpath '$ORIGIN/../libs/' ${PADDLE_BINARY_DIR}/python/paddle/fluid/${FLUID_CORE_NAME}" +
ext_name
command = "patchelf --set-rpath '$ORIGIN/../libs/' ${PADDLE_BINARY_DIR}/python/paddle/fluid/${FLUID_CORE_NAME}" +
'.so'
if os.system(command) != 0:
if os.system(command) != 0:
raise Exception("patch ${FLUID_CORE_NAME}.%s failed, command: %s" % (ext_name, command))
raise Exception("patch ${FLUID_CORE_NAME}.%s failed, command: %s" % (ext_name, command))
...
@@ -237,6 +238,8 @@ if os.name == 'nt':
...
@@ -237,6 +238,8 @@ if os.name == 'nt':
fix_package_dir[k] = v.replace('/', '\\')
fix_package_dir[k] = v.replace('/', '\\')
package_dir = fix_package_dir
package_dir = fix_package_dir
ext_modules = []
ext_modules = []
elif sys.platform == 'darwin':
ext_modules = []
setup(name='${PACKAGE_NAME}',
setup(name='${PACKAGE_NAME}',
version='${PADDLE_VERSION}',
version='${PADDLE_VERSION}',
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录