随着人工智能技术的迅猛发展,目标检测成为了浩繁应用场景中的焦点技术之一。YOLO(You Only Look Once)系列作为实时目标检测领域的代表,已经发展到了YOLOv11版本。同时,.NET平台也在不断迭代升级,最新版本已发布至.NET 9。然而,实际项目中大概会遇到各种环境限制和兼容性问题,特别是在老旧系统如CentOS 7上举行部署时。本文将详细记录我在CentOS 7上部署ASP.NET 8.0结合YOLOv11目标检测项目过程中遇到的问题及解决方案,旨在为有雷同需求的开发者提供参考。
2. 项目配景
项目标需求非常简单,需要一个目标检测的 Web 服务,实现发送照片到服务器,服务器返回照片中的目标位置信息。这里我们接纳 ASP.NET 8.0 作为 Web 服务的后端框架,YOLOv11 作为目标检测的算法,利用了YoloSharp 库来实现目标检测的功能。
整体开发过程还是非常顺利的,由于接纳了 .NET ,所以可以非常方便的在 Windows 开发后发布各个平台的版本,并可以选择发布独立的不依赖.NET框架的版本。但是在 CentOS 7 上部署时,由于系统环境的限制,导致了一系列问题。下面将详细记录这些问题及解决方案。
Process terminated. Couldn't find a valid ICU package installed on the system. Please install libicu (or icu-libs) using your package manager and try again. Alternatively you can set the configuration flag System.Globalization.Invariant to tase see https://aka.ms/dotnet-missing-libicu for more information.
at System.Environment.FailFast(System.String)
at System.Globalization.GlobalizationMode+Settings..cctor()
Connection id "0HNAB1PQ9LV69", Request id "0HNAB1PQ9LV69:00000001": An unhandled exception was thrown by the application.
System.TypeInitializationException: The type initializer for 'Microsoft.ML.OnnxRuntime.NativeMethods' threw an exception.
---> System.DllNotFoundException: Unable to load shared library 'onnxruntime' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DE
/root/ai/onnxruntime.so: cannot open shared object file: No such file or directory
/lib64/libm.so.6: version `GLIBC_2.27' not found (required by /root/ai/libonnxruntime.so)
libonnxruntime.so: cannot open shared object file: No such file or directory
/root/ai/onnxruntime: cannot open shared object file: No such file or directory
/root/ai/libonnxruntime: cannot open shared object file: No such file or directory