简体   繁体   English

在 AWS 上部署 django 时出现 Pytorch 导入错误

[英]Pytorch Import Error when deploying django on AWS

My django app works locally.我的 django 应用程序在本地工作。 When i try to deploy it and then open it on AWS, i get the following error:当我尝试部署它然后在 AWS 上打开它时,我收到以下错误:

在此处输入图像描述

I included torch==1.5.1 in my requirements.txt我在 requirements.txt 中包含了 torch==1.5.1

Requirements.txt:要求.txt:

在此处输入图像描述

When I comment out the parts of the application that require torch and remove it from requirements.txt, it works fine.当我注释掉应用程序中需要 torch 的部分并将其从 requirements.txt 中删除时,它可以正常工作。 What can I do to ensure that torch is installed like the other modules in requirements.txt?我可以做些什么来确保 Torch 像 requirements.txt 中的其他模块一样安装? Here is the link to requirements.txt 是 requirements.txt 的链接

By default torch will require CUDA and GPU .默认情况下,火炬将需要CUDAGPU Depending on your ec2 instance this may not be viable option, thus leading to the errors you are observing.根据您的 ec2 实例,这可能不是可行的选项,从而导致您观察到的错误。

You can install non-cuda version of torch as follows for tests and see if this will have any benefits:您可以按如下方式安装非 cuda 版本的火炬进行测试,看看这是否有任何好处:

pip3 install torch==1.5.1+cpu torchvision==0.6.1+cpu -f https://download.pytorch.org/whl/torch_stable.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM