Where do I get a CPU-only version of PyTorch?
As of PyTorch 1.3, PyTorch has changed its API. In order to install CPU version only, use
conda install pytorch torchvision cpuonly -c pytorch
And, the corresponding wheel files can be downloaded from https://download.pytorch.org/whl/torch_stable.html and can be installed using pip
or use the command similar to the following corresponding to your intended pytorch and torchvision versions
On Linux:
pip3 install torch==1.9.0+cpu torchvision==0.10.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
On Windows / Mac:
pip3 install torch torchvision
Check the PyTorch's getting started guide.
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
In 2020, please use the following command if you want to download pytorch-cpu version with pip3 (on Linux and Win):
pip3 install torch==1.5.0+cpu torchvision==0.6.0+cpu -f https://download.pytorch.org/whl/torch_stable.html