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上部署時遇到類似上述的錯誤,請放心您並不孤單。 此錯誤會導致應用程式崩潰,通常與位於 runtimes 文件夾中的 IronCefSubprocess.exe 有關,這是 IronPDF 的關鍵組件。

可能的原因

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

  1. 缺少 IronCefSubprocess 的執行權限

    IronCefSubprocess.exe 必須具有執行權限,以便 IronPDF 正確初始化 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
VB   C#
  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 .
  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
VB   C#

如果以上解決方案都無法解決此問題,請提交一份工程需求尋求個人化幫助。