@@ -147,22 +147,38 @@ ResponseSender::Send(
147
147
}
148
148
149
149
if (has_gpu_output) {
150
+ ScopedDefer _ ([send_message_payload] {
151
+ bi::scoped_lock<bi::interprocess_mutex> guard{send_message_payload->mu };
152
+ send_message_payload->is_stub_turn = false ;
153
+ send_message_payload->cv .notify_one ();
154
+ while (!send_message_payload->is_stub_turn ) {
155
+ // Wait for the stub process to send the response and populate error
156
+ // message if any.
157
+ send_message_payload->cv .wait (guard);
158
+ }
159
+ });
160
+
150
161
AllocatedSharedMemory<GPUBuffersShm> gpu_buffers_handle =
151
162
shm_pool_->Load <GPUBuffersShm>(
152
163
send_message_payload->gpu_buffers_handle );
164
+ if (!gpu_buffers_handle.data_ ->success ) {
165
+ std::unique_ptr<PbString> error = PbString::LoadFromSharedMemory (
166
+ shm_pool_, gpu_buffers_handle.data_ ->error );
167
+ throw PythonBackendException (
168
+ " Failed to load GPU buffers: " + error->String ());
169
+ }
153
170
154
171
AllocatedSharedMemory<bi::managed_external_buffer::handle_t >
155
172
gpu_buffers_handle_shm =
156
173
shm_pool_->Load <bi::managed_external_buffer::handle_t >(
157
174
gpu_buffers_handle.data_ ->buffers );
158
175
uint64_t gpu_buffer_count = gpu_buffers_handle.data_ ->buffer_count ;
159
176
if (gpu_tensors.size () != gpu_buffer_count) {
160
- LOG_ERROR
161
- << (std::string (
162
- " GPU buffers size does not match the provided buffers: " ) +
163
- std::to_string (gpu_tensors.size ()) +
164
- " != " + std::to_string (gpu_buffer_count));
165
- return ;
177
+ throw PythonBackendException (
178
+ std::string (
179
+ " GPU buffers size does not match the provided buffers: " ) +
180
+ std::to_string (gpu_tensors.size ()) +
181
+ " != " + std::to_string (gpu_buffer_count));
166
182
}
167
183
168
184
std::vector<std::unique_ptr<PbMemory>> dst_buffers;
@@ -175,17 +191,6 @@ ResponseSender::Send(
175
191
std::shared_ptr<PbTensor>& src_buffer = gpu_tensors[i];
176
192
PbMemory::CopyBuffer (dst_buffers[i], src_buffer->Memory ());
177
193
}
178
-
179
- {
180
- bi::scoped_lock<bi::interprocess_mutex> guard{send_message_payload->mu };
181
- send_message_payload->is_stub_turn = false ;
182
- send_message_payload->cv .notify_one ();
183
- while (!send_message_payload->is_stub_turn ) {
184
- // Wait for the stub process to send the response and populate error
185
- // message if any.
186
- send_message_payload->cv .wait (guard);
187
- }
188
- }
189
194
}
190
195
191
196
if (send_message_payload->has_error ) {
0 commit comments