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

ImportError: cannot import name 'variable_v1' from 'tensorflow.python.ops' #549

Closed
baroai opened this issue Oct 18, 2023 · 2 comments
Closed

Comments

@baroai
Copy link

baroai commented Oct 18, 2023

I git this error with

GPU = 4090 RTX 2ea
CPU = Intel
OS = Ubuntu20.04
Tensorflow=2.7.0
Protobuf=3.20.0
python=3.9.0

run command is python tf_cnn_benchmakrs.py --model resnet50 --batch_size 200 --num_gpus 2
and i got this error

Traceback (most recent call last):
  File "tf_cnn_benchmarks.py", line 25, in <module>
    import benchmark_cnn
  File "/root/test/benchmarks/scripts/tf_cnn_benchmarks/benchmark_cnn.py", line 44, in <module>
    from models import model_config
  File "/root/test/benchmarks/scripts/tf_cnn_benchmarks/models/model_config.py", line 21, in <module>
    from models import alexnet_model
  File "/root/test/benchmarks/scripts/tf_cnn_benchmarks/models/alexnet_model.py", line 24, in <module>
    from models import model
  File "/root/test/benchmarks/scripts/tf_cnn_benchmarks/models/model.py", line 23, in <module>
    from tensorflow.python.ops import variable_v1  # pylint: disable=g-direct-tensorflow-import
ImportError: cannot import name 'variable_v1' from 'tensorflow.python.ops' (/usr/local/lib/python3.8/dist-packages/tensorflow/python/ops/__init__.py)

previeous tf_cnn_benchmark is running correctly but now it doesn't work...

what should i do?

@baroai
Copy link
Author

baroai commented Oct 18, 2023

When I checked the commit version 559f08f I was able to identify the error. The error was related to the inability to import 'variable_v1,' and it indicated that the model's library could not be found in TensorFlow versions 2.5 and above. I made the same changes to this part as I did in my previous work, for example, changing variable_v1 to variables and I confirmed that GPU operations work afterward. I would like to know why the variable name was changed to one that doesn't work like this.

@reedwm
Copy link
Member

reedwm commented Oct 19, 2023

The master branch of this repo has been updated to work with the latest nightly version of TensorFlow, and so it no longer works with older versions like TF 2.7.0. You can try an older commit, such as one before 559f08f.

@reedwm reedwm closed this as completed Oct 19, 2023
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

2 participants