Deployment Platform: Render ✅

This is the error I have and saw in previous post:
Feb 27 03:43:10 PM Traceback (most recent call last):
File “app/server.py”, line 43, in
learn = loop.run_until_complete(asyncio.gather(*tasks))[0]
File “/usr/local/lib/python3.7/asyncio/base_events.py”, line 584, in run_until_complete
return future.result()
File “app/server.py”, line 31, in setup_learner
learn = load_learner(path, export_file_name)
File “/usr/local/lib/python3.7/site-packages/fastai/basic_train.py”, line 501, in load_learner
state = torch.load(Path(path)/fname, map_location=‘cpu’) if defaults.device == torch.device(‘cpu’) else torch.load(Path(path)/fname)
File “/usr/local/lib/python3.7/site-packages/torch/serialization.py”, line 368, in load
return _load(f, map_location, pickle_module)
File “/usr/local/lib/python3.7/site-packages/torch/serialization.py”, line 532, in _load
magic_number = pickle_module.load(f)
_pickle.UnpicklingError: invalid load key, ‘<’.
Feb 27 03:43:11 PM error building image: error building stage: waiting for process to exit: exit status 1
Feb 27 03:43:11 PM error: exit status 1

2 Likes

These errors are typically caused by a bad export of the PKL file, or a download URL that isn’t the raw download link. See discussions around creating the raw download link in this thread.

1 Like

Hi @anurag,

When I tried to build the sample repo Docker image with the latest fastai library (currently 1.0.46), server.py fails to run, giving the following error:

Step 7/9 : RUN python app/server.py
—> Running in a972aa18622c
/usr/local/lib/python3.7/site-packages/torch/serialization.py:435: SourceChangeWarning: source code of class ‘torchvision.models.resnet.BasicBlock’ has changed. you can retrieve the original source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
Traceback (most recent call last):
File “app/server.py”, line 46, in
learn = loop.run_until_complete(asyncio.gather(*tasks))[0]
File “/usr/local/lib/python3.7/asyncio/base_events.py”, line 584, in run_until_complete
return future.result()
File “app/server.py”, line 34, in setup_learner
learn = load_learner(path, export_file_name)
File “/usr/local/lib/python3.7/site-packages/fastai/basic_train.py”, line 549, in load_learner
state = torch.load(Path(path)/fname, map_location=‘cpu’) if defaults.device == torch.device(‘cpu’) else torch.load(Path(path)/fname)
File “/usr/local/lib/python3.7/site-packages/torch/serialization.py”, line 368, in load
return _load(f, map_location, pickle_module)
File “/usr/local/lib/python3.7/site-packages/torch/serialization.py”, line 542, in _load
result = unpickler.load()
AttributeError: Can’t get attribute ‘ImageItemList’ on <module ‘fastai.vision.data’ from ‘/usr/local/lib/python3.7/site-packages/fastai/vision/data.py’>
The command ‘/bin/sh -c python app/server.py’ returned a non-zero code: 1

I modified requirements.txt to get fastai==1.0.43.post1 instead, and that worked. Not sure whether some recent changes in ImageItemList caused this problem? Thanks.

Yijin

3 Likes

Oh i see where i was going wrong now, thanks for the help @anurag!
I have the image being posted now but could you suggest how i might do the parsing of the JSON response from the python script after the POST?

‘return JSONResponse({‘result’: str(prediction)})’

Nevermind @anurag, i actually just solved my problem there! Thanks so much for the help!

1 Like

Seems like it’s just a change in exported data, between fastai 1.0.44 and 1.0.46 (1.0.45 was a duplicate of 44, so it was skipped). Confirmed here.

Thanks.

Yijin

1 Like

It was this commit I believe: https://github.com/fastai/fastai/commit/fe5d4a65f02be706a8bcf3c12e98460656d5dab2

