Hi, I am trying to run the bear classification on my local system but facing this error:
python app/server.py serve
Error:
C:\Program Files\Anaconda3\lib\site-packages\torch\serialization.py:435: SourceChangeWarning: source code of class ‘torch.nn.modules.linear.Linear’ 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)
INFO: Started server process [4524]
INFO: Waiting for application startup.
INFO: Uvicorn running on http://0.0.0.0:5000 (Press CTRL+C to quit)
INFO: (‘127.0.0.1’, 49211) - “GET / HTTP/1.1” 500
ERROR: Exception in ASGI application
. . .
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: ‘charmap’ codec can’t decode byte 0x90 in position 247: character maps to
In the first instance if you have not done so, I suggest you search this thread for posts relating to “pip list” and update the requirements.txt in the bear classifier to match the library versions of the platform you trained your model on.
I am assuming your bear model (pkl file) works in the notebook you created it in.
Hi there!
When I try to deploy my model in Render I get the following error (I’m using the bear template only with modified classes and export_file_url):
Nov 28 11:15:02 AM INFO[0064] RUN python app/server.py
Nov 28 11:15:15 AM Traceback (most recent call last):
File “app/server.py”, line 48, in
learn = loop.run_until_complete(asyncio.gather(*tasks))[0]
File “/usr/local/lib/python3.7/asyncio/base_events.py”, line 579, in run_until_complete
return future.result()
File “app/server.py”, line 35, in setup_learner
learn = load_learner(path, export_file_name)
File “/usr/local/lib/python3.7/site-packages/fastai/basic_train.py”, 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/serialization.py”, line 387, in load
return _load(f, map_location, pickle_module, **pickle_load_args)
File “/usr/local/lib/python3.7/site-packages/torch/serialization.py”, line 564, in _load
magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, ‘{’.
Nov 28 11:15:15 AM error building image: error building stage: waiting for process to exit: exit status 1
Nov 28 11:15:15 AM error: exit status 1
If you haven’t done so already, can I suggest you search this thread for posts relating to “pip list” and update the requirements.txt file in the your classifier to match the library versions of the platform you trained your model on.
This is absolutelyessential for your model to work,
I am assuming your bear model (pkl file) works in the notebook you created it in.
Thank you very much for your answer, that helped! Im using Colab as plattform and I pip listed the packages and updated the requirements.txt file.
Now I get the following error:
Great! That worked!
I came a little bit further once I changed both calls, for torch and for torchvision.
Now this is the error I encounter:
Nov 29 09:11:41 PM INFO[0261] RUN python app/server.py
Nov 29 09:11:53 PM Traceback (most recent call last):
File “app/server.py”, line 48, in
learn = loop.run_until_complete(asyncio.gather(*tasks))[0]
File “/usr/local/lib/python3.7/asyncio/base_events.py”, line 579, in run_until_complete
return future.result()
File “app/server.py”, line 35, in setup_learner
learn = load_learner(path, export_file_name)
File “/usr/local/lib/python3.7/site-packages/fastai/basic_train.py”, line 616, 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/serialization.py”, line 426, in load
return _load(f, map_location, pickle_module, **pickle_load_args)
File “/usr/local/lib/python3.7/site-packages/torch/serialization.py”, line 603, in _load
magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, ‘\x0a’.
I was able to get through to the link generation portion of the deployment tutorial, but I can’t figure out the customize app section. Where is the server.py and the app directory and how do I edit it?
In the guide it tells you to fork the repository, if you have done this you should have your own copy. If you double click the repository folder you should see something like this
you can make your changes here. Once you have committed the changes you can, then pull your repository again into render and rerun your app. If you search this thread you will see a good selection of the frequent problems people have deploying their first model.
You should also search for “pip list” as you need to also amend your requirements.txt file.
Dec 17 12:41:52 PM INFO[0140] COPY app app/
Dec 17 12:41:52 PM INFO[0140] RUN python app/server.py
Dec 17 12:41:56 PM Segmentation fault (core dumped)
Dec 17 12:41:56 PM error building image: error building stage: waiting for process to exit: exit status 139
Dec 17 12:41:57 PM error: exit status 1
As far as I can tell I’ve just followed what the instructions say…
Any idea why this might be? Let me know if more info is needed to understand the problem.
Basically search this thread for “!pip list”, you run this on the platform you created your model on and record the library versions and update your requirements.txt in your app then redeploy.
I use google colab to build my models so it is a different environment to render, so as you are using docker to deploy the model this step must be done.
Once this has been done, you may have some other issues, but this is the most important first step.
I keep getting this error every time I upload a photo to the model!
Can someone please help
File “/usr/local/lib/python3.7/site-packages/starlette/routing.py”, line 585, in call
await route(scope, receive, send)
File “/usr/local/lib/python3.7/site-packages/starlette/routing.py”, line 207, in call
await self.app(scope, receive, send)
File “/usr/local/lib/python3.7/site-packages/starlette/routing.py”, line 40, in app
response = await func(request)
File “app/server.py”, line 63, in analyze
prediction = learn.predict(img)[0]
File “/usr/local/lib/python3.7/site-packages/fastai/basic_train.py”, line 365, in predict
res = self.pred_batch(batch=batch)
File “/usr/local/lib/python3.7/site-packages/fastai/basic_train.py”, line 345, in pred_batch
preds = loss_batch(self.model.eval(), xb, yb, cb_handler=cb_handler)
File “/usr/local/lib/python3.7/site-packages/fastai/basic_train.py”, line 26, in loss_batch
out = model(*xb)
File “/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py”, line 493, in call
result = self.forward(*input, **kwargs)
File “/usr/local/lib/python3.7/site-packages/torch/nn/modules/container.py”, line 92, in forward
input = module(input)
File “/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py”, line 493, in call
result = self.forward(*input, **kwargs)
File “/usr/local/lib/python3.7/site-packages/torch/nn/modules/container.py”, line 92, in forward
input = module(input)
File “/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py”, line 493, in call
result = self.forward(*input, **kwargs)
File “/usr/local/lib/python3.7/site-packages/torch/nn/modules/conv.py”, line 331, in forward
if self.padding_mode == ‘circular’:
File “/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py”, line 539, in getattr
type(self).name, name)) AttributeError: ‘Conv2d’ object has no attribute 'padding_mode’