Skip to content

Commit 3bcffd4

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into dev_MultiEpochReader
2 parents d9868b0 + 0821ee7 commit 3bcffd4

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

paddle/fluid/framework/init.cc

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ namespace paddle {
2626
namespace framework {
2727

2828
std::once_flag gflags_init_flag;
29+
std::once_flag p2p_init_flag;
2930

3031
void InitGflags(std::vector<std::string> &argv) {
3132
std::call_once(gflags_init_flag, [&]() {
@@ -42,6 +43,27 @@ void InitGflags(std::vector<std::string> &argv) {
4243
});
4344
}
4445

46+
void InitP2P(int count) {
47+
#ifdef PADDLE_WITH_CUDA
48+
std::call_once(p2p_init_flag, [&]() {
49+
for (int i = 0; i < count; ++i) {
50+
for (int j = 0; j < count; ++j) {
51+
if (i == j) continue;
52+
int can_acess = -1;
53+
PADDLE_ENFORCE(cudaDeviceCanAccessPeer(&can_acess, i, j),
54+
"Failed to test P2P access.");
55+
if (can_acess != 1) {
56+
LOG(WARNING) << "Cannot enable P2P access from " << i << " to " << j;
57+
} else {
58+
cudaSetDevice(i);
59+
cudaDeviceEnablePeerAccess(j, 0);
60+
}
61+
}
62+
}
63+
});
64+
#endif
65+
}
66+
4567
void InitDevices() {
4668
/*Init all avaiable devices by default */
4769

@@ -63,7 +85,7 @@ void InitDevices() {
6385
for (int i = 0; i < count; ++i) {
6486
places.emplace_back(platform::CUDAPlace(i));
6587
}
66-
88+
InitP2P(count);
6789
platform::DeviceContextPool::Init(places);
6890
}
6991

paddle/fluid/inference/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ cc_library(paddle_fluid_shared SHARED
1313
SRCS io.cc
1414
DEPS ARCHIVE_START ${GLOB_OP_LIB} ${FLUID_CORE_MODULES} ARCHIVE_END)
1515
set_target_properties(paddle_fluid_shared PROPERTIES OUTPUT_NAME paddle_fluid)
16-
set(LINK_FLAGS "-Wl,--version-script ${CMAKE_CURRENT_SOURCE_DIR}/paddle_fluid.map")
17-
set_target_properties(paddle_fluid_shared PROPERTIES LINK_FLAGS "${LINK_FLAGS}")
16+
if(NOT APPLE)
17+
# TODO(liuyiqun): Temporarily disable the link flag because it is not support on Mac.
18+
set(LINK_FLAGS "-Wl,--version-script ${CMAKE_CURRENT_SOURCE_DIR}/paddle_fluid.map")
19+
set_target_properties(paddle_fluid_shared PROPERTIES LINK_FLAGS "${LINK_FLAGS}")
20+
endif()
1821

1922
if(WITH_TESTING)
2023
add_subdirectory(tests/book)

0 commit comments

Comments
 (0)