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

Support for Tensorflow 2.4 #440

Open
lucas-langlois opened this issue Feb 24, 2021 · 7 comments
Open

Support for Tensorflow 2.4 #440

lucas-langlois opened this issue Feb 24, 2021 · 7 comments

Comments

@lucas-langlois
Copy link

lucas-langlois commented Feb 24, 2021

Hi,
I've just acquired a new machine with the lastest GPU RTX3090. This GPU is only supported for CUDA 11 meaning that I can only use the latest version of tensorflow (2.4).
I know that for now segmentation-models only works for tensorflow 2.1. I would really like to use your library to do some semantic segmentation but it seems that I am stuck.
Would you be able to estimate when tensorflow 2.4 support might be available ? Or any other ideas for me in the midtime ?

Thank you very much

@pluniak
Copy link

pluniak commented Feb 25, 2021

Are you sure it's not working? I'm using the repo with TF2.3.0.

@lucas-langlois
Copy link
Author

Yeah I had it running fine previously. But now with Tensorflow 2.4.3 (the only one that would recognize the RTX3090) here are the error message I'm getting :

  1. module 'keras.utils' has no attribute 'generic_utils' = found the way around that with %env SM_FRAMEWORK=tf.keras before loading segmentation-models
  2. when training the model

ValueError Traceback (most recent call last)
in
1 # train model
----> 2 history = model.fit_generator(
3 train_dataloader,
4 steps_per_epoch=len(train_dataloader),
5 epochs=EPOCHS,

\AppData\Local\R-MINI1\envs\tensorflow24\lib\site-packages\tensorflow\python\keras\engine\training.py in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, validation_freq, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch)
1845 'will be removed in a future version. '
1846 'Please use Model.fit, which supports generators.')
-> 1847 return self.fit(
1848 generator,
1849 steps_per_epoch=steps_per_epoch,

\AppData\Local\R-MINI1\envs\tensorflow24\lib\site-packages\tensorflow\python\keras\engine\training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_batch_size, validation_freq, max_queue_size, workers, use_multiprocessing)
1098 _r=1):
1099 callbacks.on_train_batch_begin(step)
-> 1100 tmp_logs = self.train_function(iterator)
1101 if data_handler.should_sync:
1102 context.async_wait()

\AppData\Local\R-MINI1\envs\tensorflow24\lib\site-packages\tensorflow\python\eager\def_function.py in call(self, *args, **kwds)
826 tracing_count = self.experimental_get_tracing_count()
827 with trace.Trace(self._name) as tm:
--> 828 result = self._call(*args, **kwds)
829 compiler = "xla" if self._experimental_compile else "nonXla"
830 new_tracing_count = self.experimental_get_tracing_count()

\AppData\Local\R-MINI1\envs\tensorflow24\lib\site-packages\tensorflow\python\eager\def_function.py in _call(self, *args, **kwds)
869 # This is the first call of call, so we have to initialize.
870 initializers = []
--> 871 self._initialize(args, kwds, add_initializers_to=initializers)
872 finally:
873 # At this point we know that the initialization is complete (or less

\AppData\Local\R-MINI1\envs\tensorflow24\lib\site-packages\tensorflow\python\eager\def_function.py in _initialize(self, args, kwds, add_initializers_to)
723 self._graph_deleter = FunctionDeleter(self._lifted_initializer_graph)
724 self._concrete_stateful_fn = (
--> 725 self._stateful_fn._get_concrete_function_internal_garbage_collected( # pylint: disable=protected-access
726 *args, **kwds))
727

\AppData\Local\R-MINI1\envs\tensorflow24\lib\site-packages\tensorflow\python\eager\function.py in _get_concrete_function_internal_garbage_collected(self, *args, **kwargs)
2967 args, kwargs = None, None
2968 with self._lock:
-> 2969 graph_function, _ = self._maybe_define_function(args, kwargs)
2970 return graph_function
2971

\AppData\Local\R-MINI1\envs\tensorflow24\lib\site-packages\tensorflow\python\eager\function.py in _maybe_define_function(self, args, kwargs)
3359
3360 self._function_cache.missed.add(call_context_key)
-> 3361 graph_function = self._create_graph_function(args, kwargs)
3362 self._function_cache.primary[cache_key] = graph_function
3363

