codeproject / CodeProject.AI-Server

CodeProject.AI Server is a self contained service that software developers can include in, and distribute with, their applications in order to augment their apps with the power of AI.
Other
565 stars 135 forks source link

ObjectDetectionCoral stops working when restarting the docker container. #101

Open mikegleasonjr opened 2 months ago

mikegleasonjr commented 2 months ago

Area of Concern

Describe the bug

  1. I am running a docker container with the codeproject/ai-server image with 2 volumes (so that I can restart it without having to reinstall/reconfigure everything):
    • /etc/codeproject/ai
    • /app/modules
  2. I installed the Object Detection (Coral) module, which worked fine with my TPU. I called the API and verified that everything was working.
  3. I stopped the container
  4. I started back the container
  5. The module now has this error: objectdetection_coral_adapter.py: An exception occurred initialising the module: libedgetpu.so.1: cannot open shared object file: No such file or dir

Expected behavior The module restarts properly in the docker container.

I know what the problem actually is: In ObjectDetectionCoral/install.sh, there is a line to copy the shared library in /usr/lib/x86_64-linux-gnu/ upon module installation:

cp "${moduleDirPath}/edgetpu_runtime/${edgetpu_folder}/k8/libedgetpu.so.1.0" "/usr/lib/x86_64-linux-gnu/libedgetpu.so.1.0"

Obvisouly when restarting the container, this change is lost since I do not mount /usr/lib/x86_64-linux-gnu/ as a volume to be persistent across "reboots".

I don't know if modules have a startup hook where these steps of copying the shared object and running of ldconfig could be done there?

Screenshots N/A

Your System (please complete the following information):

Additional context See Expected behavior

matthewDDennis commented 2 months ago

How are you starting the Docker container?

mikegleasonjr commented 2 months ago

Hi @matthewDDennis, thanks for the help. It is my feeling that the bug report wasn't fully understood though. The bug is actually known and described in the "Expected behavior" section (at least I tried to explain it). This isn't about Docker not restarting the container.

Please feel free to ask questions if it is still misunderstood 🙏🏻

mikegleasonjr commented 2 months ago

Maybe the ObjectDetectionCoral module should redo some steps it does upon installation in the initialise phase of the module: https://www.codeproject.com/ai/docs/devguide/module_examples/add_python_module.html#writing-the-module

It copies files into the host at the location: /usr/lib/x86_64-linux-gnu/. Those files are obviously lost when restarting the container.

There is no mention about mounting other volumes other than the settings/module folders in the documentation: https://www.codeproject.com/ai/docs/install/running_in_docker.html#advanced-docker-launch-settings-saved-outside-of-the-container