Forums

FILE NOT FOUND

.

cp = torch.load(os.path.join(script_dir, 'model.pkl'), map_location=torch.device('cpu'))

I think this code is making my website not functioning, but if I remove map_location=torch.device('cpu'), there will be an error

RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.

Is there anyway I can solve this? Please help!!

Have a look at this help page for additional tips on running PyTorch in website code.

Hi, I tried to add the line torch.set_num_threads(1), but my site is still showing 404 not found.

Could you clarify the problem a bit? You mention "file not found" and "404 not found", which are different kinds of errors.

When I use cp = torch.load(os.path.join(script_dir, 'model.pkl')), if I visit my site, it will give me an error page and tell me that I should check out the log. Then I find out that it says I should specify CPU, but if I add the map_location back, my site will display Not Found The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

A 404 error means that you do not have a view defined for the path that you're trying to access. Make sure that the path you are trying to access has a view defined for it.

How do I define a view for it? I think I have one HTML file in my templates folder.

Which web framework are you using? If it's Flask, then I recommend you go through a few of the early steps in our Flask tutorial to get the hang of web development. If it's Django, then Django Girls is a good starting point.