Error with TMVA sofie

Whenever I try to run
sayang@DESKTOP-IFS80HM:~/root_src/tutorials/tmva$ root TMVA_SOFIE_ONNX.C
its showing:
/home/sayang/root_src/tutorials/tmva/TMVA_SOFIE_ONNX.C:15:12: error: no type named ‘RModelParser_ONNX’ in namespace ‘TMVA::Experimental::SOFIE’
SOFIE::RModelParser_ONNX Parser;

Also in case of TMVA_SOFIE_Keras.C its showing :

Processing TMVA_SOFIE_Keras.C…
Traceback (most recent call last):
File “”, line 4, in
import numpy as np
ImportError: No module named numpy
terminate called after throwing an instance of ‘std::runtime_error’
what(): Model file KerasModel.h5 not found!

I have installed keras , numpy (pip install numpy),but its only happening with the tmva-sofie files. Although I have built root with(-Dtmva-sofie=on)Other tmva files are running fine. Thanks!

I think @moneta can help you.


You need to have the support for tmva-sofie. It is not enough to do at configure time (-Dtmva-sofie=On), you need also to give a compatible protobuf version. For example in my case I configured root with:

cmake ../root  -Drmva-sofie=On -D/Users/moneta/external/protobuf-3.19.4/lib/libprotobuf.a


Thanks , TMVA_SOFIE_ONNX.C is now running but TMVA_SOFIE_PyTorch.C and same with keras are still showing error, although I installed numpy(pip install numpy) and keras(pip install keras). My protobuf version is 3.6.1.

It is possible that ROOT uses a different python version and it does not find Numpy. Do you see tmva-pymva in the list given by cmake when configuring ?


Yes, tmva-pymva is present in root-config --features, but I coudn’t find it while configuring

regarding python version, it showed the following during configuring…
Could NOT find Python2 (missing: Python2_NumPy_INCLUDE_DIRS NumPy) (found version “2.7.18”)

Ok, then ROOT is using probably python3. Do you have PyTorch installed for Python3 ?
What is the default Python in your system (when you type python --version ) ?

Hi @moneta ,
sayang@DESKTOP-IFS80HM:~/root_src/tutorials$ python --version
Python 2.7.18

I have also installed Pytorch earlier(pip install torch), which is running successfully for other tmva files except sofie.

Can you please post the log you have when running TMVA_SOFIE_PyTorch.C ?

Processing TMVA_SOFIE_PyTorch.C…
Traceback (most recent call last):
File “”, line 1, in
import torch
ImportError: No module named torch
terminate called after throwing an instance of ‘std::runtime_error’
what(): Model file not found!

It looks to me that the error is due to a missing PyTorch installation.

Please suggest any way to solve this as it is only happening with TMVASofie-Pytorch and TMVASofie-Keras. Even TMVA-ONNX is running fine. Thanks!

What is happening if you do this (outside ROOT) ?

>>> import torch
>>> print(torch.__version__)

sayang@DESKTOP-IFS80HM:~/root_src/tutorials/dataframe$ python3
Python 3.8.10 (default, Jun 2 2021, 10:49:15)
[GCC 9.4.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import torch

sayang@DESKTOP-IFS80HM:~/root_src/tutorials/dataframe$ python
Python 2.7.18 (default, Mar 8 2021, 13:02:45)
[GCC 9.3.0] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.

import torch
Traceback (most recent call last):
File “”, line 1, in
ImportError: No module named torch

This is the problem, you have PyTorch installed only for python3. What you should do is to edit the script
TMVA_SOFIE_PyTorch and TMVA_SOFIE_Keras and replace the line:





1 Like

Thanks a lot for your help!