So I’ve been trying to get Numba working with RDataFrame, and I’ve failed to set up the right environment somehow. Here is an example that demonstrates the problem;
import ROOT
print("jit a function")
@ROOT.Numba.Declare(['int'], 'int')
def simple_func(inp):
print(inp)
return 2*inp
print("Use the function")
ROOT.Numba.simple_func(5)
In reality, I need to use it in RDataFrame that’s running on PHYSLITE data, given which my current environment is;
setupATLAS
asetup 22.0.77 Athena
but trying to run the python snippet with that environment gives the error;
/ROOT/6.24.06a/x86_64-centos7-gcc11-opt/lib/ROOT/_facade.py", line 150, in _importhook
return _orig_ihook(name, *args, **kwds)
ModuleNotFoundError: No module named 'numba'
Full error
Traceback (most recent call last):
File "/cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_20/ROOT/6.24.06a/x86_64-centos7-gcc11-opt/lib/ROOT/_numbadeclare.py", line 28, in _NumbaDeclareDecorator
import numba as nb
File "/cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_20/ROOT/6.24.06a/x86_64-centos7-gcc11-opt/lib/ROOT/_facade.py", line 150, in _importhook
return _orig_ihook(name, *args, **kwds)
ModuleNotFoundError: No module named 'numba'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_20/ROOT/6.24.06a/x86_64-centos7-gcc11-opt/lib/ROOT/_numbadeclare.py", line 30, in _NumbaDeclareDecorator
raise Exception('Failed to import numba')
So it seems a basic Athena setup doesn’t come with numba. Instead I tried just loading root and numba directly from lcg, in a fresh session;
export LCGENV_PATH=/cvmfs/sft.cern.ch/lcg/releases
export PATH=/cvmfs/sft.cern.ch/lcg/releases/lcgenv/latest:${PATH}
eval "`lcgenv -p LCG_101 x86_64-centos7-gcc11-opt ROOT`"
eval "`lcgenv -p LCG_101 x86_64-centos7-gcc11-opt numba 0.51.2`"
well now import numba
and import ROOT
both work, which seems like a step in the right direction. I’m going to have other issues when I need to do ROOT.xAOD.Init()
, but I will solve that problem later. However, if I run the snippet at the top a new error appears;
Exception ignored in: '<numba.core.cpu.CPUContext object at 0x7f46cc5a40a0>'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: missing Environment: _ZN08NumbaEnv4ROOT13_numbadeclare13pywrapper$242Ei
0
So I’m still missing something, but this time I’m not clear what is missing. Any tips for where to look based on that error?
ROOT Version: 6.24/06
Platform: NAME=“CentOS Linux” VERSION=“7 (Core)” ID_LIKE=“rhel fedora” CLUSTER=“sunrise”
Compiler: using pyroot