Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use lycon and TensorFlow in same project #3

Open
EdeMeijer opened this issue Sep 10, 2017 · 6 comments
Open

Cannot use lycon and TensorFlow in same project #3

EdeMeijer opened this issue Sep 10, 2017 · 6 comments

Comments

@EdeMeijer
Copy link

Hello,

I'm trying to use lycon in a project to rescale images before feeding them into TensorFlow. However, when importing both lycon and TensorFlow in a python application, TensorFlow crashes.

import lycon
import tensorflow as tf

x = tf.placeholder(tf.float32)

Running this code results in the following error

2017-09-10 13:32:53.687783: F tensorflow/core/framework/op.cc:165] Non-OK-status: RegisterAlreadyLocked(deferred_[i]) status: Invalid argument: Could not parse default value '4000' from Attr("upper_frequency_limit: float = 4000") for Op Mfcc
Could not parse default value '20' from Attr("lower_frequency_limit: float = 20") for Op Mfcc

Note I'm not trying to say lycon is at fault here, it might very well be a bug in TensorFlow, but I really don't know where to start. I'm using python 3.5 and the latest version of TensorFlow (1.3.0) and lycon, both installed through pip3. I was hoping you might have a clue what's going on here.

Thanks in advance

@EdeMeijer
Copy link
Author

These attributes (upper/lower frequency limit) are part of some WIP tensorflow audio operations (tensorflow/tensorflow#11339), so this might be an actual bug, but then I'm wondering why these ops are being loaded when importing lycon, and not when not importing lycon.

@panosgemos
Copy link

panosgemos commented Sep 16, 2017

I am having the same issue. As a workaround until it gets fixed, you can use lycon, by encapsulating it to functions by importing it only there. For example:

def myFunc():
    # do something
    import lycon
    lycon.someLyconFunction()

You can also create wrapper functions for each of the lycon functions, that will include lycon inside them. But I am afraid that, if your code uses these functions too much, there might be an overhead from the frequent imports.

An example wrapper function for lycon.load():

def load(image_path):
     import lycon
     return lycon.load(image_path)

@arel
Copy link

arel commented Sep 21, 2017

I am having this issue as well on Python 2.7.

Weird that it works if TensorFlow is imported before Lycon.

import tensorflow as tf
import lycon

x = tf.placeholder(tf.float32)  # works

A better workaround then would be something like:

def myFunc():
    import tensorflow as tf
    import lycon
    # do something with lycon
    lycon.someLyconFunction()

@ethereon
Copy link
Owner

Oddly, I can't seem to reproduce it.

I tested on Ubuntu 14.04 with both Python 2 and 3.
Tensorflow installed using the tensorflow-gpu pip package:

Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul  2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lycon
>>> import tensorflow as tf
>>> x = tf.placeholder(tf.float32)
>>> tf.Session().run(tf.reduce_sum(x), feed_dict={x:lycon.load('/tmp/test.png')})
13158753.0
>>> 'Tensorflow version is {}. Lycon version is {}'.format(tf.VERSION, lycon.__version__)
'Tensorflow version is 1.3.0. Lycon version is 0.1.9'

Similarly, no issues on macOS 10.13.
Tensorflow installed using the tensorflow pip package:

Python 3.6.1 |Anaconda 4.4.0 (x86_64)| (default, May 11 2017, 13:04:09)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import lycon
>>> import tensorflow as tf
>>> x = tf.placeholder(tf.float32)
>>> tf.Session().run(tf.reduce_sum(x), feed_dict={x:lycon.load('/tmp/test.png')})
13158753.0
>>> 'Tensorflow version is {}. Lycon version is {}'.format(tf.VERSION, lycon.__version__)
'Tensorflow version is 1.3.0. Lycon version is 0.1.9'

@EdeMeijer
Copy link
Author

I tried it on another machine with the same result, this time with Tensorflow without GPU support. Both machines are on Ubuntu 16.04, so maybe that's related. I have a 14.04 installation at home, I could try it later today to see if the OS version is the culprit.

@jeherr
Copy link

jeherr commented Oct 25, 2017

Just wanted to add that I ran into an identical error message, except instead of the lycon module it happens to me with the psi4 module. Similarly if tensorflow is imported before psi4 then the issue does not occur. Running Ubuntu 16.04 with python 3.6 from the latest miniconda. Tried with tensorflow installed from conda-forge and from pip with the tfBinaryURL as provided on tensorflow's own website. Seems like this is likely a bug with tensorflow. I'll look around for an issue on the tensorflow github for something similar and if I don't see one I'll open an issue there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants