我从哪里获得 PyTorch 的仅 CPU 版本? [英] Where do I get a CPU-only version of PyTorch?

查看:10
本文介绍了我从哪里获得 PyTorch 的仅 CPU 版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Flask + PyTorch 运行一个基本应用程序,并将其托管在 Heroku 上.但是,我遇到了一个问题,即免费版本的最大 slug 大小为 500mb,而 PyTorch 本身约为 500mb.

I'm trying to get a basic app running with Flask + PyTorch, and host it on Heroku. However, I run into the issue that the maximum slug size is 500mb on the free version, and PyTorch itself is ~500mb.

经过一些谷歌搜索后,有人写了一篇关于找到 PyTorch 的仅 cpu 版本并使用它的文章,该版本要小得多 此处.

After some google searching, someone wrote about finding a cpu-only version of PyTorch, and using that, which is much smaller here.

然而,我对这是如何完成的感到非常困惑,而且这个人根本没有记录下来.任何建议表示赞赏,谢谢.

However, I'm pretty lost as to how this is done, and the person didn't document this at all. Any advice is appreciated, thanks.

为了更具体地说明我的问题,我尝试通过(据我所知)安装火炬,包括一个将火炬列为依赖项的 requirements.txt.目前我有:火炬==0.4.1.但是,这不适用于 bc 的大小.

To be more specific about my problem, I tried installing torch by (as far as I understand), including a requirements.txt which listed torch as a dependency. Current I have: torch==0.4.1. However this doesn't work bc of size.

我的问题是,你知道我可以在需求文件中写什么来获得更小的仅 cpu 版本的 Torch,或者,如果 requirements.txt 对此不起作用,我会怎么做相反,获取 cpu 版本.

My question is, do you know what I could write in the requirements file to get the cpu-only version of torch that is smaller, or alternatively, if the requirements.txt doesn't work for this, what I would do instead, to get the cpu version.

推荐答案

根据 Pytorch 网站,您可以使用

Per the Pytorch website, you can install pytorch-cpu with

conda install pytorch-cpu torchvision-cpu -c pytorch

您可以从 Anaconda cloud 上的文件中看到,大小在 26和 56MB,具体取决于您要安装它的操作系统.

You can see from the files on Anaconda cloud, that the size varies between 26 and 56MB depending on the OS where you want to install it.

您可以从 http://download.pytorch.org/whl/cpu/ 获取轮子.轮子是 87MB.

You can get the wheel from http://download.pytorch.org/whl/cpu/. The wheel is 87MB.

您可以通过在 requirements.txt 文件中放置指向轮子的链接来设置安装.如果您在 Heroku 上使用 Python 3.6:

You can setup the installation by putting the link to the wheel in the requirements.txt file. If you use Python 3.6 on Heroku:

http://download.pytorch.org/whl/cpu/torch-0.4.1-cp36-cp36m-linux_x86_64.whl

否则,对于 Python 2.7:

otherwise, for Python 2.7:

http://download.pytorch.org/whl/cpu/torch-0.4.1-cp27-cp27mu-linux_x86_64.whl

例如,如果您的要求是 pytorch-cpunumpyscipy,并且您使用的是 Python 3.6,则要求.txt 看起来像:

For example if your requirements are pytorch-cpu, numpy and scipy and you're using Python 3.6, the requirements.txt would look like:

http://download.pytorch.org/whl/cpu/torch-0.4.1-cp36-cp36m-linux_x86_64.whl
numpy
scipy

这篇关于我从哪里获得 PyTorch 的仅 CPU 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