\AppData\Local\R-MINI1\envs\tensorflow24\lib\site-packages\tensorflow\python\eager\function.py in _create_graph_function(self, args, kwargs, override_flat_arg_shapes)
3194 arg_names = base_arg_names + missing_arg_names
3195 graph_function = ConcreteFunction(
-> 3196 func_graph_module.func_graph_from_py_func(
3197 self._name,
3198 self._python_function,

\AppData\Local\R-MINI1\envs\tensorflow24\lib\site-packages\tensorflow\python\framework\func_graph.py in func_graph_from_py_func(name, python_func, args, kwargs, signature, func_graph, autograph, autograph_options, add_control_dependencies, arg_names, op_return_value, collections, capture_by_value, override_flat_arg_shapes)
988 _, original_func = tf_decorator.unwrap(python_func)
989
--> 990 func_outputs = python_func(*func_args, **func_kwargs)
991
992 # invariant: func_outputs contains only Tensors, CompositeTensors,

\AppData\Local\R-MINI1\envs\tensorflow24\lib\site-packages\tensorflow\python\eager\def_function.py in wrapped_fn(*args, **kwds)
632 xla_context.Exit()
633 else:
--> 634 out = weak_wrapped_fn().wrapped(*args, **kwds)
635 return out
636

\AppData\Local\R-MINI1\envs\tensorflow24\lib\site-packages\tensorflow\python\framework\func_graph.py in wrapper(*args, **kwargs)
975 except Exception as e: # pylint:disable=broad-except
976 if hasattr(e, "ag_error_metadata"):
--> 977 raise e.ag_error_metadata.to_exception(e)
978 else:
979 raise

ValueError: in user code:

C:\Users\jc238248\AppData\Local\R-MINI~1\envs\tensorflow24\lib\site-packages\tensorflow\python\keras\engine\training.py:805 train_function  *
    return step_function(self, iterator)
C:\Users\jc238248\AppData\Local\R-MINI~1\envs\tensorflow24\lib\site-packages\tensorflow\python\keras\engine\training.py:795 step_function  **
    outputs = model.distribute_strategy.run(run_step, args=(data,))
C:\Users\jc238248\AppData\Local\R-MINI~1\envs\tensorflow24\lib\site-packages\tensorflow\python\distribute\distribute_lib.py:1259 run
    return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs)
C:\Users\jc238248\AppData\Local\R-MINI~1\envs\tensorflow24\lib\site-packages\tensorflow\python\distribute\distribute_lib.py:2730 call_for_each_replica
    return self._call_for_each_replica(fn, args, kwargs)
C:\Users\jc238248\AppData\Local\R-MINI~1\envs\tensorflow24\lib\site-packages\tensorflow\python\distribute\distribute_lib.py:3417 _call_for_each_replica
    return fn(*args, **kwargs)
C:\Users\jc238248\AppData\Local\R-MINI~1\envs\tensorflow24\lib\site-packages\tensorflow\python\keras\engine\training.py:788 run_step  **
    outputs = model.train_step(data)
C:\Users\jc238248\AppData\Local\R-MINI~1\envs\tensorflow24\lib\site-packages\tensorflow\python\keras\engine\training.py:754 train_step
    y_pred = self(x, training=True)
C:\Users\jc238248\AppData\Local\R-MINI~1\envs\tensorflow24\lib\site-packages\tensorflow\python\keras\engine\base_layer.py:998 __call__
    input_spec.assert_input_compatibility(self.input_spec, inputs, self.name)
C:\Users\jc238248\AppData\Local\R-MINI~1\envs\tensorflow24\lib\site-packages\tensorflow\python\keras\engine\input_spec.py:204 assert_input_compatibility
    raise ValueError('Layer ' + layer_name + ' expects ' +

ValueError: Layer model_3 expects 1 input(s), but it received 2 input tensors. Inputs received: [<tf.Tensor 'IteratorGetNext:0' shape=(None, None, None, None) dtype=uint8>, <tf.Tensor 'IteratorGetNext:1' shape=(None, None, None, None) dtype=float32>]

@pluniak
Copy link

pluniak commented Feb 26, 2021

Sorry, can't help you with that.

@WeiChihChern
Copy link

WeiChihChern commented Mar 6, 2021

Can confirm this repo works with my 3090: a docker container in linux.

@JordanMakesMaps
Copy link

See #412 if you haven't already, it looks like it might be related?

@lucas-langlois
Copy link
Author

Yes that was it! Works like a charm now.
Thank you very much for the help. No chance I would have been able to debug that by myself.

@Kritz23
Copy link

Kritz23 commented Dec 2, 2021

Yes that was it! Works like a charm now.
Thank you very much for the help. No chance I would have been able to debug that by myself.

Hey, I tried the same approach its working fine, but I'm not able to use my GPU. Can you assist?

Thanks in advance!

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