RuntimeError: missing Environment: _ZN08NumbaEnv4ROOT13_ numbadeclare13pywrapper$242Ei

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


It seems the issue is actually related to having a print statement in the jitted code! It’s the same problem as this bug report; "RuntimeError: missing Environment" using print in second call to cached numba function · Issue #3555 · numba/numba · GitHub

The environment was fine, actually, I can get ROOT out of the Athena setup and it’s still fine. So, putting everything together, my setup is;

setupATLAS
asetup Athena 22.0.77
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 numba 0.51.2`"

Then I can run;

import ROOT
ROOT.xAOD.Init()
r_frame = ROOT.RDataFrame("CollectionTree", "DAOD_PHYSLITE.root")
print("jit a function")
@ROOT.Numba.Declare(['int'], 'int')
def simple_func(inp):
    return 2*inp
print("Use on a data frame")
r_frame2 = r_frame.Define('simple', 'Numba::simple_func(2)')
r_frame2.Mean('simple').GetValue()

Hopefully this helps someone else, because it took a while to figure out what was breaking things.
Also, I guess a newer version of numba would remove this bug, but this is the only one I have on lcg right now.

1 Like

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