Windows 上的 TorchServe¶
本文档的内容¶
先决条件¶
目前,它仅在 Windows Server 2019 上通过了认证,但应该可以在 Windows 10 上运行良好。
确保您是管理员用户或具有管理员权限
这里给出的说明将使用 anaconda Powershell 终端来安装 torchserve
按照此处给出的方式安装 Anaconda
按照此处给出的方式安装 Git
安装 openjdk17
下载 openjdk17
解压缩并编辑/添加环境变量,即 PATH 和 JAVA_HOME 例如
使用命令行或使用 GUI 界面
unzip jdk-17.0.3_windows-x64_bin.zip
编辑系统或用户配置文件环境变量值并为其附加路径
PATH
<your-openjdk17-path>\bin
安装 nodejs
下载 nodejs
安装后,请确保 nodejs 和 npm node modules 二进制文件存在于 PATH 环境变量中。
如果您的“Anaconda Powershell Prompt”(APP) 无法检测到 npm 或 nodejs 命令,您可能必须重新启动 Windows
从二进制文件安装¶
注意 目前,PyPi 上没有适用于 Windows 的轮子。但是,如果您有适用于 Windows 的预构建 torchserve wheel,也可以使用以下步骤。
以管理员用户身份启动“Anaconda Powershell Prompt”(APP),即右键单击 APP 并运行以下命令
git clone https://github.com/pytorch/serve.git
cd serve
python .\ts_scripts\install_dependencies.py
对于本地 wheel file
pip install <your-torchserve-wheel-file-name>.whl
对于 PyPi 包(目前为 N/A)
pip install torchserve torch-model-archiver
启动 torchserve
torchserve.exe --start --model-store <path-to-model-store>
有关后续步骤,请参阅 为模型提供服务
从源码安装¶
确保存在值为路径的系统或用户配置文件环境变量名称。
JAVA_HOME
<your-openjdk17-path>
安装适用于 Visual Studio 2015、2017 和 2019 的 Microsoft Visual C++ Redistributable
注意:确保在安装上述 Visual C++ 组件后已重新启动系统
确保 'nvidia-smi.exe' 在环境变量中可用。通常,它应该在 C:\Program Files\NVIDIA Corporation\NVSMI 下可用,将此路径添加到 env 变量
Path
<your_install_drive>\Program Files\NVIDIA Corporation\NVSMI
Path
以管理员用户身份启动“Anaconda Powershell Prompt”(APP),即右键单击 APP 并运行以下命令
git clone https://github.com/pytorch/serve.git
pip install click
cd serve
对于生产用途,请使用以下命令:¶
python .\ts_scripts\install_dependencies.py --environment=prod
python .\ts_scripts\install_from_src.py
出于开发目的,请使用以下命令:¶
如果您计划使用 TorchServe 进行开发并更改一些源代码,以下命令将有所帮助。 install_dependencies 脚本安装开发和测试所需的一些额外依赖项。
python .\ts_scripts\install_dependencies.py --environment=dev
python .\ts_scripts\install_from_src.py
故障 排除¶
如果您从源进行构建,则可能必须更改 中指定的推理、管理和指标 API 的端口号 。 和 中的所有文件
frontend/server/src/test/resources/config.properties
frontend/server/src/test/resources/snapshot/*
frontend/server/src/main/java/org/pytorch/serve/util/ConfigManager.java
如果命令执行失败,则在 APP 上运行以下命令(anaconda powershell 提示符)有关详细信息,请参阅此 SO 答案。
curl
Remove-item alias:curl