tensorflow: tf.keras.Sequential() fails
System information
- Running the most basic instruction fails, for example from the documentation page https://www.tensorflow.org/api_docs/python/tf/keras/Sequential
- OS Platform and Distribution: Arch Linux kernel 5.7.10-arch1-1 (linux@archlinux) (gcc version 10.1.0 (GCC), GNU ld (GNU Binutils) 2.34.0)
- TensorFlow installed from (source or binary): binary package (official Arch package)
- TensorFlow version (use command below): tensorflow-cuda 2.3.0
- Python version: Python 3.8.4
- CUDA/cuDNN version: cuda 11.0
- GPU model and memory: GeForce GTX 950M, Driver Version: 450.57 - 2004MiB
Describe the current behavior Start python then run:
import tensorflow as tf
m = tf.keras.Sequential()
The last line fails with the following error messages:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.8/site-packages/tensorflow/python/training/tracking/base.py", line 457, in _method_wrapper
result = method(self, *args, **kwargs)
File "/usr/lib/python3.8/site-packages/tensorflow/python/keras/engine/sequential.py", line 116, in __init__
super(functional.Functional, self).__init__( # pylint: disable=bad-super-call
File "/usr/lib/python3.8/site-packages/tensorflow/python/training/tracking/base.py", line 457, in _method_wrapper
result = method(self, *args, **kwargs)
File "/usr/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py", line 308, in __init__
self._init_batch_counters()
File "/usr/lib/python3.8/site-packages/tensorflow/python/training/tracking/base.py", line 457, in _method_wrapper
result = method(self, *args, **kwargs)
File "/usr/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py", line 317, in _init_batch_counters
self._train_counter = variables.Variable(0, dtype='int64', aggregation=agg)
File "/usr/lib/python3.8/site-packages/tensorflow/python/ops/variables.py", line 262, in __call__
return cls._variable_v2_call(*args, **kwargs)
File "/usr/lib/python3.8/site-packages/tensorflow/python/ops/variables.py", line 244, in _variable_v2_call
return previous_getter(
File "/usr/lib/python3.8/site-packages/tensorflow/python/ops/variables.py", line 237, in <lambda>
previous_getter = lambda **kws: default_variable_creator_v2(None, **kws)
File "/usr/lib/python3.8/site-packages/tensorflow/python/ops/variable_scope.py", line 2633, in default_variable_creator_v2
return resource_variable_ops.ResourceVariable(
File "/usr/lib/python3.8/site-packages/tensorflow/python/ops/variables.py", line 264, in __call__
return super(VariableMetaclass, cls).__call__(*args, **kwargs)
File "/usr/lib/python3.8/site-packages/tensorflow/python/ops/resource_variable_ops.py", line 1507, in __init__
self._init_from_args(
File "/usr/lib/python3.8/site-packages/tensorflow/python/ops/resource_variable_ops.py", line 1661, in _init_from_args
handle = eager_safe_variable_handle(
File "/usr/lib/python3.8/site-packages/tensorflow/python/ops/resource_variable_ops.py", line 242, in eager_safe_variable_handle
return _variable_handle_from_shape_and_dtype(
File "/usr/lib/python3.8/site-packages/tensorflow/python/ops/resource_variable_ops.py", line 174, in _variable_handle_from_shape_and_dtype
gen_logging_ops._assert( # pylint: disable=protected-access
File "/usr/lib/python3.8/site-packages/tensorflow/python/ops/gen_logging_ops.py", line 49, in _assert
_ops.raise_from_not_ok_status(e, name)
File "/usr/lib/python3.8/site-packages/tensorflow/python/framework/ops.py", line 6843, in raise_from_not_ok_status
six.raise_from(core._status_to_exception(e.code, message), None)
File "<string>", line 3, in raise_from
tensorflow.python.framework.errors_impl.InvalidArgumentError: assertion failed: [0] [Op:Assert] name: EagerVariableNameReuse
Describe the expected behavior
An empty sequential model is created, no error.
Standalone code to reproduce the issue
import tensorflow as tf
m = tf.keras.Sequential()
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 6
- Comments: 46 (8 by maintainers)
Same problem with python 3.7, tf 2.3 , CUDA 10.1 and cuDnn 7.6, windows 10 python 3.7, tf-nigthly (1-SEP-2020) , CUDA 11.0 and cuDnn 8.03, windows 10
also replicated by just
tf.Variable((2,3))
the problem does not happen in tensorflow 2.2
This is the failing assertion which seems to be GPU independent. Do you know if you’re doing something weird in your model?
seems to work fine for me though, on
tf-nightly
.I have same issue too. I have 2 laptop. One has rtx2060 mobile and other gtx860M. I installed linux a while of time ago. before that it is worked smoothly but after i install windows 10 back its doesn’t working anymore I m facing with this error on gtx860m. rtx one just working fine with these versions. but gtx one not working whatever i do visual studio 2019 community with c++ Cuda: 10.1 update2 Cudnn: 7.6.5 Windows10 ( two laptop has same installation versions) I tried all possiblities. I tried python 3.7, python 3.8, anaconda versions, i tried driver version wich comes with cuda, i tried updating driver version to 451. I tried tensorflow 2.2.0 and 2.3.0. and always i installed windows 10 from zero when trying different combination.
or trying to train a model it s not working and giving this error
or stoping like this.
@gowthamkpr Right now I’m running with the following (downgraded) versions
Waiting for the next update that would guarantee that my code runs.
Seems to be working when deactivating the GPU:
At that point I get the following output:
The model has been created: