GPU and CPU rendering on MacBookPro M2 ProMax

I have the latest Apple MacBook with Apple silicon, 96GB of RAM running Ventura. I am using the most recent build of Slicer for Mac from 2023-4-25. My fairly large data sets are rendering well, though slowly, using the CPU, but when I swap to GPU the volume is a uniform prism of color. Here is an example data set of a clingfish.

I expect the answer is that Apple silicon is just not working well with Slicer, but if someone has a workaround it would be great.

@jcfr @pieper this the screenshot @Adam_Summers sent me earlier, if it helps…

CPU rendering
image

GPU rendering.
image

Thanks for sharing the data. I could use GPU rendering on a mac pro, but on a mac book air m2 I got this error:

[VTK] Invalid texture dimensions [447, 318, 2308]

[FD] UNSUPPORTED (log once): POSSIBLE ISSUE: unit 1 GLD_TEXTURE_INDEX_3D is unloadable and bound to sampler type (Float) - using zero texture because texture unloadable

so it must be a hardware or driver limit, probably to 2048 max dimension

I used CropVolume with a 1.5x multiplier on the spacing and then GPU rendering worked on the m2 machine:

image

Dear Steve, thanks so much for identifying the issue. You have given me a path to a work around. I really appreciate it.

-Adam

This is an unfortunate limitation, particularly if this is true for the top of the line M2 macbook pro @Fishguy has. I don’t have this problem on my 2018 intel macbook pro.

Do you know if there is a way to report this to apple? I am concerned because a lot of biology folks use Slicer on Mac, and that’s a limitation we can’t do much.

Just to follow up. Steve has found the issue. More than 2048 slices and the GPU won’t work. I have tested this with 5 data sets that were not working, and by cutting down the number of slices they work just fine. The InputStack module in SlicerMorph (which I think Steve wrote) has a ā€˜Skip Slices’ option that allows you to tune the total slices in the Z direction. That is a work around until Apple gets itself in order on this.

Thanks a lot.

Adam

From what I can tell this is a hardware limit on Apple GPUs. This document says that all the apple GPUs, including the ā€œMetal 3ā€ in the M2 have a max size of 2048 in all dimensions. It’s hard to know if they will relax this in the future. For. now I’m afraid downsampling is the best option.

@Adam_Summers if skipping slices give you okay image quality then that’s a good workaround. Using CropVolume to downsample a larger volume will be less lossy, but more time consuming of course.

As a follow-up, this is being addressed by @lassoan through PR-8430:

On macOS graphics hardware, maximum 3D texture size (along any axis) is typically 2048. This commit sets volume partitioning partitioned to not exceed this size by default.

On other systems volume is maximum size is set to 4096 by default, which will not split up the volume in most cases (which was the behavior before this commit).

1 Like