RegressionKeras example

Dear experts,
I would like to run this example:
https://root.cern.ch/doc/v622/RegressionKeras_8py_source.html

On lxplus I did:

source /cvmfs/sft.cern.ch/lcg/views/LCG_98python3/x86_64-centos7-gcc8-opt/setup.sh
[mtesta@lxplus759 ML_setup]$ python
Python 3.7.6 (default, Aug 12 2020, 09:46:40)
[GCC 8.3.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

from ROOT import TMVA, TFile, TTree, TCut

It’s stuck here. The culprit seems “from ROOT import TFile”

Am I doing something wrong in the setup?

Is there an instruction how to run this example?

Best, Marianna.

Hi Marianna,
on lxplus it can take a while to read the files from CMVS that are required to import ROOT – a while as in, 30 seconds max, and typically only the first time you run that script.

I just tried myself:

[eguiraud@lxplus727 ~]$ source /cvmfs/sft.cern.ch/lcg/views/LCG_98python3/x86_64-centos7-gcc8-opt/setup.sh
[eguiraud@lxplus727 ~]$ python
Python 3.7.6 (default, Aug 12 2020, 09:46:40) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ROOT import TMVA
>>> from ROOT import TFile
Error in <RootX11ErrorHandler>: BadAccess (attempt to access private resource denied) (XID: 418, XREQ: 18)
>>> 

That last error message should not be there, there is something wrong with this LCG view.

To work around the issue you can use a different LCG view, e.g. /cvmfs/sft.cern.ch/lcg/views/LCG_99/x86_64-centos7-gcc8-opt/setup.sh works.

I’ll report the problem with LCG_98python3 upstream.

Cheers,
Enrico

Hi Enrico,
I find out that using the -Y option when connecting: ssh -Y lxplus.cern.ch
makes the `“from ROOT import TFile” command stucking, also with LCG_99
Can this be fixed?
Best, Marianna.

Uhm it goes through fine for me:

~ ssh -Y eguiraud@lxplus.cern.ch
Warning: Permanently added the ECDSA host key for IP address '188.185.91.62' to the list of known hosts.
Password: 
* ********************************************************************
* Welcome to lxplus7117.cern.ch, CentOS, 7.9.2009
* Archive of news is available in /etc/motd-archive
* Reminder: you have agreed to the CERN
*   computing rules, in particular OC5. CERN implements
*   the measures necessary to ensure compliance.
*   https://cern.ch/ComputingRules
* Puppet environment: production, Roger state: production
* Foreman hostgroup: lxplus/nodes/login
* Availability zone: cern-geneva-c
* LXPLUS Public Login Service - http://lxplusdoc.web.cern.ch/
* A C8 based lxplus8.cern.ch is now available
* Please read LXPLUS Privacy Notice in http://cern.ch/go/TpV7
* ********************************************************************
[eguiraud@lxplus7117 ~]$ source /cvmfs/sft.cern.ch/lcg/views/LCG_99/x86_64-centos7-gcc8-opt/setup.sh
[eguiraud@lxplus7117 ~]$ python
Python 3.8.6 (default, Dec 11 2020, 21:39:59) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ROOT import TFile
>>> 
>>> 

Not sure what might be happening :confused:

HI, may be it depends on my remote connection…

Could you please try to run the full file?
I get error
AttributeError: module ‘tensorflow’ has no attribute ‘get_default_graph’

(full log attached)log_regressionkeras.txt (1.6 KB)

Ah indeed, I can reproduce that one!

[eguiraud@lxplus700 ~]$ source /cvmfs/sft.cern.ch/lcg/views/LCG_99/x86_64-centos7-gcc8-opt/setup.sh
[eguiraud@lxplus700 ~]$ python $(root-config --tutdir)/tmva/keras/RegressionKeras.py
Using TensorFlow backend.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  110k  100  110k    0     0  14.2M      0 --:--:-- --:--:-- --:--:-- 15.4M
DataSetInfo              : [dataset] : Added class "Regression"
                         : Add Tree TreeR of type Regression with 10000 events
                         : Dataset[dataset] : Class index : 0  name : Regression
Traceback (most recent call last):
  File "/cvmfs/sft.cern.ch/lcg/releases/ROOT/v6.22.06-1d426/x86_64-centos7-gcc8-opt/tutorials/tmva/keras/RegressionKeras.py", line 51, in <module>
    model = Sequential()
  File "/cvmfs/sft.cern.ch/lcg/views/LCG_99/x86_64-centos7-gcc8-opt/lib/python3.8/site-packages/keras/engine/sequential.py", line 87, in __init__
    super(Sequential, self).__init__(name=name)
  File "/cvmfs/sft.cern.ch/lcg/views/LCG_99/x86_64-centos7-gcc8-opt/lib/python3.8/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
    return func(*args, **kwargs)
  File "/cvmfs/sft.cern.ch/lcg/views/LCG_99/x86_64-centos7-gcc8-opt/lib/python3.8/site-packages/keras/engine/network.py", line 96, in __init__
    self._init_subclassed_network(**kwargs)
  File "/cvmfs/sft.cern.ch/lcg/views/LCG_99/x86_64-centos7-gcc8-opt/lib/python3.8/site-packages/keras/engine/network.py", line 294, in _init_subclassed_network
    self._base_init(name=name)
  File "/cvmfs/sft.cern.ch/lcg/views/LCG_99/x86_64-centos7-gcc8-opt/lib/python3.8/site-packages/keras/engine/network.py", line 109, in _base_init
    name = prefix + '_' + str(K.get_uid(prefix))
  File "/cvmfs/sft.cern.ch/lcg/views/LCG_99/x86_64-centos7-gcc8-opt/lib/python3.8/site-packages/keras/backend/tensorflow_backend.py", line 74, in get_uid
    graph = tf.get_default_graph()
AttributeError: module 'tensorflow' has no attribute 'get_default_graph'

I’m not sure whether it’s a problem with the tutorial code or with the LCG release, we need @moneta .

Hello, any chance to have some help on that?
Best, Marianna.

Hi,

This is cause by an incompatibility between keras and tensorflow in LCG 99. With tensorflow 2 you need either to use keras 2.3 or tensorflow.keras (recommended solution).
We need to fix the tutorials in ROOT for tf.keras.

Best regards

Lorenzo