KNIME Keras Integration Issue

Dear All,

I am having trouble running the following KNIME deep learning example (02_Keras\04_Cats_and_Dogs\02_Train_simple_CNN) from the example server.

Specifically, something seems to be not working when trying to read back the network structure into KNIME. These are the messages that I am getting from the DL Python Network Creator Node:

WARN  PythonKernel                    Using TensorFlow backend.
WARN  PythonKernel                    2018-01-29 18:07:16.340358: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations.
WARN  PythonKernel                    2018-01-29 18:07:16.340358: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations.
WARN  PythonKernel                    2018-01-29 18:07:16.340358: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
WARN  PythonKernel                    2018-01-29 18:07:16.341358: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
WARN  PythonKernel                    2018-01-29 18:07:16.341358: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
WARN  PythonKernel                    2018-01-29 18:07:16.341358: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
WARN  PythonKernel                    2018-01-29 18:07:16.342358: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
WARN  PythonKernel                    2018-01-29 18:07:16.342358: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
ERROR DL Python Network Creator 3:222      Execute failed: An error occurred in Python: Traceback (most recent call last):
  File "C:\KNIME\plugins\org.knime.python2_3.5.0.v201712011355\py\PythonKernel.py", line 491, in execute
    exec(source_code, self._exec_env, self._exec_env)
  File "<string>", line 5, in <module>
  File "C:\KNIME\plugins\org.knime.dl.python_3.5.1.v201712211137\py\DLPythonNetworkSpecExtractor.py", line 89, in get_layer_data_specs_as_data_frame
    extractor = DLPythonNetworkSpecExtractor(network.spec)
  File "C:\KNIME\plugins\org.knime.dl.keras_3.5.1.v201712211137\py\DLKerasNetwork.py", line 140, in spec
    for node_idx in range(0, len(layer.inbound_nodes)):
AttributeError: 'Conv2D' object has no attribute 'inbound_nodes'

The script in the node executes fine, and returns an object as the network to be passed to KNIME. Something seems to happen as the network is being downloaded .

I have an Anaconda3 installation with python 3.5.4 and Keras 2.1.3. (Although I have tried Python 3.6.4 as well). I am new to Keras as well which might be a less than ideal situation concerning troubleshooting but I hope someone has an idea where these issues might be coming from.

Thanks!

Best regards,
Michal

 

 

Hi Michal,

Keras version 2.1.3 introduced breaking changes that are incompatible with the current version of the KNIME Deep Learning Keras integration. Downgrading Keras to version 2.1.2 should resolve the issue.

This will be fixed in a future version of KNIME Deep Learning. I added the issue to the list of known issues and updated the installation guide for the time being.

Thanks for reporting the problem!

Marcel

Hello,

I have succesfully managed to use the CPU version of Keras in Knime with Keras 2.1.2 and Tensorflow 1.2.1 in Python 3.6.4 with Anaconda.  

However on another machine with NVIDIA GPU I struggle a bit more with the GPU implementation cause then I need to install the corresponding CUDA and CUDNN version required by Tensorflow. Without Knime, only Python it worked with CUDA 9.0, CUDNN 7 then keras-gpu 2.1.3 and tensorflow-gpu 1.5.0.

But if I downgrade Keras to 2.1.2 then Tensorflow is also downgraded but then it throws an error when I import tensorflow in Python.

So can someone tell me which version of tensorflow-gpu to use, so I could try a clean installation of tensorflow before installing keras, cause apparently the best is to use pip install --upgrade tensorflow-gpu rather than anaconda.

Eventually what version of CUDA was used would be great too, thanks !

   

Me again coming back with a solution !

Apparently Keras 2.1.2 works with TensorFlow 1.1.0. However this version of TensorFlow is not available in Python 3.6.

So using Python 3.5 instead in anaconda, installing TensorFlow as pip install --upgrade tensorflow-gpu and keras-gpu with the graphical interface of Anaconda navigator this finally worked.

For CUDA according to the documentation for Tensorflow 1.1.0 I used CUDA 8.0 with CUDNN 5.1 (the one downloaded from NVIDIA website, I don't talk about the cudnn python package that is 6.0 for me). 

Wow, that was quick. Thanks for sharing your solution. Any further feedback his highly appreciated. :-)

Dear all,

I have installed the KNIME Python extension and Keras and I am also trying to work with the example 02_Keras\04_Cats_and_Dogs\02_Train_simple_CNN. While I am executing the node "DL Python Network Creator" I get the following import error: "No module named keras". Do you know how I can fix it?

In addition how can I check if the below dependencies are properly installed?

  • h5py
  • numpy (minimum version: 1.9.1)
  • pyyaml
  • scipy (minimum version: 0.14)
  • six (minimum version: 1.9.0)
  • tensorflow or tensorflow-gpu

Thank you!

Hi dimitra,

That sounds like KNIME is not using the correct conda environment. Can you make sure that the right one (i.e. the one where Keras is installed) is selected in the Python preferences (File > Preferences > KNIME > Python > Path to Python 3 executable)?

In addition how can I check if the below dependencies are properly installed?

Using the terminal/command line, you can check that by entering:

conda list -n my_conda_env

where my_conda_env is the name of the conda environment where Keras is installed and which is selected in the KNIME Python preferences.

Marcel

Dear Marcel,

Thank you very much for your answer. I checked the path in the Python preferences and it's the right one. I also checked the dependencies that are mentioned here: https://www.knime.com/deeplearning and they do not appear all on the list. How can I install the missing ones? Would you advise me to perform the whole procedure of the local Python installation?

 

Thank you very much,

Dimitra

Hi dimitra,

you can install the missing dependencies via:

conda install -n my_conda_env package=version

where, again, my_conda_env is the name of the conda environment where Keras is installed. package is the name of the package you want to install and version is the version of that package (e.g. conda install my_conda_env numpy=1.9.1 for installing numpy version 1.9.1). The version can be omitted but I recommend that you specify it as otherwise the most recent version of the package would be installed which probably would not match the one Keras requires.

To find out the versions Keras requires, use:

conda info keras=version

where version is the version of the installed Keras package (e.g. conda info keras=2.0.8 for Keras 2.0.8). This command will list several entries of the form keras version pyXX[..]. Look for the one where XX matches the Python version you use (e.g. keras 2.0.8 py35h4bddecc_0 for Python 3.5, don't mind the gibberish at the end).

In the end, it might be more convenient to go through the entire installation procedure from scratch (which shouldn't take too long either).

Hope this helps you :)

Marcel

Hello all,

I’ve tried KNIME with Keras and tensorflow and works as a charm with tensorflow backend. I’m interested in the image segmentation workflow, but I just started with the MNIST example as a test. I ran all the examples with tensorflow and they worked very well.

I prefer to use Keras with mxnet as a backend because it’s faster and uses less memory, however it seems that mxnet is not supported as a backed with KNIME, I haven’t been able to make any of the workflow examples work. Any thoughts?
Regards,
Jorge

Hi Jorge,

Unfortunately, using Keras with MXNet as backend is not yet possible with KNIME. We have to support each Keras backend explicitly and only did that for TensorFlow, CNTK and Theano so far.
We may want to wait with our integration until MXNet is officially supported by Keras. The corresponding pull request to the Keras repository was put on hold some days ago, though, so this might take some time.

Marcel

Hi Marcel,

Thanks for your reply. Well, if MXNet is currently not supported as backend but will be in the near future I am fine with waiting :slight_smile: . I can use KNIME + TF for now and wait until integration is complete as long as it just means switching backends.

Regards,
Jorge