Hi @anurag I wanted to give render a try, but when I click on https://dashboard.render.com/register?i=fastai-v3 all it gives me is a blank page, and when I try to sign up at render.com it tells me I’ll be notified later about when I can sign up. Thoughts? Thanks.

I just sent you an invite. Try hard-refreshing the dashboard or open it in a different browser?

Thanks! Appears to be a FireFox problem. I should have checked that first.

1 Like

I successfully deployed the demo code by following the instructions on fastai official course website.

The experience was smooth and enjoying. What a great platform! Congrats Anurag!

1 Like

I am getting the error

AttributeError: Can’t get attribute ‘ImageItemList’ on <module ‘fastai.vision.data’ from ‘/anaconda3/envs/fastai-env/lib/python3.7/site-packages/fastai/vision/data.py’>

when trying to locally run a server.
I have tried changing the requirements txt to the specific version listed but nothing has changed.

=== Software ===
python : 3.7.2
fastai : 1.0.46
fastprogress : 0.1.20
torch : 1.0.1.post2
torch cuda : None / is Not available

=== Hardware ===
No GPUs available

=== Environment ===
platform : Darwin-17.7.0-x86_64-i386-64bit
conda env : fastai-env
python : /anaconda3/envs/fastai-env/bin/python
sys.path : /Users/bradleybrown/Desktop/fastai/webapp/fastai-v3
/anaconda3/envs/fastai-env/lib/python37.zip
/anaconda3/envs/fastai-env/lib/python3.7
/anaconda3/envs/fastai-env/lib/python3.7/lib-dynload
/anaconda3/envs/fastai-env/lib/python3.7/site-packages
no supported gpus found on this system

Hi Bradley,

This was mentioned a few posts before your post, please see here. If your requirements.txt is getting the latest fastai 1.0.46, you need to make sure you exported the pkl file with fastai 1.0.46 too. If your pkl file was exported with an older fastai version (eg 1.0.44), then change the requirements.txt to get 1.0.44 before you build and run the Docker image.

Thanks.

Yijin

3 Likes

There is no value for the response header:

The response headers are:

  1. content-encoding: br

  2. content-length: 25

  3. content-type: text/plain; charset=utf-8

  4. date:

Mon, 04 Mar 2019 13:51:17 GMT

  1. server: uvicorn

  2. status: 500

  3. strict-transport-security: max-age=315360000;

Hi @anurag,
I have signed up to Render but when I tried to confirm my account through the received link I got ‘invalid or expired activation link’.

I just reset your emails. Try signing up again?

Now it’s working. Thanks

1 Like

@anurag, OMG super easy to use and a great help that there is starter code to help guide the process. :100: Only issue during the process was an error (mentioned before in this thread:

AttributeError: Can’t get attribute ‘ImageItemList’ on <module ‘fastai.vision.data’ from ‘/usr/local/lib/python3.7/site-packages/fastai/vision/data.py’>
The command ‘/bin/sh -c python app/server.py’ returned a non-zero code: 1

But replacing the fastai version in the requirements.txt fixed the issue as mentioned by @utkb

What I love about render:

  • Much much much easier to use IMO when compared to deploying on heroku or AWS (sometimes you just want to deploy and not worry about how to deploy! :slight_smile: )
  • I like the fact that it renders directly from gitub - easier to navigate
  • Starter code a huge help when compared to reading documentation
  • Love the horse images (I think - or donkey?) when done!

Is there a way to customize the url for the deployment?

1 Like

Thanks for the kind words! You can add a custom domain to your Render app: https://render.com/docs/custom-domains/

2 Likes

Hi @anurag,

First of all thank you for responding to all of these questions, I really appreciate it. I don’t believe this has been asked yet, but when I’m deploying my web app (automatically by pushing my github repo or manually via Render console) and it fails deploying, how do I troubleshoot my problems? Just now I manually deployed my web app and I get a terminal feed, but it just stops after a certain point with no error message in the log when the deployment fails.

Thanks,
Wayde