当前位置:   article > 正文

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

python3.7对应的pytorch版本仅cpu版本

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/193789
推荐阅读
相关标签
  

闽ICP备14008679号