# CUDA version Problem

**URL:** <https://discourse.itk.org/t/cuda-version-problem/6498>\
**Category:** Engineering\
**Created:** [March 7, 2024, 8:02am UTC](https://discourse.itk.org/t/cuda-version-problem/6498 "2024-03-07T08:02:47Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![skb](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/c77e96/32.png) [@skb](https://discourse.itk.org/u/skb)\
**Post date:** [March 7, 2024, 8:02am UTC](https://discourse.itk.org/t/cuda-version-problem/6498/1 "2024-03-07T08:02:47Z")

</div>

i wonder if there are any relationship between the ＣＵＤＡ version of compiling RTK linkｅｄ and the CUDA version of RTK applying environment，because i met a strange problem that a same procedure runs faster on my pc than that on a better epuiped computer with 2 4090 GPUs, and only the CUDA version is different，i tried to oberve the usage rate of GPU,the usage rate of GPU runs highly during the procedure running,it means the procedure did called GPU .but what is the reason for time cost difference?

---

<div class="post-metadata">

**Author:** ![simon.rit](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@simon.rit](https://discourse.itk.org/u/simon.rit)\
**Post date:** [March 7, 2024, 12:32pm UTC](https://discourse.itk.org/t/cuda-version-problem/6498/2 "2024-03-07T12:32:58Z")

</div>

I don’t have an answer but I would first check that the bottleneck is indeed the computation and not I/O differences between computers. There is a cmake option in RTK (RTK\_PROBE\_EACH\_FILTER) to know where time is spent, maybe it would help comparing the two.  
You might also want to change the CMAKE\_CUDA\_ARCHITECTURES option to activate compile options suitable for 4090 GPUs, the current [default](https://github.com/RTKConsortium/ITKCudaCommon/blob/master/itk-module-init.cmake#L12) is low to be compatible with most cards.

---

<div class="post-metadata">

**Author:** ![skb](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/c77e96/32.png) [@skb](https://discourse.itk.org/u/skb)\
**Post date:** [March 8, 2024, 2:19am UTC](https://discourse.itk.org/t/cuda-version-problem/6498/3 "2024-03-08T02:19:06Z")

</div>

thank you for replying,firstly,my ITK’s verison is 5.2.1,and RTK’s version is 2.3,i compiled them with cmake-gui,i can not find the keys which named RTK\_PROBE\_EACH\_FILTER and CMAKE\_CUDA\_ARCHITECTURES ,but i find RTK\_PROBE\_EACH\_FILTER in cmakelist.txt in RTK’s suorce package,and i modify it from off to on,is it means i need compile RTK again and new dlls will help me find out where the time is spent?by the way,how to set CMAKE\_CUDA\_ARCHITECTURES to activate compile options suitable for 4090 GPUs,i just know the **RTX 3080** for value 86,there is no infomation for 4090,

---

<div class="post-metadata">

**Author:** ![simon.rit](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@simon.rit](https://discourse.itk.org/u/simon.rit)\
**Post date:** [March 9, 2024, 5:22pm UTC](https://discourse.itk.org/t/cuda-version-problem/6498/4 "2024-03-09T17:22:04Z")

</div>

The cmake options are probably in the advanced options.  
To display timing information, you need to call `rtk::GlobalResourceProbe::GetInstance()->Report(std::cout);`.  
For architectures, I think 4090 is Ada Lovelace so 89, see [CUDA - Wikipedia](https://en.wikipedia.org/wiki/CUDA#GPUs_supported).

---

<div class="post-metadata">

**Author:** ![skb](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/c77e96/32.png) [@skb](https://discourse.itk.org/u/skb)\
**Post date:** [March 11, 2024, 3:29am UTC](https://discourse.itk.org/t/cuda-version-problem/6498/5 "2024-03-11T03:29:55Z")

</div>

thank you,i got the way to display timing information,but i want to know between rtk::GlobalResourceProbe::GetInstance()-\>Start(char\*) and rtk::GlobalResourceProbe::GetInstance()-\>Stop(char\*), if i need call Update()?now i call Update() in last step which is FOVfilter;

---

<div class="post-metadata">

**Author:** ![simon.rit](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@simon.rit](https://discourse.itk.org/u/simon.rit)\
**Post date:** [March 11, 2024, 10:22pm UTC](https://discourse.itk.org/t/cuda-version-problem/6498/6 "2024-03-11T22:22:20Z")

</div>

No, all filters that have been compiled after inclusion of rtkMacro.h will automatically record the information. That would be all filters for an executable with rtkMacro.h included first thing. This is based on a redefinition of the New macro:

> <https://github.com/SimonRit/RTK/blob/master/include/rtkMacro.h#L145-L164>

---

<div class="post-metadata">

**Author:** ![skb](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/c77e96/32.png) [@skb](https://discourse.itk.org/u/skb)\
**Post date:** [March 12, 2024, 3:26am UTC](https://discourse.itk.org/t/cuda-version-problem/6498/7 "2024-03-12T03:26:59Z")

</div>

> [@simon.rit](#):
>
> `smartPtr `

thank you for replying! i compiled RTK again,i set CMAKE\_CUDA\_ARCHITECTURES by adding a newline set\_property(TARGET RTK PROPERTY CUDA\_ARCHITECTURES “86;89”) in RTK/src/cmakelist.txt and i got new dlls,then i test in my procedure,it seems that there is no improvement in speed on better equiped computer,on the other hand,i called `rtk::GlobalResourceProbe::GetInstance()-\>Report(std::cout) to display timing information,it shows that fdkfilter takes up the vast majority of time，the total time is 76s,and fdkfilter cost 43s.on my computer,total time is 53s,fdkfilter cost 22s,i don’t know why is it and what to do to help it,could you please give me some advice,thanks!

---

<div class="post-metadata">

**Author:** ![simon.rit](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@simon.rit](https://discourse.itk.org/u/simon.rit)\
**Post date:** [March 12, 2024, 5:37am UTC](https://discourse.itk.org/t/cuda-version-problem/6498/8 "2024-03-12T05:37:37Z")

</div>

It is useful to look at the details. FDK is a composite filter. What should take most of the time is the ramp filter and the backprojection. Are they both slower on this machine? Don’t hesitate to post the two logs.

---

<div class="post-metadata">

**Author:** ![skb](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/c77e96/32.png) [@skb](https://discourse.itk.org/u/skb)\
**Post date:** [March 12, 2024, 7:03am UTC](https://discourse.itk.org/t/cuda-version-problem/6498/9 "2024-03-12T07:03:33Z")

</div>

i called CudaFDKConeBeamReconstructionFilter on my procedure,how can i figure out What should take most of the time is the ramp filter and the backprojection,replace CudaFDKConeBeamReconstructionFilter with ramp filter and the backprojection？

---

<div class="post-metadata">

**Author:** ![simon.rit](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@simon.rit](https://discourse.itk.org/u/simon.rit)\
**Post date:** [March 12, 2024, 12:59pm UTC](https://discourse.itk.org/t/cuda-version-problem/6498/10 "2024-03-12T12:59:18Z")

</div>

No, `rtk::GlobalResourceProbe::GetInstance()->Report(std::cout);` should provide the details, doesn’t it?

---

<div class="post-metadata">

**Author:** ![skb](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/c77e96/32.png) [@skb](https://discourse.itk.org/u/skb)\
**Post date:** [March 13, 2024, 1:01am UTC](https://discourse.itk.org/t/cuda-version-problem/6498/11 "2024-03-13T01:01:50Z")

</div>

if i just call rtk::GlobalResourceProbe::GetInstance()-\>Report(std::cout) there is nothing show,i used rtk::GlobalResourceProbe::GetInstance()-\>Start() and rtk::GlobalResourceProbe::GetInstance()-\>Stop() between filter start and end ,it will show the timing information

---

<div class="post-metadata">

**Author:** ![skb](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/c77e96/32.png) [@skb](https://discourse.itk.org/u/skb)\
**Post date:** [March 13, 2024, 1:04am UTC](https://discourse.itk.org/t/cuda-version-problem/6498/12 "2024-03-13T01:04:02Z")

</div>

![image](https://discourse.itk.org/uploads/default/original/2X/6/624b47ce86e0351f1e6c18db2ee48b19f967f259.png)  
that’s the timing information

---

<div class="post-metadata">

**Author:** ![simon.rit](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@simon.rit](https://discourse.itk.org/u/simon.rit)\
**Post date:** [March 13, 2024, 5:54am UTC](https://discourse.itk.org/t/cuda-version-problem/6498/13 "2024-03-13T05:54:25Z")

</div>

It does not look like you have activated RTK\_PROBE\_EACH\_FILTER but that you do the probing manually. If it were activated, you would get something like this (here with rtkfdk):

```auto
$ rtkfdk -p . -r his -o test.mha --like fdk.mha -v -g geometry.xml 
Regular expression matches 355 file(s)...
Reading... 
Reading geometry information from geometry.xml...
Reconstructing and writing... 
FDKConeBeamReconstructionFilter 99% completed.

*******************************************************************************************************************
Probe Tag Starts Stops Time (s) Memory (kB) Cuda memory (kB)
*******************************************************************************************************************
ConstantImageSource 1 1 0.00070715 0 0              
CropImageFilter 355 355 0.000190987 0.0225352 0              
DisplacedDetectorForOffsetFieldOfViewImageFilter 23 23 0.000468327 0 0              
ElektaSynergyRawLookupTableImageFilter 355 355 0.000145972 0 0              
ExtractImageFilter 23 23 0.000613192 0 0              
FDKBackProjectionImageFilter 23 23 0.00418923 0 0              
FDKConeBeamReconstructionFilter 1 1 0.741545 12936 0              
FDKWeightProjectionFilter 23 23 0.00112339 0 0              
FFTRampImageFilter 23 23 0.023475 562.435 0              
ImageFileReader 355 355 0.000567063 4.8 0              
ImageSeriesReader 355 355 0.000727532 4.8 0              
LUTbasedVariableI0RawToAttenuationImageFilter 355 355 0.000922433 0 0              
LogImageFilter 355 355 0.000163057 0 0              
ParkerShortScanImageFilter 23 23 0.000502255 0 0              
ProjectionsReader 1 1 0.889115 445160 0              
StreamingImageFilter 2 2 0.79476 183412 0              
SubtractImageFilter 710 710 0.000144491 0 0              
ThresholdImageFilter 355 355 0.000141167 0 0              

```

---

<div class="post-metadata">

**Author:** ![simon.rit](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@simon.rit](https://discourse.itk.org/u/simon.rit)\
**Post date:** [March 13, 2024, 6:15am UTC](https://discourse.itk.org/t/cuda-version-problem/6498/14 "2024-03-13T06:15:41Z")

</div>

Maybe you can check that `RTK_PROBE_EACH_FILTER` is set and that `rtkConfiguration.h` is the first include in your main file as in [rtkfdk](https://github.com/SimonRit/RTK/blob/master/applications/rtkfdk/rtkfdk.cxx#L21) before including `rtkMacro.h’?

---

<div class="post-metadata">

**Author:** ![skb](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/c77e96/32.png) [@skb](https://discourse.itk.org/u/skb)\
**Post date:** [March 13, 2024, 8:08am UTC](https://discourse.itk.org/t/cuda-version-problem/6498/15 "2024-03-13T08:08:25Z")

</div>

![企业微信截图_17103152467440](https://discourse.itk.org/uploads/default/original/2X/6/69b0a1bf1dc53d2adbcc0b02b000e11a8ebc5ad2.png)  
when compiled RTK,i choosed this setting,and i checked the cmakelist.txt,there is a line written "option(RTK\_PROBE\_EACH\_FILTER “Probe each RTK filter in a global object and report times and memory used in RTK applications” ON) ",in my main file, i have include `rtkConfiguration.h`before including `rtkMacro.h’,but just call rtk::GlobalResourceProbe::GetInstance()-\>Report(std::cout) shows nothing

---

<div class="post-metadata">

**Author:** ![simon.rit](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@simon.rit](https://discourse.itk.org/u/simon.rit)\
**Post date:** [March 13, 2024, 12:15pm UTC](https://discourse.itk.org/t/cuda-version-problem/6498/16 "2024-03-13T12:15:00Z")

</div>

Can you check if your rtkConfiguration.h file has indeed the line

```c++
#define RTK_PROBE_EACH_FILTER

```

?  
I don’t know what’s wrong otherwise if rtkConfiguration.h and rtkMacro.h are included first (before, e.g., FDK)

---

<div class="post-metadata">

**Author:** ![skb](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/c77e96/32.png) [@skb](https://discourse.itk.org/u/skb)\
**Post date:** [March 14, 2024, 1:07am UTC](https://discourse.itk.org/t/cuda-version-problem/6498/17 "2024-03-14T01:07:19Z")

</div>

> [@simon.rit](#):
>
> `R`

 ![image](https://discourse.itk.org/uploads/default/original/2X/9/90c8160242908a92e83bcc1f6e2b25bc06e8e097.png)  
rtkConfiguration.h file dosn’t have indeed the line  
#define RTK\_PROBE\_EACH\_FILTER  
and i add this to it,after rebuilding RTK, i got the detailed information of timing,CudaFDKConeBeamReconstructionFilter takes up the vast majority of time.last but not the least,the main purpose of this topic is to deal with the difference between 2 computers,i want to know how to fix it,theoretically，a better equiped computer runs faster than a bad one.

---

<div class="post-metadata">

**Author:** ![simon.rit](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@simon.rit](https://discourse.itk.org/u/simon.rit)\
**Post date:** [March 14, 2024, 6:23am UTC](https://discourse.itk.org/t/cuda-version-problem/6498/18 "2024-03-14T06:23:40Z")

</div>

Indeed, so can you post the two timing outputs for comparison?

---

<div class="post-metadata">

**Author:** ![skb](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/c77e96/32.png) [@skb](https://discourse.itk.org/u/skb)\
**Post date:** [March 14, 2024, 6:33am UTC](https://discourse.itk.org/t/cuda-version-problem/6498/19 "2024-03-14T06:33:56Z")

</div>

A4000 GPU

 ![image](https://discourse.itk.org/uploads/default/original/2X/6/652fea2a0454dbeba0335553933d95037120c2d7.png)  
4090 GPU  
 ![企业微信截图_17103978764768](https://discourse.itk.org/uploads/default/original/2X/f/f73a0e61642b4ee0bc5fd5c6f1a35cfb2faa91f1.png)  
here are the comparision,

---

<div class="post-metadata">

**Author:** ![simon.rit](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@simon.rit](https://discourse.itk.org/u/simon.rit)\
**Post date:** [March 14, 2024, 7:28am UTC](https://discourse.itk.org/t/cuda-version-problem/6498/20 "2024-03-14T07:28:46Z")

</div>

So the backprojection is slightly faster on the 4090 GPU but the ramp filter is two times slower. Interestingly, the CudaCropImageFilter, which does not compute much, is three times slower so it might be a suboptimal use of the memory cache. Maybe increasing `RTK_CUDA_PROJECTIONS_SLAB_SIZE` to e.g. 32 will help? There is also a number of hard coded constants in RTK (tBlock\_x, tBlock\_y, tBlock\_z) which would benefit from being tuned for each architecture.

[Next page](https://discourse.itk.org/t/cuda-version-problem/6498.md?page=2)
