File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ namespace paddle {
26
26
namespace framework {
27
27
28
28
std::once_flag gflags_init_flag;
29
+ std::once_flag p2p_init_flag;
29
30
30
31
void InitGflags (std::vector<std::string> &argv) {
31
32
std::call_once (gflags_init_flag, [&]() {
@@ -42,6 +43,27 @@ void InitGflags(std::vector<std::string> &argv) {
42
43
});
43
44
}
44
45
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
+
45
67
void InitDevices () {
46
68
/* Init all avaiable devices by default */
47
69
@@ -63,7 +85,7 @@ void InitDevices() {
63
85
for (int i = 0 ; i < count; ++i) {
64
86
places.emplace_back (platform::CUDAPlace (i));
65
87
}
66
-
88
+ InitP2P (count);
67
89
platform::DeviceContextPool::Init (places);
68
90
}
69
91
Original file line number Diff line number Diff line change @@ -13,8 +13,11 @@ cc_library(paddle_fluid_shared SHARED
13
13
SRCS io.cc
14
14
DEPS ARCHIVE_START ${GLOB_OP_LIB} ${FLUID_CORE_MODULES} ARCHIVE_END )
15
15
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 ()
18
21
19
22
if (WITH_TESTING )
20
23
add_subdirectory (tests/book )
You can’t perform that action at this time.
0 commit comments