python3.7 pytorch cpu版本,在哪里可以获得PyTorch的仅CPU版本?

本文介绍了如何在Heroku免费版上解决slug大小超过500MB的问题,特别是针对PyTorch库的大小。通过安装CPU版本的PyTorch来减小应用体积。具体步骤包括从PyTorch官网获取适用于CPU的whl文件链接,并将其添加到requirements.txt文件中,例如对于Python3.6,可以使用torch-0.4.1-cp36-cp36m-linux_x86_64.whl的链接。
摘要由CSDN通过智能技术生成

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.

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.

EDIT:

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.

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.

解决方案

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

conda install pytorch-cpu torchvision-cpu -c pytorch

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.

You can get the wheel from http://download.pytorch.org/whl/cpu/.

The wheel is 87MB.

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

otherwise, for Python 2.7:

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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值