-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
@JoOkuma I am wondering if this is the proper wayof calling the back ends, as you kindly explained in this issue. I would like to measure the performance of the Numpy vs. Cupy backends. in other words a process based exclusively on CPU vs the boost in performance using the CuPy GPU backend. I am posting the code I used to generate this test. I have a 32x speed increase using the Cupy backend (uhuu!!!). I want to make sure I am not missing something. The results (see below) indicate that I effectively was using Numpy vs Cupy backends "effectively". Nevertheless I observed a spike of function in my GPU using the Numpy backend. I was expecting that the Numpy backend was exclusively CPU based. Did I understood this wrong?
Results:
Yang <<CupyBackend>> Deskewing completed. Execution Time: 0.5733585357666016 seconds
├ Number of free blocks before and after release: 4->0, used: 0.055 GBs -> 0.055 GBs, total:0.055 GBs
Yang <<NumpyBackend>> Deskewing completed. Execution Time: 19.52552628517151 seconds
Code
from dexp.utils.backends import CupyBackend, NumpyBackend
import dexp
from tifffile import imread
import numpy as np
from dexp.processing.deskew import yang_deskew
import time
def main():
path2img = 'C:\\Python\\Tilt_Calibration_by_Sphere_deskew\\20240207_agoSlide_sphere_8_1_MMStack_Pos0.ome.tif'
RawImage = imread(path2img)
RotatedImage = np.transpose(RawImage, axes=(0, 2, 1)).copy()
dz_pixel = 1.0
test_angle = 45
dz_stage = dz_pixel / np.sin(np.deg2rad(test_angle))
backends = [CupyBackend, NumpyBackend]
for backend in backends:
with backend() as bkd:
array = bkd.to_backend(RotatedImage)
start_time = time.time()
array_out = dexp.processing.deskew.yang_deskew(array,
depth_axis=0,
lateral_axis=2,
flip_depth_axis=0,
dx=0.175,
dz=dz_stage,
angle=45,
camera_orientation=0,
num_split=1,
internal_dtype=None,
padding=None)
end_time = time.time()
print(f"Yang <<{backend.__name__}>> Deskewing completed. Execution Time:", end_time - start_time, "seconds")
array_out = bkd.to_numpy(array_out)
if __name__ == "__main__":
main()Metadata
Metadata
Assignees
Labels
No labels