@@ -14,7 +14,9 @@ limitations under the License. */
14
14
15
15
#include " paddle/fluid/operators/detail/sendrecvop_utils.h"
16
16
17
+ #ifdef PADDLE_WITH_CUDA
17
18
#include < nccl.h>
19
+ #endif
18
20
#include < sys/time.h>
19
21
#include < thread> // NOLINT
20
22
@@ -51,10 +53,12 @@ void SerializeToByteBuffer(const std::string& name, framework::Variable* var,
51
53
e.WriteUint64 (VarMsg::kTypeFieldNumber , 0 );
52
54
} else if (var->IsType <framework::SelectedRows>()) {
53
55
e.WriteUint64 (VarMsg::kTypeFieldNumber , 1 );
56
+ #ifdef PADDLE_WITH_CUDA
54
57
} else if (var->IsType <ncclUniqueId>()) {
55
58
// NOTE: sendrecv only support RAW type for NCCL_ID
56
59
VLOG (3 ) << " serilizing: setting var type nccl id" ;
57
60
e.WriteUint64 (VarMsg::kTypeFieldNumber , 2 );
61
+ #endif
58
62
}
59
63
60
64
if (!out_name.empty ()) {
@@ -141,17 +145,19 @@ void SerializeToByteBuffer(const std::string& name, framework::Variable* var,
141
145
}
142
146
payload_size = tensor->numel () * framework::SizeOfType (tensor->type ());
143
147
e.WriteVarlengthBeginning (VarMsg::kSerializedFieldNumber , payload_size);
148
+ #ifdef PADDLE_WITH_CUDA
144
149
} else if (var->IsType <ncclUniqueId>()) {
145
150
// ===========================NCCL ID==================================
146
151
e.WriteVarlengthBeginning (VarMsg::kSerializedFieldNumber ,
147
152
NCCL_UNIQUE_ID_BYTES);
148
153
ncclUniqueId* uid = var->GetMutable <ncclUniqueId>();
149
154
e.WriteRawBytes (std::string (uid->internal , NCCL_UNIQUE_ID_BYTES));
155
+ #endif
150
156
} else {
151
157
PADDLE_THROW (" Serialize does not support type: %s" ,
152
158
typeid (var->Type ()).name ());
153
159
}
154
-
160
+ # ifdef PADDLE_WITH_CUDA
155
161
if (var->IsType <ncclUniqueId>()) {
156
162
// for serialize NCCL_ID
157
163
::grpc::Slice slices (e.size ());
@@ -160,7 +166,7 @@ void SerializeToByteBuffer(const std::string& name, framework::Variable* var,
160
166
msg->Swap (&tmp);
161
167
return ;
162
168
}
163
-
169
+ # endif
164
170
// steal reference of tensor data
165
171
::grpc::Slice slices[4 ]; // metadata, tensor, rows meta, rows
166
172
int num_slices = 2 ; // only SelectedRows have rows buffer
0 commit comments