How to compile torch 1.5.0 without GPU support?
I want to install pytorch 1.5.0 on AWS lambda. Since the torch library is very large, I need to make it as small as possible to fit within the size limits. My script looks like this so far:

    mkdir python
    docker run \
        --rm \
        -v $(pwd):/build \
        python:3.8 \
        sh -c "
            cd /build;
            pip3 install torch==1.5.0 -t python/torch --no-cache-dir;
            find . -type d -name '__pycache__' | xargs rm -rf;
            find . -type d -name 'tests' | xargs rm -rf;
            find . -type f -name '*.py[co]' | xargs rm -rf;
        ";

    zip -r9 torch.zip python;



But the resulting zip file is very large (500+ MB). However, one of the largest files in the installation package is libtorch_cuda.so. Removing that file makes the zip file less than half the size. I know that cuda is a library for GPUs, and since AWS lambda doesn't have a GPU, i don't need this support. But when I remove that file torch will not import correctly.

torch 1.4.0, by comparison, is much smaller because it did not by default include the cuda libraries.

I want torch 1.5.0 without the GPU support.

Is there a way to pip install torch==1.5.0 without gpu support? 

PyTorch also distributes CPU only versions, that you can install with pip. Although they aren't published to PyPI, so you need to get them from their own registry.

You can get the CPU version on PyTorch - Getting Started Locally by selecting CUDA: None.

pip install torch==1.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

