⚠️ 注意:有限維護
此專案不再積極維護。現有版本仍然可用,但沒有計劃中的更新、錯誤修復、新功能或安全補丁。使用者應注意,漏洞可能不會得到解決。
Windows 上的 TorchServe¶
本文件目錄¶
先決條件¶
目前,它僅在 Windows Server 2019 上獲得認證,但在 Windows 10 上也應能正常工作。
確保您是管理員使用者或具有管理員許可權
此處給出的說明將使用 anaconda Powershell 終端安裝 torchserve
按照此處的說明安裝 Anaconda
按照此處的說明安裝 Git
安裝 openjdk17
解壓並編輯/新增環境變數,例如 PATH 和 JAVA_HOME
使用命令列
unzip jdk-17.0.3_windows-x64_bin.zip或使用 GUI 介面編輯系統或使用者配置檔案環境變數
PATH的值,並在其後追加路徑<your-openjdk17-path>\bin
安裝 nodejs
下載nodejs
安裝後請確保 nodejs 和 npm node 模組二進位制檔案存在於 PATH 環境變數中。
如果您的“Anaconda Powershell Prompt”(APP)無法檢測到 npm 或 nodejs 命令,您可能需要重啟 Windows
從二進位制檔案安裝¶
注意:目前,PyPi 上沒有提供適用於 Windows 的 wheel 檔案。但是,如果您有預構建的適用於 Windows 的 torchserve wheel 檔案,也可以使用以下步驟。
以管理員使用者身份啟動“Anaconda Powershell Prompt”(APP),即右鍵單擊 APP 並執行以下命令
git clone https://github.com/pytorch/serve.gitcd servepython .\ts_scripts\install_dependencies.py對於本地 wheel 檔案
pip install <your-torchserve-wheel-file-name>.whl
對於 PyPi 包(目前不適用)
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++ 可再發行元件
注意:請確保在安裝上述 Visual C++ 元件後已重啟系統
確保 ‘nvidia-smi.exe’ 在
Path環境變數中可用。通常,它應該位於<your_install_drive>\Program Files\NVIDIA Corporation\NVSMI下,例如 C:\Program Files\NVIDIA Corporation\NVSMI,將此路徑新增到Path環境變數中。以管理員使用者身份啟動“Anaconda Powershell Prompt”(APP),即右鍵單擊 APP 並執行以下命令
git clone https://github.com/pytorch/serve.gitpip install clickcd serve
用於生產環境,使用以下命令:¶
python .\ts_scripts\install_dependencies.py --environment=prodpython .\ts_scripts\install_from_src.py
用於開發目的,使用以下命令:¶
如果您計劃使用 TorchServe 進行開發並修改部分原始碼,以下命令會有所幫助。install_dependencies 指令碼會安裝一些開發和測試所需的額外依賴項。
python .\ts_scripts\install_dependencies.py --environment=devpython .\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中指定。如果
curl命令執行失敗,則在 APP (anaconda powershell prompt) 上執行以下命令Remove-item alias:curl。有關詳細資訊,請參閱此 SO 回答。