Deployment woes -> Deployment Success!

Finished(?) Product: Treebeard guesses Hobbit or Orc?

[FIXED] So there are a couple of changes that led to success:

  1. Zip the CONTENTS of your application folder, NOT the parent folder. (Select all > Zip). Beanstalk acts like it understands the Dockerfile if you Zip the parent folder and upload it, but perhaps it doesn’t.

  2. Use the Environments > Create a new environment option. If you haven’t used Elastic Beanstalk before, you will be taken through a slightly different wizard for creating your environment. I recommend creating a garbage project so you can get into the console proper, and then using Environments > Create a new environment to follow the guide. I don’t know if this was part of the fix for me, as none of the selections appeared to be materially different, but it could have been.

--------------------------------------original post below-----------

In attempting to follow the various deployment guides I am encountering the issue below. I am successful until I get to the 6th step of the image build in which the ‘’ file is run.

I have verified that my export.pkl file is publicly accessible, and I have tried following the guides for Render, Elastic Beanstalk, and building from my own local Docker install. Someone posted the same issue on the github.

Any help is greatly appreciated, and I am happy to provide further information.

Traceback (most recent call last): File "app/", line 48, in <module> learn = loop.run_until_complete(asyncio.gather(*tasks))[0] File "/usr/local/lib/python3.7/asyncio/", line 587, in run_until_complete return future.result() File "app/", line 35, in setup_learner learn = load_learner(path, export_file_name) File "/usr/local/lib/python3.7/site-packages/fastai/", line 598, in load_learner state = torch.load(source, map_location='cpu') if defaults.device == torch.device('cpu') else torch.load(source) File "/usr/local/lib/python3.7/site-packages/torch/", line 387, in load return _load(f, map_location, pickle_module, **pickle_load_args) File "/usr/local/lib/python3.7/site-packages/torch/", line 564, in _load magic_number = pickle_module.load(f, **pickle_load_args) _pickle.UnpicklingError: invalid load key, '\x0a'. The command '/bin/sh -c python app/' returned a non-zero code: 1

Looks like something is wrong with your pickle. While still in jupyter, once exported does loading it back in via load_learner work?

And if that doesn’t work (this is just a hunch without seeing your code) but if you remove the async loading (which doesn’t look async from the call stack anyway) is it still broken?

Just looked at the guide you’re following. Are you storing your pickle on Google drive or something similar, and if so are you sure you’re using a downloadable link, not a sharing link?

Storing it here at the moment:

When running in a local container, the export.pkl file does download.

As a general update, I can get the application to run in a local container now, but I had to modify the requirements to install the latest torch instead of the URL provided. Might not be a good practice; I don’t know, but I was encountering an error importing otherwise.

Elastic beanstalk still fails to build the environment due to command failing.

learn = load_learner('../input/test-learner/','export.pkl')

does appear to work, yes.

Jumping on the bandwagon…
I tried a. AWS way - but t2micro instance became full with all pip installs
b. I tried locally on windows…there is error on - when doing pip install fastai

Building wheels for collected packages: bottleneck, nvidia-ml-py3
Building wheel for bottleneck (PEP 517) … error
ERROR: Command errored out with exit status 1:
command: ‘c:\python37\python.exe’ ‘c:\python37\lib\site-packages\pip_vendor\’ build_wheel ‘C:\Users\kh2045\AppData\Local\Temp\tmpf9223u8y’
cwd: C:\Users\kh2045\AppData\Local\Temp\pip-install-dopy_rdj\bottleneck
Complete output (51 lines):
running bdist_wheel
running build
running build_py
creating build
creating build\
creating build\\bottleneck
copying -> build\\bottleneck
copying -> build\\bottleneck
copying -> build\\bottleneck
creating build\\bottleneck\benchmark
copying bottleneck\benchmark\ -> build\\bottleneck\benchmark
copying bottleneck\benchmark\ -> build\\bottleneck\benchmark
copying bottleneck\benchmark\ -> build\\bottleneck\benchmark
copying bottleneck\ -> build\\bottleneck\benchmark

error: Microsoft Visual C++ 14.0 is required. Get it with “Build Tools for Visual Studio”:

ERROR: Failed building wheel for bottleneck

Failed to build bottleneck
ERROR: Could not build wheels for bottleneck which use PEP 517 and cannot be installed directly

C. I am trying GCP way…following this doc -

GCP expects creation of service account to access the resources. I have created one.
When I try gcloud app deploy" …I see 403 forbidden error - forbidden resource access error

I dont know what role to give to service account.

Kindly help me on this.


One quick thing to try: use a t3.small instead of the t2.micro. They recommend the t3 size.

1 Like