@@ -135,10 +135,6 @@ def _execute_section(self, section: Section, section_index: int = 0):
135135 slicing_dim_section : Literal [0 , 1 ] = _get_slicing_dim (section .pattern ) - 1 # type: ignore
136136 self .determine_max_slices (section , slicing_dim_section , self .source .aux_data .get_angles ())
137137
138- # Account for potential padding in number of max slices
139- padding = determine_section_padding (section )
140- section .max_slices -= padding [0 ] + padding [1 ]
141-
142138 self ._log_pipeline (
143139 f"Maximum amount of slices is { section .max_slices } for section { section_index } " ,
144140 level = logging .DEBUG ,
@@ -260,9 +256,9 @@ def _execute_section_block(
260256 ) -> DataSetBlock :
261257 if_previous_block_is_on_gpu = False
262258 convert_gpu_block_to_cpu = False
259+ if_current_block_is_on_gpu = False
263260
264261 for ind , method in enumerate (section ):
265- if_current_block_is_on_gpu = False
266262 if method .implementation == "gpu_cupy" :
267263 if_current_block_is_on_gpu = True
268264 if method .method_name == "calculate_stats" and if_previous_block_is_on_gpu :
@@ -410,7 +406,9 @@ def determine_max_slices(self, section: Section, slicing_dim: int, angles: np.nd
410406 assert len (section ) > 0 , "Section should contain at least 1 method"
411407
412408 data_shape = self .source .chunk_shape
413- max_slices = data_shape [slicing_dim ]
409+ max_slices = (
410+ data_shape [slicing_dim ] + self .source .padding [0 ] + self .source .padding [1 ]
411+ )
414412 # loop over all methods in section
415413 has_gpu = False
416414 for idx , m in enumerate (section ):
@@ -463,6 +461,20 @@ def determine_max_slices(self, section: Section, slicing_dim: int, angles: np.nd
463461 max_slices_methods [idx ] = min (max_slices , slices_estimated )
464462 non_slice_dims_shape = output_dims
465463
464+ if (
465+ min (max_slices_methods )
466+ < 1 + self .source .padding [0 ] + self .source .padding [1 ]
467+ ):
468+ padded_method = next (
469+ method .method_name for method in section .methods if method .padding
470+ )
471+ err_str = (
472+ "Unable to process data due to GPU memory limitations.\n "
473+ f"Please remove method '{ padded_method } ' from the pipeline, or run on a "
474+ "machine with more GPU memory."
475+ )
476+ raise ValueError (err_str )
477+
466478 section .max_slices = min (max_slices_methods )
467479
468480 def _pass_min_block_length_to_intermediate_data_wrapper (self , section : Section ):
0 commit comments