# Unable to run Garfield's GemGPU example

**URL:** <https://root-forum.cern.ch/t/unable-to-run-garfields-gemgpu-example/60413>\
**Category:** Garfield++\
**Created:** [August 3, 2024, 8:44pm UTC](https://root-forum.cern.ch/t/unable-to-run-garfields-gemgpu-example/60413 "2024-08-03T20:44:35Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabrielribcesario](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/gabrielribcesario/32/38927_2.png) [@gabrielribcesario](https://root-forum.cern.ch/u/gabrielribcesario)\
**Post date:** [August 3, 2024, 8:44pm UTC](https://root-forum.cern.ch/t/unable-to-run-garfields-gemgpu-example/60413/1 "2024-08-03T20:44:35Z")

</div>

Hello,

For the last week I have been trying to compile the [GemGPU](https://gitlab.cern.ch/garfield/garfieldpp/-/blob/master/Examples/GemGPU/gem.C?ref_type=heads) example but to no success. Both Tensorflow and PyTorch can detect my GPU, both `nvidia-smi` and `nvcc -V` work fine and `cudaGetDeviceCount()` returns 1, which is the exact number of available GPUs my computer has. I also used `-DUSEGPU=ON` when calling cmake before installing Garfield.

The `aval.ResumeAvalanche()` call (line 90 of the example) triggers the following error message:

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/b/1/b19ee27b360222af57bf6e1fd6c540606b07ef58.png)

Line 238 in the [AvalancheMicroscopicGPU.cu](https://gitlab.cern.ch/garfield/garfieldpp/-/blob/master/GPU/AvalancheMicroscopicGPU.cu?ref_type=heads) file seems to be the one triggering the error, but I have no idea on how to fix it.

Any help is appreciated. I’ll be glad to provide more information if needed.

_ROOT Version:_ 6.32.2  
_Platform:_ WSL2, Ubuntu 22.04  
_CUDA Toolkit Version:_ 12.6  
_Compiler:_ GCC 11.4.0

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [August 3, 2024, 8:47pm UTC](https://root-forum.cern.ch/t/unable-to-run-garfields-gemgpu-example/60413/2 "2024-08-03T20:47:35Z")

</div>

Maybe @hschindl can help

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [August 5, 2024, 11:50am UTC](https://root-forum.cern.ch/t/unable-to-run-garfields-gemgpu-example/60413/3 "2024-08-05T11:50:45Z")

</div>

Hi,  
this might have been fixed by this merge request:

> **[Add ability to calculate signals on GPU (!408) · Merge requests · garfield /...](https://gitlab.cern.ch/garfield/garfieldpp/-/merge_requests/408)**
>
> This adds the ability to calculate signals on the GPU. We use the "old" method of adding directly to the signal arrays rather than doing it after the...

Could you update and try again?

---

<div class="post-metadata">

**Author:** ![gabrielribcesario](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/gabrielribcesario/32/38927_2.png) [@gabrielribcesario](https://root-forum.cern.ch/u/gabrielribcesario)\
**Post date:** [August 5, 2024, 12:47pm UTC](https://root-forum.cern.ch/t/unable-to-run-garfields-gemgpu-example/60413/4 "2024-08-05T12:47:34Z")

</div>

I tried re-installing Garfield, I am getting the following error code during the `make install` step of the installation:

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/7/6/76670c166ad583a9ea3b3d219613abe44f41858a.png)

---

<div class="post-metadata">

**Author:** ![gabrielribcesario](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/gabrielribcesario/32/38927_2.png) [@gabrielribcesario](https://root-forum.cern.ch/u/gabrielribcesario)\
**Post date:** [August 5, 2024, 1:49pm UTC](https://root-forum.cern.ch/t/unable-to-run-garfields-gemgpu-example/60413/5 "2024-08-05T13:49:18Z")

</div>

I was able to work around the error by installing the pip version of CMake (I was previously using the apt one). I ended up getting the same error as the one from my 1st post (thrust::system::system\_error during the stack data transfer).

However, adding the `-DCMAKE_CUDA_ARCHITECTURES=native` flag during the `cmake` step of the Garfield installation caused something different to happen:

![image](https://root-forum.cern.ch/uploads/default/original/3X/8/d/8d1a662d0e09a4b5c88fa5cac4253ac38c3ea58b.png)

The executable was able to complete the stack transfer, but the terminal has been stuck like this for a few minutes now. I opened a second terminal, ran the executable and then closed the terminal. I was able to observe a drop in GPU usage:

![image](https://root-forum.cern.ch/uploads/default/original/3X/e/d/ed27a04ea96cd68b688c69656e6ca276656ef38e.png)

**Last minute edit:** Alright, the example seems to be running normally, its just **really** slow compared to my CPU. When using `nInitElectrons = 10000` the CPU is still a lot faster than the GPU, about twice as fast. Perhaps I’m missing something?

---

<div class="post-metadata">

**Author:** ![tomneep](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/tomneep/32/37233_2.png) [@tomneep](https://root-forum.cern.ch/u/tomneep)\
**Post date:** [August 5, 2024, 2:49pm UTC](https://root-forum.cern.ch/t/unable-to-run-garfields-gemgpu-example/60413/6 "2024-08-05T14:49:42Z")

</div>

Hi @gabrielribcesario,

What GPU model do you have?

---

<div class="post-metadata">

**Author:** ![gabrielribcesario](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/gabrielribcesario/32/38927_2.png) [@gabrielribcesario](https://root-forum.cern.ch/u/gabrielribcesario)\
**Post date:** [August 5, 2024, 3:47pm UTC](https://root-forum.cern.ch/t/unable-to-run-garfields-gemgpu-example/60413/7 "2024-08-05T15:47:17Z")

</div>

GPU: NVIDIA GeForce RTX 3090 (24GB)  
CPU: Intel(R) Core™ i9-10980XE CPU @ 3.00GHz

---

<div class="post-metadata">

**Author:** ![tomneep](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/tomneep/32/37233_2.png) [@tomneep](https://root-forum.cern.ch/u/tomneep)\
**Post date:** [August 5, 2024, 4:19pm UTC](https://root-forum.cern.ch/t/unable-to-run-garfields-gemgpu-example/60413/8 "2024-08-05T16:19:18Z")

</div>

Thanks. This isn’t a model we’ve tested before so it is interesting to see your results. Looking at the `List_of_Nvidia_graphics_processing_units` wikipedia page (sorry I can’t post links) it seems that double precision performance isn’t as good for the 3090s as for the typical data centre GPUs we’ve been testing (e.g. an A100 is listed as having 10 TFLOPS at double precision compared with vs 0.5 TFLOPS for the 3090).

We originally had the option to run calculations at single precision but that feature was lost in development. It might be interesting to try and resurrect it for cases like this.

---

<div class="post-metadata">

**Author:** ![gabrielribcesario](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/gabrielribcesario/32/38927_2.png) [@gabrielribcesario](https://root-forum.cern.ch/u/gabrielribcesario)\
**Post date:** [August 5, 2024, 4:46pm UTC](https://root-forum.cern.ch/t/unable-to-run-garfields-gemgpu-example/60413/9 "2024-08-05T16:46:30Z")

</div>

Ah, I see! Yeah, that makes sense, this GPU is pretty good for Machine Learning tasks, as they generally use single precision, a shame I can’t use it to accelerate the Avalanche calculations. It looks like I’ll have to make do with the CPU + OpenMP for the time being.

Anyway, thank you both for your help @tomneep @hschindl !

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [August 19, 2024, 4:47pm UTC](https://root-forum.cern.ch/t/unable-to-run-garfields-gemgpu-example/60413/10 "2024-08-19T16:47:14Z")

</div>

Closed on August 19, 2024, 4:47pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
