Incompatibility between ROOT and TensorFlow?

I have a problem when trying to use both ROOT and TensorFlow in Python scripts. When I install ROOT by itself, it seems to work fine, and I can do import root in the Python interpreter. Similarly, when I install Tensorflow by itself, I can do import tensorflow and run tensorflow’s test scripts with no issue. However, when I try to setup root and also tensorflow at the same time, I get confusing errors.

More specifically, here are the steps to reproduce and the resulting errors:

ssh elehrer@cmslpc-sl6.fnal.gov
source /cvmfs/cms.cern.ch/cmsset_default.sh
cd nobackup/CMSSW_9_4_0/src
cmsenv
source /cvmfs/sft.cern.ch/lcg/views/LCG_89/x86_64-slc6-gcc62-opt/setup.sh
source activate tensorflow

gives the error

Traceback (most recent call last):
  File "/uscms/home/elehrer/miniconda2/bin/conda", line 7, in <module>
    from conda.cli import main
ImportError: No module named conda.cli

which does not occur if I simply source activate tensorflow without having run setup.sh first.

Alternatively, if I first activate my tensorflow environment then run setup.sh, i.e. I do

ssh elehrer@cmslpc-sl6.fnal.gov
source activate tensorflow
source /cvmfs/cms.cern.ch/cmsset_default.sh
cd nobackup/CMSSW_9_4_0/src
cmsenv
source /cvmfs/sft.cern.ch/lcg/views/LCG_89/x86_64-slc6-gcc62-opt/setup.sh
python -c "import tensorflow as tf"

then Python outputs “Illegal instruction” and exits, not allowing me to use TensorFlow.
Alternatively, if I do as the last line python -c "import root" then I get

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named root

even though root is set up.

Any and all help would be greatly appreciated! I have no idea what is causing this issue, much less how to fix it.


ROOT Version: 6.10/02, Built for linuxx8664gcc
Platform: Linux cmslpc36.fnal.gov 2.6.32-696.23.1.el6.x86_64 #1 SMP Tue Mar 13 17:46:31 CDT 2018 x86_64 x86_64 x86_64 GNU/Linux
Compiler: gcc (GCC) 6.2.0


Hi, from the errors described above, you installed tensorflow and ROOT for different versions of Python, so you can only import one of them at a time. Please try to setup tensorflow, then configure and install ROOT with cmake $SRCDIR -Dpython=ON -DPYTHON_EXECUTABLE=$(which python). This will let you compile ROOT against the python used by tensorflow, so you will be able both together. Just make sure you use the same compiler (or a compatible one) that was used to compile Python itself, otherwise, ROOT won’t be able to link to the Python libraries if there are ABI incompatibilities between the compilers. I hope this solves your problem. Cheers,

Thank you for the suggestion. Now, though, 51% of the way through cmake a different occur has come up.

[ 51%] Building CXX object math/mathcore/CMakeFiles/MathCore.dir/src/MixMaxEngine.cxx.o
In file included from /uscms/home/elehrer/nobackup/keras-training/root/math/mathcore/src/MixMaxEngine.cxx:19:0:
/uscms/home/elehrer/nobackup/keras-training/root/math/mathcore/src/mixmax.h:107:23: error: exponent has no digits
 #define INV_MERSBASE (0x1p-61)
                       ^
/uscms/home/elehrer/nobackup/keras-training/root/math/mathcore/src/mixmax.h:171:17: note: in expansion of macro 'INV_MERSBASE'
        return Z*INV_MERSBASE;
                 ^~~~~~~~~~~~
math/mathcore/CMakeFiles/MathCore.dir/build.make:1013: recipe for target 'math/mathcore/CMakeFiles/MathCore.dir/src/MixMaxEngine.cxx.o' failed
gmake[2]: *** [math/mathcore/CMakeFiles/MathCore.dir/src/MixMaxEngine.cxx.o] Error 1
CMakeFiles/Makefile2:12066: recipe for target 'math/mathcore/CMakeFiles/MathCore.dir/all' failed
gmake[1]: *** [math/mathcore/CMakeFiles/MathCore.dir/all] Error 2
Makefile:136: recipe for target 'all' failed
gmake: *** [all] Error 2

Nevermind. Your suggestion worked perfectly! Thank you!

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