# How to use CUDA for AvlancheMC

**URL:** <https://root-forum.cern.ch/t/how-to-use-cuda-for-avlanchemc/64052>\
**Category:** Garfield++\
**Created:** [August 20, 2025, 3:25am UTC](https://root-forum.cern.ch/t/how-to-use-cuda-for-avlanchemc/64052 "2025-08-20T03:25:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Migu](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/b487fb/32.png) [@Migu](https://root-forum.cern.ch/u/Migu)\
**Post date:** [August 20, 2025, 3:25am UTC](https://root-forum.cern.ch/t/how-to-use-cuda-for-avlanchemc/64052/1 "2025-08-20T03:25:08Z")

</div>

Hello,

I have found that the current Garfield++supports the use of CUDA.

I want to use CUDA to accelerate running `AvalancheMC`, and I would like to know if any examples can help me.

---

<div class="post-metadata">

**Author:** ![Migu](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/b487fb/32.png) [@Migu](https://root-forum.cern.ch/u/Migu)\
**Post date:** [August 20, 2025, 3:40am UTC](https://root-forum.cern.ch/t/how-to-use-cuda-for-avlanchemc/64052/2 "2025-08-20T03:40:42Z")

</div>

To avoid creating an additional discussion, I have another question here：

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

When using TrackSrim, I encountered an error message above.

---

<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 20, 2025, 4:29am UTC](https://root-forum.cern.ch/t/how-to-use-cuda-for-avlanchemc/64052/3 "2025-08-20T04:29:30Z")

</div>

Hi,

I’m afraid there is no GPU version of `AvalancheMC`at the moment.

Regarding the crash: can you provide a **minimal working example** that reproduces the issue?

---

<div class="post-metadata">

**Author:** ![Migu](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/b487fb/32.png) [@Migu](https://root-forum.cern.ch/u/Migu)\
**Post date:** [August 20, 2025, 7:37am UTC](https://root-forum.cern.ch/t/how-to-use-cuda-for-avlanchemc/64052/4 "2025-08-20T07:37:59Z")

</div>

Hello，

Thanks for your reply.

I can run this program in my original environment using the latest version of Garfield++and ROOT 6.36, but I found that the program executes very slowly, and even if I wait for a few hours, I cannot calculate the first cluster. So I wanted to run this program in another old version of the Garfield++environment, and then I encountered the error mentioned earlier.

I am using WSL, and I checked the total CPU usage in Windows while I was running the program:

 ![1755588559617](https://root-forum.cern.ch/uploads/default/original/3X/c/5/c5ba20a39a6b5d62ad24c05e8a2277cd14e735a2.png)

It shows that the total CPU utilization is only 10%. I have allocated resources for my WSL, and my server has 64 logical processors. But I still have a slower running speed compared to others in this discussion.

[https://root-forum.cern.ch/t/signal-question/63443/14](https://root-forum.cern.ch/t/signal-question/63443/14)

The code and parameters I used are consistent with those discussed in the link.

Here is the code and corresponding files. Thank you in advance for your help.

[mre.zip](https://root-forum.cern.ch/uploads/short-url/iyN2hP2PBQ7sKkj5GHusFCwzWP2.zip) (12.8 KB)

---

<div class="post-metadata">

**Author:** ![Migu](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/b487fb/32.png) [@Migu](https://root-forum.cern.ch/u/Migu)\
**Post date:** [August 21, 2025, 6:43am UTC](https://root-forum.cern.ch/t/how-to-use-cuda-for-avlanchemc/64052/5 "2025-08-21T06:43:03Z")

</div>

This issue is caused by an error in Garfield++calling ROOT.

I solved this problem by changing the environment variable configuration of ROOT.

But I still face the problem of slow `AvalancheMC` computation, even with dynamic `OpenMP`.

---

<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 31, 2025, 1:14pm UTC](https://root-forum.cern.ch/t/how-to-use-cuda-for-avlanchemc/64052/6 "2025-08-31T13:14:04Z")

</div>

Hi,

out of curiosity: what was the error?

As discussed in a previous thread, I would recommend using `DriftLineRKF` instead of `AvalancheMC`for your application.

---

<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 31, 2025, 3:29pm UTC](https://root-forum.cern.ch/t/how-to-use-cuda-for-avlanchemc/64052/7 "2025-08-31T15:29:30Z")

</div>

Hello,

This seems to be the same error I’ve reported [here](https://root-forum.cern.ch/t/segmentation-violation-when-plotting-with-garfield/64072). Can you try reverting your Garfield installation back to [commit 101dfdae](https://gitlab.cern.ch/garfield/garfieldpp/-/commit/101dfdae5c7d71b8112750a3ea05f1d4310bdf7c) and see if it persists? I’d recommend deleting everything inside the build directory when doing so, or at least the CMake generated files (e.g. CMake cache, etc.).

---

<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:** [September 14, 2025, 3:30pm UTC](https://root-forum.cern.ch/t/how-to-use-cuda-for-avlanchemc/64052/8 "2025-09-14T15:30:30Z")

</div>

Closed on September 14, 2025, 3:30pm UTC

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