katoy
June 15, 2026, 8:31am
1
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?
Hi,
thanks a lot for your message! Could you try adding a line
target_include_directories(GarfieldGPU PRIVATE ${ROOT_INCLUDE_DIRS})
in CMakeLists.txt just before
target_compile_definitions(GarfieldGPU PRIVATE USEGPU)
endif()
Let me know if this works!
katoy
June 16, 2026, 9:45am
3
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!
katoy
June 17, 2026, 9:18am
4
Hi,
When the command
target_include_directories(GarfieldGPU PRIVATE ${ROOT_INCLUDE_DIRS})
is put on just before
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.
katoy
June 24, 2026, 5:59am
5
Hi, Heinrich Schindler,
I misunderstood your suggestion. Your suggestion is the line
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?