# Building problem with GPU

**URL:** <https://root-forum.cern.ch/t/building-problem-with-gpu/64902>\
**Category:** Garfield++\
**Created:** [June 15, 2026, 8:31am UTC](https://root-forum.cern.ch/t/building-problem-with-gpu/64902 "2026-06-15T08:31:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![katoy](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/8e8cbc/32.png) [@katoy](https://root-forum.cern.ch/u/katoy)\
**Post date:** [June 15, 2026, 8:31am UTC](https://root-forum.cern.ch/t/building-problem-with-gpu/64902/1 "2026-06-15T08:31:43Z")

</div>

I’m trying to build Garfield (master blanch) with GPU in my PC(AlmaLinux10.2). My PC has already installed ROOT v6.36.04 and v6.40.00 . When I build Garfield, the below message showed and can’t build it.

$cmake -Dcuda=ON ..

Check for working CUDA compiler: /usr/local/cuda/bin/nvcc - skipped  
– Detecting CUDA compile features  
– Detecting CUDA compile features - done

$make

Loading from the following files: …/AvalancheMicroscopicGPU.cu:19:  
../garfieldpp-master/Include/Garfield/RandomEngineRoot.hh:

4:10: Fatal error: TRandom3.h: No such file or directory  
4 | #include \<TRandom3.h\>

Trandom3.h is only included in Garfield/RandomEngineRoot.hh.

I can build Garfield without GPU.

Could you help to build Garfield with GPU?

---

<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:** [June 16, 2026, 8:42am UTC](https://root-forum.cern.ch/t/building-problem-with-gpu/64902/2 "2026-06-16T08:42:09Z")

</div>

Hi,  
thanks a lot for your message! Could you try adding a line

```auto
target_include_directories(GarfieldGPU PRIVATE ${ROOT_INCLUDE_DIRS})

```

in `CMakeLists.txt` just before

```auto
target_compile_definitions(GarfieldGPU PRIVATE USEGPU)
endif()

```

Let me know if this works!

---

<div class="post-metadata">

**Author:** ![katoy](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/8e8cbc/32.png) [@katoy](https://root-forum.cern.ch/u/katoy)\
**Post date:** [June 16, 2026, 9:45am UTC](https://root-forum.cern.ch/t/building-problem-with-gpu/64902/3 "2026-06-16T09:45:46Z")

</div>

Thank you for your answers.

I add a below line in CMakeLists.txt

target\_include\_directories(GarfieldGPU PRIVATE ${ROOT\_INCLUDE\_DIRS})

just before

target\_compile\_definitions(Garfield PRIVATE BOOL:${GARFIELD\_WITH\_CUDA}:USEGPU\>)

After then, I can build Garfield++ without errors (although there are many warnings).

I haven’t tested yet whether the program works correctly.

But I can’t find below lines

target\_compile\_definitions(GarfieldGPU PRIVATE USEGPU)  
endif()

I can find

if(GARFIELD\_CUDA\_USE\_FLOAT)  
target\_compile\_definitions(Garfield PRIVATE GARFIELD\_CUDA\_USE\_FLOAT)  
endif()

Thank you very much!

---

<div class="post-metadata">

**Author:** ![katoy](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/8e8cbc/32.png) [@katoy](https://root-forum.cern.ch/u/katoy)\
**Post date:** [June 17, 2026, 9:18am UTC](https://root-forum.cern.ch/t/building-problem-with-gpu/64902/4 "2026-06-17T09:18:28Z")

</div>

Hi,

When the command

target\_include\_directories(GarfieldGPU PRIVATE ${ROOT\_INCLUDE\_DIRS})

is put on just before

```auto
target_include_directories(GarfieldGPU PRIVATE ${ROOT_INCLUDE_DIRS})	    

```

I can’t build garfield without GARFIELD\_WITH\_CUDA option

I modified to the below commands

if(GARFIELD\_WITH\_CUDA)  
target\_include\_directories(GarfieldGPU PRIVATE ${ROOT\_INCLUDE\_DIRS})  
endif()

Then I can build Garfield with and without GARFIELD\_WITH\_CUDA option.

However, I haven’t tested yet whether the program works correctly.

Thank you.

---

<div class="post-metadata">

**Author:** ![katoy](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/8e8cbc/32.png) [@katoy](https://root-forum.cern.ch/u/katoy)\
**Post date:** [June 24, 2026, 5:59am UTC](https://root-forum.cern.ch/t/building-problem-with-gpu/64902/5 "2026-06-24T05:59:39Z")

</div>

Hi, Heinrich Schindler,

I misunderstood your suggestion. Your suggestion is the line

```auto
target_include_directories(GarfieldGPU PRIVATE ${ROOT_INCLUDE_DIRS})

```

put in GPU/CMakeLists.txt. But I put this line in CMakeLists.txt on top directory.

Since you already modified GPU/CMakeLists.txt on master Branch, I tried to

build to the master Branch with GARFILED\_WITH\_CUDA option. But I can’t

build it because of same error message in below,

Loading from the following files: …/AvalancheMicroscopicGPU.cu:19:  
../garfieldpp-master/Include/Garfield/RandomEngineRoot.hh:

4:10: Fatal error: TRandom3.h: No such file or directory  
4 | #include \<TRandom3.h\>

Could you help to solve this problem?

---

<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:** [July 8, 2026, 5:59am UTC](https://root-forum.cern.ch/t/building-problem-with-gpu/64902/6 "2026-07-08T05:59:46Z")

</div>

Closed on July 8, 2026, 5:59am UTC

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