From f126b81e2040a207e40f17345df32b3331671d14 Mon Sep 17 00:00:00 2001 From: Valina Li Date: Wed, 3 Jan 2024 11:02:07 -0800 Subject: [PATCH] fix: docker compose up failed with "Error: configuration file not found or cannot open" (#436) * fix: docker compose up failed with "Error: configuration file not found or cannot open" closes: #434 Signed-off-by: Jim Wang Signed-off-by: Valina Li --- Makefile | 2 + configs/opencv-ovms/cmd_client/main.go | 37 ++++++++++++++++++- .../models/2022/config_template.json | 2 +- .../scripts/gen_ovms_model_config_json.sh | 9 +++++ docker-compose.yml | 10 ++--- 5 files changed, 52 insertions(+), 8 deletions(-) create mode 100755 configs/opencv-ovms/scripts/gen_ovms_model_config_json.sh diff --git a/Makefile b/Makefile index dff1c158..f2e23765 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,7 @@ run-portainer: docker compose -p portainer -f docker-compose-portainer.yml up -d run-pipelines: + @./scripts/gen_ovms_model_config_json.sh docker compose -f docker-compose.yml up -d clean: @@ -114,6 +115,7 @@ down-portainer: down-pipelines: docker compose -f docker-compose.yml down + @rm ./configs/opencv-ovms/models/2022/config.json clean-all: clean clean-ovms clean-simulator clean-results clean-telegraf clean-webcam down-pipelines diff --git a/configs/opencv-ovms/cmd_client/main.go b/configs/opencv-ovms/cmd_client/main.go index a43f90ca..93119231 100644 --- a/configs/opencv-ovms/cmd_client/main.go +++ b/configs/opencv-ovms/cmd_client/main.go @@ -137,8 +137,9 @@ type OvmsClientConfig struct { } type Flags struct { - FlagSet *flag.FlagSet - configDir string + FlagSet *flag.FlagSet + configDir string + oVMSModelConfigDir string } func main() { @@ -148,12 +149,15 @@ func main() { } flagSet.StringVar(&flags.configDir, "configDir", filepath.Join(".", resourceDir), "") flagSet.StringVar(&flags.configDir, "cd", filepath.Join(".", resourceDir), "") + flagSet.StringVar(&flags.oVMSModelConfigDir, "genOVMSModelConfig", "", "") err := flags.FlagSet.Parse(os.Args[1:]) if err != nil { flagSet.Usage() log.Fatalln(err) } + flags.genOVMSModelConfig() + // the config yaml file is in res/ folder of the "pipeline profile" directory contents, err := flags.readPipelineConfig() if err != nil { @@ -665,3 +669,32 @@ func (flags *Flags) readPipelineConfig() ([]byte, error) { return contents, err } + +func (flags *Flags) genOVMSModelConfig() { + if len(flags.oVMSModelConfigDir) > 0 { + log.Println("generate config.json file for docker compose up case...") + + deviceUpdater := server.NewDeviceUpdater(flags.oVMSModelConfigDir, ovmsTemplateConfigJson) + targetDevice := defaultTargetDevice + if len(os.Getenv(TARGET_DEVICE_ENV)) > 0 { + // only set the value from env if env is not empty; otherwise defaults to the default value in defaultTargetDevice + // devices supported CPU, GPU, GPU.x, AUTO, MULTI:GPU,CPU + targetDevice = os.Getenv(TARGET_DEVICE_ENV) + } + + log.Println("Updating config with DEVICE environment variable:", targetDevice) + + newUpdateConfigJson := "config.json" + + if err := deviceUpdater.UpdateDeviceAndCreateJson(targetDevice, filepath.Join(flags.oVMSModelConfigDir, newUpdateConfigJson)); err != nil { + log.Printf("Error: failed to update device and produce a new ovms server config json: %v", err) + os.Exit(1) + } + + configJsonContainer := filepath.Join("/models", newUpdateConfigJson) + log.Println("configJsonContainer:", configJsonContainer) + os.Exit(0) + } else { + log.Println("no OVMS Model config input, skip...") + } +} diff --git a/configs/opencv-ovms/models/2022/config_template.json b/configs/opencv-ovms/models/2022/config_template.json index a047e546..969dd367 100644 --- a/configs/opencv-ovms/models/2022/config_template.json +++ b/configs/opencv-ovms/models/2022/config_template.json @@ -51,7 +51,7 @@ { "config": { "name": "efficientnet-b0", - "base_path": "/models/efficientnet-b0/FP32", + "base_path": "/models/efficientnet-b0/FP32-INT8", "target_device": "{target_device}" }, "latest": { diff --git a/configs/opencv-ovms/scripts/gen_ovms_model_config_json.sh b/configs/opencv-ovms/scripts/gen_ovms_model_config_json.sh new file mode 100755 index 00000000..13ac9446 --- /dev/null +++ b/configs/opencv-ovms/scripts/gen_ovms_model_config_json.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# +# Copyright (C) 2023 Intel Corporation. +# +# SPDX-License-Identifier: Apache-2.0 +# + +DEVICE="$DEVICE" \ +./profile-launcher --genOVMSModelConfig ./configs/opencv-ovms/models/2022 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 25a52281..00be49cc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,7 +44,7 @@ services: command: " -nostdin -re -stream_loop -1 - -i /home/pipeline-server/sample-media/couple-paying-at-the-counter-in-the-grocery-4121754-3840-15-bench.mp4 + -i /home/pipeline-server/sample-media/vehicle-bike-1920-15-bench.mp4 -c copy -f rtsp -rtsp_transport @@ -65,7 +65,7 @@ services: command: " -nostdin -re -stream_loop -1 - -i /home/pipeline-server/sample-media/vehicle-bike-3840-15-bench.mp4 + -i /home/pipeline-server/sample-media/video_of_people_walking_855564-1920-15-bench.mp4 -c copy -f rtsp -rtsp_transport @@ -106,7 +106,7 @@ services: environment: - CONTAINER_NAME="object-detection0" - GRPC_PORT=9001 - - INPUTSRC=rtsp://localhost:8554/camera_0 + - INPUTSRC=rtsp://localhost:8554/camera_1 - cid_count=0 - DETECTION_MODEL_NAME=ssd_mobilenet_v1_coco - DETECTION_LABEL_FILE=coco_91cl_bkgr.txt @@ -131,7 +131,7 @@ services: environment: - CONTAINER_NAME="object-detection1" - GRPC_PORT=9001 - - INPUTSRC=rtsp://localhost:8554/camera_0 + - INPUTSRC=rtsp://localhost:8554/camera_2 - cid_count=1 - DETECTION_MODEL_NAME=ssd_mobilenet_v1_coco - DETECTION_LABEL_FILE=coco_91cl_bkgr.txt @@ -156,7 +156,7 @@ services: environment: - CONTAINER_NAME="classification2" - GRPC_PORT=9001 - - INPUTSRC=rtsp://localhost:8554/camera_1 + - INPUTSRC=rtsp://localhost:8554/camera_0 - cid_count=2 - CLASSIFICATION_MODEL_NAME=efficientnet-b0 - CLASSIFICATION_LABEL_FILE=imagenet_2012.txt