如何在没有GPU支持的情况下编译割炬1.5.0?

问题描述 投票:0回答:1

我想在AWS lambda上安装pytorch 1.5.0。由于割炬库非常大,因此我需要使其尽可能小以适合尺寸限制。到目前为止,我的脚本看起来像这样:

    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;

但是生成的zip文件非常大(500+ MB)。但是,安装包中最大的文件之一是libtorch_cuda.so。删除该文件会使zip文件的大小减小一半。我知道cuda是GPU的库,并且由于AWS lambda没有GPU,所以我不需要此支持。但是,当我删除该文件时,割炬将无法正确import

相比之下,火炬1.4.0小得多,因为默认情况下它不包括cuda库。

我想要没有GPU支持的手电筒1.5.0。

是否可以通过pip安装torch==1.5.0 gpu支持?

python-3.x aws-lambda pip pytorch
1个回答
0
投票

PyTorch还分发仅CPU版本,您可以通过pip安装。尽管它们尚未发布到PyPI,所以您需要从其自己的注册表中获取它们。

您可以通过选择CUDA在PyTorch - Getting Started Locally上获得CPU版本:

pip install torch==1.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
© www.soinside.com 2019 - 2024. All rights reserved.