# Error with TMVA sofie

**URL:** <https://root-forum.cern.ch/t/error-with-tmva-sofie/49188>\
**Category:** TMVA\
**Created:** [March 15, 2022, 9:49am UTC](https://root-forum.cern.ch/t/error-with-tmva-sofie/49188 "2022-03-15T09:49:34Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sayandeep\_Ghosh](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sayandeep_ghosh/32/29173_2.png) [@Sayandeep\_Ghosh](https://root-forum.cern.ch/u/Sayandeep_Ghosh)\
**Post date:** [March 15, 2022, 9:49am UTC](https://root-forum.cern.ch/t/error-with-tmva-sofie/49188/1 "2022-03-15T09:49:34Z")

</div>

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 “make\_keras\_model.py”, 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!

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [March 15, 2022, 10:09am UTC](https://root-forum.cern.ch/t/error-with-tmva-sofie/49188/2 "2022-03-15T10:09:40Z")

</div>

I think @moneta can help you.

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [March 15, 2022, 11:30am UTC](https://root-forum.cern.ch/t/error-with-tmva-sofie/49188/3 "2022-03-15T11:30:14Z")

</div>

Hello,

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:

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

```

Lorenzo

---

<div class="post-metadata">

**Author:** ![Sayandeep\_Ghosh](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sayandeep_ghosh/32/29173_2.png) [@Sayandeep\_Ghosh](https://root-forum.cern.ch/u/Sayandeep_Ghosh)\
**Post date:** [March 15, 2022, 12:30pm UTC](https://root-forum.cern.ch/t/error-with-tmva-sofie/49188/4 "2022-03-15T12:30:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [March 15, 2022, 1:35pm UTC](https://root-forum.cern.ch/t/error-with-tmva-sofie/49188/5 "2022-03-15T13:35:46Z")

</div>

Hi,  
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 ?

Lorenzo

---

<div class="post-metadata">

**Author:** ![Sayandeep\_Ghosh](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sayandeep_ghosh/32/29173_2.png) [@Sayandeep\_Ghosh](https://root-forum.cern.ch/u/Sayandeep_Ghosh)\
**Post date:** [March 15, 2022, 1:38pm UTC](https://root-forum.cern.ch/t/error-with-tmva-sofie/49188/6 "2022-03-15T13:38:12Z")

</div>

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”)

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [March 15, 2022, 2:09pm UTC](https://root-forum.cern.ch/t/error-with-tmva-sofie/49188/7 "2022-03-15T14:09:57Z")

</div>

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` ) ?

---

<div class="post-metadata">

**Author:** ![Sayandeep\_Ghosh](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sayandeep_ghosh/32/29173_2.png) [@Sayandeep\_Ghosh](https://root-forum.cern.ch/u/Sayandeep_Ghosh)\
**Post date:** [March 15, 2022, 2:15pm UTC](https://root-forum.cern.ch/t/error-with-tmva-sofie/49188/8 "2022-03-15T14:15:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [March 15, 2022, 3:04pm UTC](https://root-forum.cern.ch/t/error-with-tmva-sofie/49188/9 "2022-03-15T15:04:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Sayandeep\_Ghosh](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sayandeep_ghosh/32/29173_2.png) [@Sayandeep\_Ghosh](https://root-forum.cern.ch/u/Sayandeep_Ghosh)\
**Post date:** [March 15, 2022, 3:43pm UTC](https://root-forum.cern.ch/t/error-with-tmva-sofie/49188/10 "2022-03-15T15:43:45Z")

</div>

Processing TMVA\_SOFIE\_PyTorch.C…  
Traceback (most recent call last):  
File “make\_pytorch\_model.py”, line 1, in   
import torch  
ImportError: No module named torch  
terminate called after throwing an instance of ‘std::runtime\_error’  
what(): Model file PyTorchModel.pt not found!

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [March 15, 2022, 10:19pm UTC](https://root-forum.cern.ch/t/error-with-tmva-sofie/49188/11 "2022-03-15T22:19:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Sayandeep\_Ghosh](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sayandeep_ghosh/32/29173_2.png) [@Sayandeep\_Ghosh](https://root-forum.cern.ch/u/Sayandeep_Ghosh)\
**Post date:** [March 16, 2022, 5:40am UTC](https://root-forum.cern.ch/t/error-with-tmva-sofie/49188/12 "2022-03-16T05:40:07Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [March 16, 2022, 8:06am UTC](https://root-forum.cern.ch/t/error-with-tmva-sofie/49188/13 "2022-03-16T08:06:51Z")

</div>

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

```auto
python
>>> import torch
>>> print(torch. __version__ )

```

---

<div class="post-metadata">

**Author:** ![Sayandeep\_Ghosh](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sayandeep_ghosh/32/29173_2.png) [@Sayandeep\_Ghosh](https://root-forum.cern.ch/u/Sayandeep_Ghosh)\
**Post date:** [March 16, 2022, 9:00am UTC](https://root-forum.cern.ch/t/error-with-tmva-sofie/49188/14 "2022-03-16T09:00:21Z")

</div>

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  
> > > print(torch. **version** )  
> > > 1.10.2+cu102

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

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [March 16, 2022, 9:33am UTC](https://root-forum.cern.ch/t/error-with-tmva-sofie/49188/15 "2022-03-16T09:33:44Z")

</div>

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:

```auto
gSystem->Exec("python make_pytorch_model.py");

```

with

```auto
gSystem->Exec("python3 make_pytorch_model.py");

```

Lorenzo

---

<div class="post-metadata">

**Author:** ![Sayandeep\_Ghosh](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sayandeep_ghosh/32/29173_2.png) [@Sayandeep\_Ghosh](https://root-forum.cern.ch/u/Sayandeep_Ghosh)\
**Post date:** [March 16, 2022, 9:36am UTC](https://root-forum.cern.ch/t/error-with-tmva-sofie/49188/16 "2022-03-16T09:36:28Z")

</div>

Thanks a lot for your help!
