tensorflow-model-optimization fails to import in official tensorflow:2.15.0 Docker image due to TF_USE_LEGACY_KERAS=1 and missing tf_keras
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- docker, python, tensorflow
- Domain
- devops, machine-learning
Research direction
Reproduce the import failure in the official tensorflow/tensorflow:2.15.0 image using tensorflow-model-optimization==0.8.0 and the shown Python command. Inspect how TF_USE_LEGACY_KERAS=1 and the tf_keras dependency interact; done means tfmot imports successfully without upgrading TensorFlow beyond 2.15.
Written by the indexing model from the issue text.
Description
When using the official TensorFlow Docker image tensorflow/tensorflow:2.15.0, the environment variable TF_USE_LEGACY_KERAS is preset to 1 (True). This causes tensorflow-model-optimization (tfmot) to fail with an ImportError because it expects tf_keras to be installed.
Attempting to install tf_keras leads to an automatic upgrade of TensorFlow to 2.21+, which breaks compatibility with tfmot (which is designed for TensorFlow 2.15).
- Pull the official image:
docker pull tensorflow/tensorflow:2.15.0 docker run -it tensorflow/tensorflow:2.15.0 bash pip install tensorflow-model-optimization==0.8.0 python -c "import tensorflow_model_optimization as tfmot"
The import fails with:
ImportError: Keras cannot be imported. Check that it is installed.
- Dominant language
- Python
- Stars
- 1.6k
- Forks
- 349
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from tensorflow/model-optimization
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
tensorflow/model-optimization#1301 · 1 comment ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 50/100
tensorflow/model-optimization#1270 · 2 comments ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
tensorflow/model-optimization#1241 ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 35/100
tensorflow/model-optimization#1182 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
tensorflow/model-optimization#1181 · 1 comment ·
All issues in tensorflow/model-optimization
Similar issues
-
agent-ready documentation needs-triage
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
-
documentation
Difficulty 1/5 Under an hour Newbie friendliness 91/100
-
workflow-status page template still says reusable workflows are "triggered only by workflow_call:" Open
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
instance instance add
Difficulty 1/5 Under an hour Newbie friendliness 72/100
searxng/searx-instances#939 · 1 comment ·
-
area-deployment area-integrations triage:bot-seen
Difficulty 2/5 Half a day Newbie friendliness 86/100