# Better GPU will benefit or not VR volume rendering

**URL:** <https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008>\
**Category:** Support\
**Created:** [December 10, 2021, 4:31pm UTC](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008 "2021-12-10T16:31:57Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [December 17, 2021, 2:20pm UTC](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008/41 "2021-12-17T14:20:40Z")

</div>

> [@davide445](#):
>
> can you try on the ircadb1.12

What is this strange file ?

---

<div class="post-metadata">

**Author:** ![davide445](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/davide445/32/13460_2.png) [@davide445](https://discourse.slicer.org/u/davide445)\
**Post date:** [December 18, 2021, 7:52pm UTC](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008/43 "2021-12-18T19:52:12Z")

</div>

> [@chir.set](#):
>
> What is this strange file ?

I probably misunderstood your question. The zip contains dicom volumes from a public anonimized dataset used for research.  
Just choosen something anyone can use for testing.

---

<div class="post-metadata">

**Author:** ![davide445](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/davide445/32/13460_2.png) [@davide445](https://discourse.slicer.org/u/davide445)\
**Post date:** [December 19, 2021, 11:25am UTC](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008/44 "2021-12-19T11:25:38Z")

</div>

> [@Hao\_Li](#):
>
> I have tested the following scans on windows with 6900XT
> 
> 2367x1784x942 = 7G No  
> 1950x1830x1600 = 11G Wrong stitching  
> 885x1300x1230 = 5G Yes  
> 2125x2510x938 = 10G No  
> 1937x1829x951 = 6,5G Wrong stitching  
> 2836x1948x2664 = 14G No  
> 1928x1927x937 = 6,8G Wrong stitching  
> 2098x1919x936 = 7G No  
> 1268x1454x1064 = 3G yes  
> 2572x1837x951 = 8G no

Might I ask you if will be possible to use volume crop changing the spacing scale of your 1268x1454x1064 volume to 0.9, and test this way on the 6900 XT.  
This since seems apart the GL\_MAX\_3D\_TEXTURE\_SIZE = 2048 topic might be some wrong shared memory management.  
Looking at your numbers and seeing the GPU memory usage on my side I got the idea to verify why in some cases you have problems even if the texture resolution is below 2048, and created this table

| Res | Hao\_Li disk | Hao\_Li results | VRAM needed (GByte) |
| --- | --- | --- | --- |
| 2367x1784x942 | 7G | No | 29.6 |
| 1950x1830x1600 | 11G | Wrong stitching | 42.5 |
| 885x1300x1230 | 5G | Yes | 10.5 |
| 2125x2510x938 | 10G | No | 37.3 |
| 1937x1829x951 | 6.5G | Wrong stitching | 25.0 |
| 2836x1948x2664 | 14G | No | 109.7 |
| 1928x1927x937 | 6.8G | Wrong stitching | 25.9 |
| 2098x1919x936 | 7G | No | 28.1 |
| 1268x1454x1064 | 3G | Yes | 14.6 |
| 2572x1837x951 | 8G | No | 33.5 |

Where the VRAM needed is calculated considering 16bit (2 byte) resolution at every index, so 8 byte per voxel.  
Appear to me you got problems not only if the slice number is more than 2048, but also if the needed VRAM is greather than your GPU VRAM, 16GB in your case.  
When both the conditions are met (no more than 2048 slices and no more than 16GB VRAM required) you have no problems (two cases).  
So upscaling 10% that volume create a new one requiring more than 16GB and if my hypotesys is true you will need to start having problems even if the slice are less than 2048.

---

<div class="post-metadata">

**Author:** ![davide445](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/davide445/32/13460_2.png) [@davide445](https://discourse.slicer.org/u/davide445)\
**Post date:** [December 19, 2021, 11:44am UTC](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008/45 "2021-12-19T11:44:27Z")

</div>

> [@chir.set](#):
>
> I don’t fully understand your requirements :
> 
> - what is the original volume ?
> 
> I tested with the eyeglobe and another 512x512x2147 slices volume with ‘Spacing scale’ \< 0.24, Volume rendering always works on Linux. In both cases, though the ''Crop volume module shows high dimension values, the ‘Volumes’ module always show the source dimensions for the cropped volumes.

Sorry never answered this question. “original volume” it’s just the name appears on my side as the ircabd1.12 data (the PATIENT\_DICOM folder) is loaded, nothing else.  
About your test being already more than 2048 slices it’s interesting works.  
But wanted to ask if you was actually visualizing the 3d of the first upscaled volume (and not maybe the original one): 6400x6400x26837 will need something about 8 TB VRAM!  
Might I ask how much RAM has your PC.

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [December 19, 2021, 1:10pm UTC](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008/46 "2021-12-19T13:10:05Z")

</div>

> [@davide445](#):
>
> the PATIENT\_DICOM folder

OK, I’ll test with that on my work machine tomorrow.

> [@davide445](#):
>
> Might I ask how much RAM has your PC

I’m running with 64 GB of RAM and 12 GB of VRAM on the 6700XT.

> [@davide445](#):
>
> if you was actually visualizing the 3d of the first upscaled volume

I visualized on both volumes, original and cropped, with Volume Rendering cache emptied. I don’t think that the cropped volumes have so many real slices. The Volumes module does not report that magnitude of Z dimension in the cropped volumes, but the original one. Moreover, if I export a cropped volume as a DICOM series, it has the same number of files as the Z dimension of the original volume. I don’t how we should understand the ‘Spacing scale’ parameter of Crop Volume.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 19, 2021, 2:46pm UTC](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008/47 "2021-12-19T14:46:44Z")

</div>

> [@chir.set](#):
>
> The Volumes module does not report that magnitude of Z dimension in the cropped volumes, but the original one

If you find that the actual volume size is not the same as what Volumes module displays then it is a bug. Check again that you selected the correct volume node etc. and if you confirm that the reported size is wrong then please provide a list of steps to reproduce.

> [@chir.set](#):
>
> don’t how we should understand the ‘Spacing scale’ parameter of Crop Volume

Output volume spacing = input volume spacing \* spacing scale

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [December 19, 2021, 4:40pm UTC](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008/48 "2021-12-19T16:40:49Z")

</div>

> [@lassoan](#):
>
> Check again that you selected the correct volume node etc.

It seems there’s a bug.

_Try 1_

- Start Slicer
- Load CTA-cardio
- Go to Crop Volume
- Generate the ROI with the ‘Fix’ button
- Hide the ROI
- Set Spacing Scale to 0.1
- Apply

It completes quickly with the result below.

 ![crop_volume_01](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/4/64074aa6b5955a018d2509865f853b176d318145.png)

In Volumes module, the cropped volume is similar as the original.

 ![volume_01](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/0/401b8b5eae987be625fef519fee220ed83adc590.png)

_Try 2_

- Do as above
- But with Spacing Scale to 0.9

It takes some time to complete, and the Volumes module shows a cropped volume different from the original.

 ![volume_09](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/7/974b9abe54f0d84857e504e3c5003977c5e81334.png)

Afterwards, in the same session, it we set Spacing Scale to 0.1, it blows up my laptop.

There’s a problem if first Spacing Scale is too low.

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [December 19, 2021, 6:53pm UTC](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008/49 "2021-12-19T18:53:46Z")

</div>

Can confirm that 🙂

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 19, 2021, 7:04pm UTC](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008/50 "2021-12-19T19:04:24Z")

</div>

Spacing scale of 0.1 is expected to “blow up” most computers, as it means making the volume size 1000x larger! Windows would probably just terminate the offending application but on Linux your computer may need a hard reset.

We could maybe display a warning when somebody attempts to do such an extreme operation, because a scaling value of 0.1 may look innocent if you don’t think about what it does and you don’t look at the output volume size.

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [December 19, 2021, 7:31pm UTC](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008/51 "2021-12-19T19:31:16Z")

</div>

> [@lassoan](#):
>
> if you don’t think about what it does

Yes, that was my case.

However, if we start at 0.1, it completes without rescaling anything. This may need a fix too. The warning is welcome. But if it does not rescale despite the warning, it’s misleading.

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [December 20, 2021, 8:05am UTC](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008/52 "2021-12-20T08:05:40Z")

</div>

> [@davide445](#):
>
> can you try on the ircadb1.12 to use the Crop Volume feature with this parameters and try if the result can be rendered

With Spacing Scale at 0.24 using your reference dataset, the resulting volume is 2133 x 2133 x 1083, so \> 2048 in 2 dimensions.

Volume rendering with this resampled volume works, and is very fluid at normal speed.  
Using adaptative, it’s a little laggy, but yet good at default 8 fps.  
At maximum speed, it’s of course minimum interaction speed, 2 - 3 seconds between rotations.

---

<div class="post-metadata">

**Author:** ![davide445](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/davide445/32/13460_2.png) [@davide445](https://discourse.slicer.org/u/davide445)\
**Post date:** [December 20, 2021, 8:09am UTC](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008/53 "2021-12-20T08:09:22Z")

</div>

> [@chir.set](#):
>
> With Spacing Scale at 0.24 using your reference dataset, the resulting volume is 2133 x 2133 x 1083, so \> 2048 in 2 dimensions.

Also at that resolution will exceed the VRAM of your GPU, so that we got also this check that using shared memory works in Linux.

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [December 20, 2021, 8:41am UTC](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008/54 "2021-12-20T08:41:48Z")

</div>

> [@davide445](#):
>
> Also at that resolution will exceed the VRAM of your GPU

I checked that, it used between 1.7 to 2.2 GB of VRAM. Or it’s badly reported by [CoreCtrl](https://gitlab.com/corectrl/corectrl).

---

<div class="post-metadata">

**Author:** ![davide445](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/davide445/32/13460_2.png) [@davide445](https://discourse.slicer.org/u/davide445)\
**Post date:** [December 20, 2021, 8:54am UTC](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008/55 "2021-12-20T08:54:34Z")

</div>

> [@chir.set](#):
>
> I checked that, it used between 1.7 to 2.2 GB of VRAM. Or it’s badly reported by [CoreCtrl](https://gitlab.com/corectrl/corectrl).

@Hao_Li we need your crosscheck on Windows if possibile as from this post

> [@Better GPU will benefit or not VR volume rendering](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008/44):
>
> Might I ask you if will be possible to use volume crop changing the spacing scale of your 1268x1454x1064 volume to 0.9, and test this way on the 6900 XT. This since seems apart the GL\_MAX\_3D\_TEXTURE\_SIZE = 2048 topic might be some wrong shared memory management. Looking at your numbers and seeing the GPU memory usage on my side I got the idea to verify why in some cases you have problems even if the texture resolution is below 2048, and created this table Res Hao\_Li disk Hao\_Li results V…

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [December 20, 2021, 8:58am UTC](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008/56 "2021-12-20T08:58:41Z")

</div>

> [@chir.set](#):
>
> With Spacing Scale at 0.24 using your reference dataset, the resulting volume is 2133 x 2133 x 1083

One last note.

With Spacing Scale at 0.18 using your reference dataset, the resulting volume is 2844 x 2844 x 1444, and Volume Rendering no longer works at any interactive speed.

---

<div class="post-metadata">

**Author:** ![davide445](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/davide445/32/13460_2.png) [@davide445](https://discourse.slicer.org/u/davide445)\
**Post date:** [December 20, 2021, 9:48am UTC](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008/57 "2021-12-20T09:48:21Z")

</div>

> [@chir.set](#):
>
> With Spacing Scale at 0.18 using your reference dataset, the resulting volume is 2844 x 2844 x 1444, and Volume Rendering no longer works at any interactive speed.

Used VRAM using your monitor system?

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [December 20, 2021, 10:25am UTC](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008/58 "2021-12-20T10:25:50Z")

</div>

> [@davide445](#):
>
> Used VRAM using your monitor system?

1.2 GB, i.e., nothing from Volume Rendering.

---

<div class="post-metadata">

**Author:** ![Hao\_Li](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hao_li/32/3420_2.png) [@Hao\_Li](https://discourse.slicer.org/u/Hao_Li)\
**Post date:** [December 20, 2021, 12:18pm UTC](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008/59 "2021-12-20T12:18:55Z")

</div>

Hi! I’m on vacation, will test in a week.

---

<div class="post-metadata">

**Author:** ![Hao\_Li](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hao_li/32/3420_2.png) [@Hao\_Li](https://discourse.slicer.org/u/Hao_Li)\
**Post date:** [December 27, 2021, 9:52am UTC](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008/60 "2021-12-27T09:52:04Z")

</div>

@davide445  
Hi! I’ve just checked.  
1268x1454x1064 Original  
I cropped using 0.9 spacing scale, and the new volume became 1408x1615x1182. The result was viewable but ended in wrong stitching. Wonder if it confirms your thoughts. Let me know if you need anything else tested, I’ll switch back to 3090 when we finish.

---

<div class="post-metadata">

**Author:** ![davide445](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/davide445/32/13460_2.png) [@davide445](https://discourse.slicer.org/u/davide445)\
**Post date:** [December 27, 2021, 12:45pm UTC](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008/61 "2021-12-27T12:45:16Z")

</div>

> [@Hao\_Li](#):
>
> I cropped using 0.9 spacing scale, and the new volume became 1408x1615x1182

Please try to decrease the spacing scale until one of the dimensions exceed 2048, this will need to result in no rendering (if the idea is true)

[Previous page](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008.md?page=2)

[Next page](https://discourse.slicer.org/t/better-gpu-will-benefit-or-not-vr-volume-rendering/21008.md?page=4)
