IronPDF 中的 GPU 處理問題:解決方案

This article was translated from English: Does it need improvement?
Translated
View the article in English
[0110/094441.173:ERROR:network_service_instance_impl.cc(521)] Network service crashed, restarting service.
[0110/094442.261:ERROR:gpu_process_host.cc(990)] GPU process exited unexpectedly: exit_code=255
[0110/094442.261:WARNING:gpu_process_host.cc(1337)] The GPU process has crashed 3 time(s)
[0110/094442.261:FATAL:gpu_data_manager_impl_private.cc(440)] GPU process isn't usable. Goodbye.

如果您在使用IronPDF時,特別是在Azure上部署時遇到類似上述的錯誤,請放心您並不孤單。 此錯誤已知會導致應用程式崩潰,通常與執行時期資料夾中的 IronCefSubprocess.exe 有關,這是 IronPDF 的關鍵組成部分。

可能的原因

數個因素可能導致這個 GPU 處理錯誤。 以下是一些最常見的原因:

  1. 缺少IronCefSubprocess的執行許可權

    IronPDF 必須賦予 IronCefSubprocess.exe 執行權限,以便正確初始化 ChromePdfRenderer 類別。

  2. 不正確的 Azure 部署步驟

    在 Azure 中,IronPDF 的部署流程在 Linux 和 Windows 之間有所不同。 遵循錯誤的步驟可能會觸發此錯誤。

  3. 缺少 DLL 依賴項

    IronCefSubprocess.exe需要某些DLL文件才能正常運行。 缺少 DLL 檔案,尤其是在非 Windows 環境中,可能會導致程序失敗。

解決方案

本地環境

如果您在本地遇到此錯誤,請嘗試以下步驟:

  1. 停用 GPU 模式

    將以下行添加到您的代碼中以禁用 IronPDF 的 GPU 模式:

IronPdf.Installation.ChromeGpuMode = IronPdf.Engines.Chrome.ChromeGpuModes.Disabled;
IronPdf.Installation.ChromeGpuMode = IronPdf.Engines.Chrome.ChromeGpuModes.Disabled;
IronPdf.Installation.ChromeGpuMode = IronPdf.Engines.Chrome.ChromeGpuModes.Disabled
$vbLabelText   $csharpLabel
  1. 授予執行權限

    確保 IronCefSubprocess.exe 具有執行權限。 對於 Linux 系統,使用以下命令:

chmod 755 IronCefSubprocess 
# You may need to specify an exact path
# IronCefSubprocess is typically found at bin/runtimes/linux-x64/
# chmod 755 /bin/runtimes/linux-x64/native/IronCefSubprocess
# in some cases you may need to use chmod 777 .
chmod 755 IronCefSubprocess 
# You may need to specify an exact path
# IronCefSubprocess is typically found at bin/runtimes/linux-x64/
# chmod 755 /bin/runtimes/linux-x64/native/IronCefSubprocess
# in some cases you may need to use chmod 777 .
SHELL
  1. 檢查缺少的DLL

    如果上述步驟無法解決問題,請手動執行IronCefSubprocess.exe以檢查遺失的 DLL。 系統將顯示一個錯誤框,標明缺少的 DLL。 安裝所需的 DLL 並重新運行應用程式。

Azure 部署

如果錯誤發生在將您的應用程式部署到Azure之後,請按照以下步驟操作:

  1. 使用 ZipDeploy

    使用 ZipDeploy 部署您的應用程式,以確保所有文件都正確打包。

  2. 取消勾選從封裝文件執行

    確保在部署期間取消勾選**從包文件運行**選項。

  3. 容器化至 Linux

    如果您的應用程式目標是Linux環境,請考慮在部署到Azure之前使用Docker進行容器化。 請參考Docker 安裝指南以獲取詳細說明。

  4. 啟用單一行程模式

    將以下程式碼加入以強制 IronPDF 以單進程模式運行:

IronPdf.Installation.SingleProcess = true;
IronPdf.Installation.SingleProcess = true;
IronPdf.Installation.SingleProcess = True
$vbLabelText   $csharpLabel

如果上述解決方案均無法解決問題,請提交工程請求以獲取個人化協助。