-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
questionUsability question, not directly related to an error with the imageUsability question, not directly related to an error with the image
Description
Summary
I was using the image python:3.9.13-slim
to deploy a container that uses tensorflow and other libraries. Everything was okay but with the latest image release at the moment of writting: Digest:sha256:5e652db0ae12b5e5e538466f5a6ca4ae0b4e5f0c647cbfbd1071ac75edb3785d
I began to have issues with the container even though I didn't change a thing.
I was prompt with the following error when the container was starting:
Traceback (most recent call last):
neural-network | File "/app/app.py", line 6, in <module>
neural-network | from model import Model
neural-network | File "/app/model.py", line 3, in <module>
neural-network | from tensorflow import keras
neural-network | File "/opt/venv/lib/python3.9/site-packages/tensorflow/__init__.py", line 37, in <module>
neural-network | from tensorflow.python.tools import module_util as _module_util
neural-network | File "/opt/venv/lib/python3.9/site-packages/tensorflow/python/__init__.py", line 37, in <module>
neural-network | from tensorflow.python.eager import context
neural-network | File "/opt/venv/lib/python3.9/site-packages/tensorflow/python/eager/context.py", line 29, in <module>
neural-network | from tensorflow.core.framework import function_pb2
neural-network | File "/opt/venv/lib/python3.9/site-packages/tensorflow/core/framework/function_pb2.py", line 16, in <module>
neural-network | from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
neural-network | File "/opt/venv/lib/python3.9/site-packages/tensorflow/core/framework/attr_value_pb2.py", line 16, in <module>
neural-network | from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
neural-network | File "/opt/venv/lib/python3.9/site-packages/tensorflow/core/framework/tensor_pb2.py", line 16, in <module>
neural-network | from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
neural-network | File "/opt/venv/lib/python3.9/site-packages/tensorflow/core/framework/resource_handle_pb2.py", line 16, in <module>
neural-network | from tensorflow.core.framework import tensor_shape_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__shape__pb2
neural-network | File "/opt/venv/lib/python3.9/site-packages/tensorflow/core/framework/tensor_shape_pb2.py", line 36, in <module>
neural-network | _descriptor.FieldDescriptor(
neural-network | File "/opt/venv/lib/python3.9/site-packages/google/protobuf/descriptor.py", line 560, in __new__
neural-network | _message.Message._CheckCalledFromGeneratedFile()
neural-network | TypeError: Descriptors cannot not be created directly.
neural-network | If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
neural-network | If you cannot immediately regenerate your protos, some other possible workarounds are:
neural-network | 1. Downgrade the protobuf package to 3.20.x or lower.
neural-network | 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
neural-network |
neural-network | More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
Environment
I am running docker desktop 4.8.2 in a Mac M1 machine.
My dockerfile looks like this:
FROM python:3.9.13-slim
WORKDIR /app
ENV VIRTUAL_ENV=/opt/venv
RUN python -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN apt-get -y update \
&& apt install -y build-essential libpq-dev
RUN pip install --upgrade pip
RUN pip install redis
RUN pip install nltk
RUN pip install numpy
RUN pip install pandas
RUN pip install sqlalchemy
# x86_64
# RUN pip install tensorflow
# RUN pip install psycopg2-binary
# aarch64
RUN pip install tensorflow-aarch64 -f https://tf.kmtea.eu/whl/stable.html
RUN pip install psycopg2
COPY . .
CMD ["python", "-u", "app.py"]
Current workaround
I found a solution in a not so popular stackoverflow comment in which the person suggested to:
pip uninstall protobuf
pip install --no-binary protobuf protobuf
Svito-zar
Metadata
Metadata
Assignees
Labels
questionUsability question, not directly related to an error with the imageUsability question, not directly related to an error with the image