Tensorflow insatllation is failing on AWS python3.8 image when building the docker file
Question:
Collecting Flask==1.1.2
Downloading Flask-1.1.2-py2.py3-none-any.whl (94 kB)
Collecting tensorflow==2.4.0
Downloading tensorflow-2.4.0-cp38-cp38-manylinux2010_x86_64.whl (394.8 MB)
ERROR: Exception:
Traceback (most recent call last):
File "/var/lang/lib/python3.8/site-packages/pip/_vendor/resolvelib/resolvers.py", line 171, in _merge_into_criterion
crit = self.state.criteria[name]
KeyError: 'tensorflow'
During handling of the above exception, another exception occurred:
File "/var/lang/lib/python3.8/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 52, in _close
self.__callback(self.__buf.getvalue())
File "/var/lang/lib/python3.8/site-packages/pip/_vendor/cachecontrol/controller.py", line 309, in cache_response
cache_url, self.serializer.dumps(request, response, body=body)
File "/var/lang/lib/python3.8/site-packages/pip/_vendor/cachecontrol/serialize.py", line 72, in dumps
return b",".join([b"cc=4", msgpack.dumps(data, use_bin_type=True)])
File "/var/lang/lib/python3.8/site-packages/pip/_vendor/msgpack/__init__.py", line 35, in packb
return Packer(**kwargs).pack(o)
File "/var/lang/lib/python3.8/site-packages/pip/_vendor/msgpack/fallback.py", line 960, in pack
self._pack(obj)
File "/var/lang/lib/python3.8/site-packages/pip/_vendor/msgpack/fallback.py", line 943, in _pack
return self._pack_map_pairs(
File "/var/lang/lib/python3.8/site-packages/pip/_vendor/msgpack/fallback.py", line 1045, in _pack_map_pairs
self._pack(v, nest_limit - 1)
File "/var/lang/lib/python3.8/site-packages/pip/_vendor/msgpack/fallback.py", line 943, in _pack
return self._pack_map_pairs(
File "/var/lang/lib/python3.8/site-packages/pip/_vendor/msgpack/fallback.py", line 1045, in _pack_map_pairs
self._pack(v, nest_limit - 1)
File "/var/lang/lib/python3.8/site-packages/pip/_vendor/msgpack/fallback.py", line 889, in _pack
return self._buffer.write(obj)
MemoryError
The command '/bin/sh -c python3.8 -m pip install -r requirements.txt' returned a non-zero code: 2
Following this blog to create the container image for lambda
URL : https://aws.amazon.com/blogs/machine-learning/using-container-images-to-run-tensorflow-models-in-aws-lambda/
Answers:
This is a memory error. When creating the environment, use a larger capacity EC2 instance.
The default instance type is t2.small. I used c5.xlarge and TensorFlow was installed properly.
I had exact same issue when I deployed my web app to Elastic Beanstalk with t2.micro instance type. And after I changed to t2.medium instance and everything worked smoothly.
Collecting Flask==1.1.2
Downloading Flask-1.1.2-py2.py3-none-any.whl (94 kB)
Collecting tensorflow==2.4.0
Downloading tensorflow-2.4.0-cp38-cp38-manylinux2010_x86_64.whl (394.8 MB)
ERROR: Exception:
Traceback (most recent call last):
File "/var/lang/lib/python3.8/site-packages/pip/_vendor/resolvelib/resolvers.py", line 171, in _merge_into_criterion
crit = self.state.criteria[name]
KeyError: 'tensorflow'
During handling of the above exception, another exception occurred:
File "/var/lang/lib/python3.8/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 52, in _close
self.__callback(self.__buf.getvalue())
File "/var/lang/lib/python3.8/site-packages/pip/_vendor/cachecontrol/controller.py", line 309, in cache_response
cache_url, self.serializer.dumps(request, response, body=body)
File "/var/lang/lib/python3.8/site-packages/pip/_vendor/cachecontrol/serialize.py", line 72, in dumps
return b",".join([b"cc=4", msgpack.dumps(data, use_bin_type=True)])
File "/var/lang/lib/python3.8/site-packages/pip/_vendor/msgpack/__init__.py", line 35, in packb
return Packer(**kwargs).pack(o)
File "/var/lang/lib/python3.8/site-packages/pip/_vendor/msgpack/fallback.py", line 960, in pack
self._pack(obj)
File "/var/lang/lib/python3.8/site-packages/pip/_vendor/msgpack/fallback.py", line 943, in _pack
return self._pack_map_pairs(
File "/var/lang/lib/python3.8/site-packages/pip/_vendor/msgpack/fallback.py", line 1045, in _pack_map_pairs
self._pack(v, nest_limit - 1)
File "/var/lang/lib/python3.8/site-packages/pip/_vendor/msgpack/fallback.py", line 943, in _pack
return self._pack_map_pairs(
File "/var/lang/lib/python3.8/site-packages/pip/_vendor/msgpack/fallback.py", line 1045, in _pack_map_pairs
self._pack(v, nest_limit - 1)
File "/var/lang/lib/python3.8/site-packages/pip/_vendor/msgpack/fallback.py", line 889, in _pack
return self._buffer.write(obj)
MemoryError
The command '/bin/sh -c python3.8 -m pip install -r requirements.txt' returned a non-zero code: 2
Following this blog to create the container image for lambda
URL : https://aws.amazon.com/blogs/machine-learning/using-container-images-to-run-tensorflow-models-in-aws-lambda/
This is a memory error. When creating the environment, use a larger capacity EC2 instance.
The default instance type is t2.small. I used c5.xlarge and TensorFlow was installed properly.
I had exact same issue when I deployed my web app to Elastic Beanstalk with t2.micro instance type. And after I changed to t2.medium instance and everything worked smoothly.