目录

AMD支持

TorchServe 可以在任何由 ROCm 支持的操作系统和设备组合上运行。 支持的 ROCm

支持的ROCm版本

当前稳定的major.patch版本的ROCm以及之前的路径版本将被支持。例如,版本N.2N.1N是当前的主要版本。

安装

  • 确保您的系统上已安装 Python >= 3.8

  • 克隆这个仓库

    git clone git@github.com:pytorch/serve.git
    
  • 进入克隆的文件夹

    cd serve
    
  • 创建一个Python虚拟环境

    python -m venv venv
    
  • 激活虚拟环境。如果您使用其他 shell(fish、csh、powershell)请使用相应的选项,从 /venv/bin/

    source venv/bin/activate
    
  • 安装所需的ROCm支持依赖项。

    python ./ts_scripts/install_dependencies.py --rocm=rocm61
    python ./ts_scripts/install_from_src.py
    
  • 在Python虚拟环境中启用AMD-SMI

    sudo chown -R $USER:$USER /opt/rocm/share/amd_smi/
    pip install -e /opt/rocm/share/amd_smi/
    

选择加速器使用 HIP_VISIBLE_DEVICES

如果您在运行TorchServe的系统中有多个加速器,您可以通过将环境变量HIP_VISIBLE_DEVICES设置为一个以逗号分隔的0索引整数字符串来选择哪些加速器应被TorchServe可见。

如果您有8个加速器,但只想让TorchServe看到最后四个,请执行export HIP_VISIBLE_DEVICES=4,5,6,7

ℹ️ Not setting HIP_VISIBLE_DEVICES will cause TorchServe to use all available accelerators on the system it is running on.

⚠️ You can run into trouble if you set HIP_VISIBLE_DEVICES to an empty string. eg. export HIP_VISIBLE_DEVICES= or export HIP_VISIBLE_DEVICES="" use unset HIP_VISIBLE_DEVICES if you want to remove its effect.

⚠️ Setting both CUDA_VISIBLE_DEVICES and HIP_VISIBLE_DEVICES may cause unintended behaviour and should be avoided. Doing so may cause an exception in the future.

Docker

在开发中

Dockerfile.rocm 提供初步的ROCm支持用于TorchServe。

构建和运行 dev-image:

docker build --file docker/Dockerfile.rocm --target dev-image -t torch-serve-dev-image-rocm --build-arg USE_ROCM_VERSION=rocm62 --build-arg BUILD_FROM_SRC=true .

docker run -it --rm --device=/dev/kfd --device=/dev/dri torch-serve-dev-image-rocm bash

示例用法

安装完TorchServe并配置好ROCm所需的依赖后,您就可以开始为您的模型提供服务了。

对于一个简单的示例,请参见serve/examples/image_classifier/mnist/

文档

访问 PyTorch 的全面开发人员文档

查看文档

教程

获取面向初学者和高级开发人员的深入教程

查看教程

资源

查找开发资源并解答您的问题

查看资源