CERN/TIGRE

Reconstruction errors out with certain geometries cause memset fail when initializing iterative reconstruction.

X-Strahl opened this issue · 4 comments

I am having issues reconstructing certain geometries in TIGRE with MLEM and CGLS/LSQR (FDK works fine). This only happens with certain geometry combinations and I have not been able to pinpoint what triggers it exactly. By just downsampling the radiographs, I am able to circumvent it, but smaller radiographs do not mean it will succeed. Sometimes upsampling fixes the issue. This includes changing the geometry of course (detector pixel amount and size).

With this code:

from tigre.utilities import sample_loader
import tigre
import tigre.algorithms as algs
import matplotlib.pyplot as plt
import numpy as np

phantom = np.random.rand(3511,1964,1964).astype(np.float32)
tigre_geometry = tigre.geometry_default(nVoxel=phantom.shape)
tigre_geometry.nDetector=np.array([phantom.shape[0],phantom.shape[1]])
angles = np.linspace(0, 2*np.pi, 102)
tigre_geometry.DSD=458
tigre_geometry.DSO=28

tigre_geometry.dDetector=np.array([0.12987013, 0.12987013])
tigre_geometry.sDetector=np.array([455.97402597, 255.06493506])
tigre_geometry.dVoxel=np.array([0.02026159, 0.02027554, 0.02027554])
tigre_geometry.sVoxel=np.array([28.4532169373,15.9162968, 15.9162968 ])

projections_default = tigre.Ax(phantom, tigre_geometry, angles)
print(tigre_geometry)
recon=algs.mlem(projections_default, tigre_geometry, angles, 20)

I can provoke the error. And I get the output:


TIGRE parameters
-----
Geometry parameters
Distance from source to detector (DSD) = 458 mm
Distance from source to origin (DSO)= 28 mm
-----
Detector parameters
Number of pixels (nDetector) = [3511 1964]
Size of each pixel (dDetector) = [0.12987013 0.12987013] mm
Total size of the detector (sDetector) = [455.97402597 255.06493506] mm
-----
Image parameters
Number of voxels (nVoxel) = [3511 1964 1964]
Total size of the image (sVoxel) = [28.45321694 15.9162968  15.9162968 ] mm
Size of each voxel (dVoxel) = [0.02026159 0.02027554 0.02027554] mm
-----
Offset correction parameters
Offset of image from origin (offOrigin) = [0 0 0] mm
Offset of detector (offDetector) = [0 0] mm
-----
Auxillary parameters
Samples per pixel of forward projection (accuracy) = 0.5
-----
Rotation of the Detector (rotDetector) = [0 0 0] rad

../Common/CUDA/TIGRE_common.cpp (7): memset fail 
../Common/CUDA/TIGRE_common.cpp (14): CBCT:CUDA:Atb an illegal memory access was encountered

Hardware is 512GB RAM and dual RTX 4090. Forcing TIGRE to just use one GPU does not fix the issue. Latest Cython and Numpy is used.

Screenshot 2023-10-23 at 9 07 57 AM

I also see issues like this sometimes where it seemingly succeeds but the reconstruction looks like this (This is a vertical slice), where a large portion has no value.

Thanks! this seems an edge case on the memory management of CUDA, I believe.
I'll investigate.