Possible to Partial Import Functionality into PyROOT?

Hello everyone,
Is it possible to ignore certain parts of the ROOT library when importing PyRoot.

I created a shared library that can run Cuda code. I downloaded ROOT via conda-forge which does not have the cuda flag turned on for the built binaries, resulting in roofit / tmva performing a typedef that clashes with a typedef that cuda’s driver_types.h performs in my code when loading my shared library.
I tried to do from ROOT import foo and it still appears roofit tags along. Is there any way to remove RooFit for the import?


1 Like

Hi @lan13005,
Thanks for reaching out!
First of all, can you post the error you get? At the moment, there is no way of removing RooFit from your import. A solution for your problem could be to build ROOT from source enabling CUDA support, but maybe @jonas can suggest an easier solution your you.


Hi @Ian13005!

Monica is right, there is no way to do partial imports.

What is the redefinition error exactly? I have fixed a few of those recently, can you check if the problem is still present with the ROOT master?

You can get a recent ROOT development version for example by sourcing the nightlies from cvmfs:

An alternative is to build from source.


Its kind of tricky to test since I don’t have a GPU. I am using the GPUs at our lab and our software is old, supporting only up to 6.24. I gave up trying to build root from source without sudo permissions so I tried conda-forging it. Unfortunately our nvidia drivers here at the lab only support up to 6.26 (as ROOT 6.28 conda binaries are bundled with a too-new version of gcc). I think I have to talk with our sys admins to see where to take this.

Anyways, as for the typedef redefinition. The library I import includes cuda_runtime.h which in turn includes builtin_types.h. The first offender I run into is from RooBatchComputeTypes.h which performs another typedef based on a preprocessor directive for cuda. If I were to build from source with CUDA turned I, in theory this should work.

/apps/cuda/11.4.2//include/driver_types.h:2763:48: error: typedef redefinition with different types (‘struct CUstream_st *’ vs ‘cudaStream_t’)
typedef device_builtin struct CUstream_st *cudaStream_t;
/w/halld-scshelf2101/lng/Mambaforge/envs/PyAmpTools/include/RooBatchComputeTypes.h:29:8: note: previous definition is here
struct cudaStream_t;

/apps/cuda/11.4.2//include/driver_types.h:2768:47: error: typedef redefinition with different types (‘struct CUevent_st *’ vs ‘cudaEvent_t’)
typedef device_builtin struct CUevent_st *cudaEvent_t;
/w/halld-scshelf2101/lng/Mambaforge/envs/PyAmpTools/include/RooBatchComputeTypes.h:28:8: note: previous definition is here
struct cudaEvent_t;

Interestingly I tried adding these cmake flags (as lined out in roots build from source wiki) during the build process and I still get the typedef redefinition

export EXTRA_CMAKE_FLAGS="-Dcuda=On

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