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

from keras.backend import tf as ktf #25

Open
aliericcantona opened this issue Nov 14, 2017 · 10 comments
Open

from keras.backend import tf as ktf #25

aliericcantona opened this issue Nov 14, 2017 · 10 comments

Comments

@aliericcantona
Copy link

from keras.backend import tf as ktf fails on keras.version = 2.0.8
therefore the interpolation layer gives an error.

Any solution?

@cardwing
Copy link

I have met the same problem. My solution is to not activate tensorflow in the terminal, i.e., not use "source activate tensorflow". Just use "python pspnet.py -m pspnet101_cityscapes -i example_images/cityscapes.png -o example_results/cityscapes.jpg", it will work.

@Vladkryvoruchko
Copy link
Owner

Vladkryvoruchko commented Nov 26, 2017

@cardwing what do you mean activate tf in the terminal? I guess it is to import tf in the python shell?
@aliericcantona Can you please provide some logs or error stack, as well as packages version

@qiuyinglin
Copy link

@Vladkryvoruchko
i am running the same issue as @aliericcantona
i install this whole package in amazon EC2 machine, which has Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-1022-aws x86_64v)

and in terminal, i put command "source activate tensorflow_p36" to have the TensorFlow(+Keras2) with Python3 (CUDA 8) enviroment.

then i run python pspnet.py -m pspnet101_voc2012 -i example_images/pascal_voc.jpg -o example_results/pascal_voc.jpg

then i get the below error:

/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type.
from ._conv import register_converters as _register_converters
Using TensorFlow backend.
/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: compiletime version 3.5 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.6
return f(*args, **kwds)
2018-01-19 07:39:58.963310: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2018-01-19 07:39:59.046386: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:892] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2018-01-19 07:39:59.046732: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Found device 0 with properties:
name: Tesla K80 major: 3 minor: 7 memoryClockRate(GHz): 0.8235
pciBusID: 0000:00:1e.0
totalMemory: 11.17GiB freeMemory: 11.10GiB
2018-01-19 07:39:59.046769: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: Tesla K80, pci bus id: 0000:00:1e.0, compute capability: 3.7)
Namespace(flip=False, id='0', input_path='example_images/pascal_voc.jpg', model='pspnet101_voc2012', multi_scale=False, output_path='our_example_results/pascal_voc.jpg', sliding=False)
Keras model & weights found, loading...
XXX lineno: 18, opcode: 0
Traceback (most recent call last):
File "pspnet.py", line 270, in
weights=args.model)
File "pspnet.py", line 149, in init
input_shape=input_shape, weights=weights)
File "pspnet.py", line 41, in init
self.model = model_from_json(file_handle.read())
File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/keras/models.py", line 349, in model_from_json
return layer_module.deserialize(config, custom_objects=custom_objects)
File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/keras/layers/init.py", line 55, in deserialize
printable_module_name='layer')
File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 143, in deserialize_keras_object
list(custom_objects.items())))
File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/keras/engine/topology.py", line 2517, in from_config
process_node(layer, node_data)
File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/keras/engine/topology.py", line 2474, in process_node
layer(input_tensors[0], **kwargs)
File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/keras/engine/topology.py", line 617, in call
output = self.call(inputs, **kwargs)
File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/keras/layers/core.py", line 663, in call
return self.function(inputs, **arguments)
File "/media/tatsch/DataSSD1/workspace/PSPNet-Keras-tensorflow/pspnet/layers_builder.py", line 18, in Interp
new_height, new_width = shape
SystemError: unknown opcode

how can i fix it? Thanks!

@cardwing
Copy link

@Vladkryvoruchko , not use tf in the terminal is just not execute "source activate tensorflow". Just use "python file_name.py -m pspnet101_cityscapes -i example_images/cityscapes.png -o example_results/cityscapes.jpg" should work.

@jmtatsch
Copy link
Contributor

Apparently this issue is caused by the marshal serial format having changed a bit between Python 3.5 and 3.6 as discovered in keras-team/keras#9595 . Converting the weights from numpy with python 3.6 should work around it.

@shokohigol
Copy link

I have met the same problem. I use python 3.5 and tensorflow-gpu 1.14.0.
I don't understand "not use tf in the terminal is just not execute "source activate tensorflow"" from @cardwing.
how can i fix it?

@cardwing
Copy link

Just use "python pspnet.py -m pspnet101_cityscapes -i example_images/cityscapes.png -o example_results/cityscapes.jpg".

@raghuram-kukun
Copy link

@cardwing Could you please be clearer? The README.md asks us to run the file just the way you have mentioned. What does don't activate tensorflow in terminal mean?

@nicpho
Copy link

nicpho commented Mar 21, 2020

from keras.backend.tensorflow_backend import tf as ktf for keras 2.3.1

@mobiiin
Copy link

mobiiin commented Feb 21, 2021

im having the same issue. tensorflow-gpu 2.4 or 2.3 not sure and keras 2.4.3
from keras.backend.tensorflow_backend import tf as ktf doesn't work either
ps: tf.keras.backend worked on my system
move the tensorflow import to the upper line

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

9 participants