forked from openvinotoolkit/model_server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
592 lines (526 loc) · 22.6 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
#
# Copyright (c) 2020-2022 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# workaround for docker clipping build step logs
BUILDKIT_STEP_LOG_MAX_SIZE=500000000
BUILDKIT_STEP_LOG_MAX_SPEED=10000000
VIRTUALENV_EXE := python3 -m virtualenv -p python3
VIRTUALENV_DIR := .venv
ACTIVATE="$(VIRTUALENV_DIR)/bin/activate"
STYLE_CHECK_OPTS := --extensions=hpp,cc,cpp,h \
--output=vs7 \
--recursive \
--linelength=120 \
--filter=-build/c++11,-runtime/references,-whitespace/braces,-whitespace/indent,-build/include_order,-runtime/indentation_namespace,-build/namespaces,-whitespace/line_length,-runtime/string,-readability/casting,-runtime/explicit,-readability/todo
STYLE_CHECK_DIRS := src demos/common/cpp/src demos/image_classification/cpp demos/benchmark/cpp
HTTP_PROXY := "$(http_proxy)"
HTTPS_PROXY := "$(https_proxy)"
NO_PROXY := "$(no_proxy)"
ifeq ($(shell uname),Darwin)
# MacOS
CORES_TOTAL := $(shell sysctl -n hw.physicalcpu)
else
# Ubuntu & Redhat
CORES_PER_SOCKET := $(shell lscpu | awk '/^Core\(s\) per socket:/ {print $$NF}')
SOCKETS := $(shell lscpu | awk '/^Socket\(s\):/ {print $$NF}')
CORES_TOTAL := $$(($(SOCKETS) * $(CORES_PER_SOCKET)))
endif
JOBS ?= $(CORES_TOTAL)
# Image on which OVMS is compiled. If DIST_OS is not set, it's also used for a release image.
# Currently supported BASE_OS values are: ubuntu redhat
BASE_OS ?= ubuntu
# do not change this; change versions per OS a few lines below (BASE_OS_TAG_*)!
BASE_OS_TAG ?= latest
BASE_OS_TAG_UBUNTU ?= 20.04
BASE_OS_TAG_REDHAT ?= 8.8
INSTALL_RPMS_FROM_URL ?=
CHECK_COVERAGE ?=0
RUN_TESTS ?= 1
NVIDIA ?=0
GPU ?= 0
BUILD_NGINX ?= 0
MEDIAPIPE_DISABLE ?= 0
PYTHON_DISABLE ?= 0
FUZZER_BUILD ?= 0
# NOTE: when changing any value below, you'll need to adjust WORKSPACE file by hand:
# - uncomment source build section, comment binary section
# - adjust binary version path - version variable is not passed to WORKSPACE file!
OV_SOURCE_BRANCH ?= ddc395b6cb7bccba0e18687da65bf58c059f49d8 # 12.06.2023
OV_CONTRIB_BRANCH ?= 651a3a0e74caef0361a36a54a9ea737609fd5aea # 12.06.2023
OV_SOURCE_ORG ?= openvinotoolkit
OV_CONTRIB_ORG ?= openvinotoolkit
SENTENCEPIECE ?= 1
OV_USE_BINARY ?= 0
APT_OV_PACKAGE ?= openvino-2022.1.0
# opt, dbg:
BAZEL_BUILD_TYPE ?= opt
CMAKE_BUILD_TYPE ?= Release
MINITRACE ?= OFF
ifeq ($(MEDIAPIPE_DISABLE),1)
DISABLE_MEDIAPIPE_PARAMS = " --define MEDIAPIPE_DISABLE=1 --cxxopt=-DMEDIAPIPE_DISABLE=1"
else
DISABLE_MEDIAPIPE_PARAMS = " --define MEDIAPIPE_DISABLE=0 --cxxopt=-DMEDIAPIPE_DISABLE=0"
endif
ifeq ($(PYTHON_DISABLE),1)
DISABLE_PYTHON_PARAMS = " --define PYTHON_DISABLE=1 --cxxopt=-DPYTHON_DISABLE=1"
else
DISABLE_PYTHON_PARAMS = " --define PYTHON_DISABLE=0 --cxxopt=-DPYTHON_DISABLE=0"
endif
FUZZER_BUILD_PARAMS ?= ""
ifeq ($(FUZZER_BUILD),1)
FUZZER_BUILD_PARAMS = " --define FUZZER_BUILD=1 --cxxopt=-DFUZZER_BUILD=1"
endif
STRIP = "always"
BAZEL_DEBUG_BUILD_FLAGS ?= ""
ifeq ($(BAZEL_BUILD_TYPE),dbg)
BAZEL_DEBUG_BUILD_FLAGS = " --copt=-g -c dbg"
STRIP = "never"
endif
ifeq ($(MINITRACE),ON)
MINITRACE_FLAGS=" --copt=-DMTR_ENABLED"
else
MINITRACE_FLAGS=""
endif
BAZEL_DEBUG_FLAGS="--strip=$(STRIP)"$(BAZEL_DEBUG_BUILD_FLAGS)$(DISABLE_MEDIAPIPE_PARAMS)$(DISABLE_PYTHON_PARAMS)$(FUZZER_BUILD_PARAMS)
# Option to Override release image.
# Release image OS *must have* glibc version >= glibc version on BASE_OS:
DIST_OS ?= $(BASE_OS)
DIST_OS_TAG ?= $(BASE_OS_TAG)
ifeq ($(findstring ubuntu,$(BASE_OS)),ubuntu)
BASE_OS_TAG=$(BASE_OS_TAG_UBUNTU)
ifeq ($(BASE_OS),ubuntu22)
BASE_OS_TAG=22.04
endif
ifeq ($(BASE_OS),ubuntu20)
BASE_OS_TAG=20.04
endif
OS=ubuntu
ifeq ($(NVIDIA),1)
BASE_IMAGE=docker.io/nvidia/cuda:11.8.0-runtime-ubuntu$(BASE_OS_TAG)
BASE_IMAGE_RELEASE=$(BASE_IMAGE)
else
BASE_IMAGE ?= ubuntu:$(BASE_OS_TAG)
BASE_IMAGE_RELEASE=$(BASE_IMAGE)
endif
ifeq ($(BASE_OS_TAG),20.04)
INSTALL_DRIVER_VERSION ?= "22.43.24595"
DLDT_PACKAGE_URL ?= http://s3.toolbox.iotg.sclab.intel.com/ov-packages/l_openvino_toolkit_ubuntu20_2023.3.0.13513.ddc395b6cb7_x86_64.tgz
else ifeq ($(BASE_OS_TAG),22.04)
INSTALL_DRIVER_VERSION ?= "23.22.26516"
DLDT_PACKAGE_URL ?= http://s3.toolbox.iotg.sclab.intel.com/ov-packages/l_openvino_toolkit_ubuntu22_2023.3.0.13513.ddc395b6cb7_x86_64.tgz
endif
endif
ifeq ($(BASE_OS),redhat)
BASE_OS_TAG=$(BASE_OS_TAG_REDHAT)
OS=redhat
ifeq ($(NVIDIA),1)
BASE_IMAGE=docker.io/nvidia/cuda:11.8.0-runtime-ubi8
BASE_IMAGE_RELEASE=$(BASE_IMAGE)
else
BASE_IMAGE ?= registry.access.redhat.com/ubi8/ubi:$(BASE_OS_TAG_REDHAT)
BASE_IMAGE_RELEASE=registry.access.redhat.com/ubi8/ubi-minimal:$(BASE_OS_TAG_REDHAT)
endif
DIST_OS=redhat
INSTALL_DRIVER_VERSION ?= "23.22.26516"
DLDT_PACKAGE_URL ?= http://s3.toolbox.iotg.sclab.intel.com/ov-packages/l_openvino_toolkit_rhel8_2023.3.0.13513.ddc395b6cb7_x86_64.tgz
endif
OVMS_CPP_DOCKER_IMAGE ?= openvino/model_server
ifeq ($(BAZEL_BUILD_TYPE),dbg)
OVMS_CPP_DOCKER_IMAGE:=$(OVMS_CPP_DOCKER_IMAGE)-dbg
endif
OVMS_CPP_IMAGE_TAG ?= latest
ifeq ($(NVIDIA),1)
IMAGE_TAG_SUFFIX = -cuda
endif
OVMS_PYTHON_IMAGE_TAG ?= py
PRODUCT_NAME = "OpenVINO Model Server"
PRODUCT_VERSION ?= "2023.3.0"
PROJECT_VER_PATCH =
$(eval PROJECT_VER_PATCH:=`git rev-parse --short HEAD`)
$(eval PROJECT_NAME:=${PRODUCT_NAME})
$(eval PROJECT_VERSION:=${PRODUCT_VERSION}.${PROJECT_VER_PATCH})
OVMS_CPP_CONTAINER_NAME ?= "server-test-${PROJECT_VER_PATCH}-$(shell date +%Y-%m-%d-%H.%M.%S)"
OVMS_CPP_CONTAINER_PORT ?= 9178
PYTHON_CLIENT_TEST_GRPC_PORT ?= 9279
PYTHON_CLIENT_TEST_REST_PORT ?= 9280
PYTHON_CLIENT_TEST_CONTAINER_NAME ?= python-client-test$(shell date +%Y-%m-%d-%H.%M.%S)
TEST_PATH ?= tests/functional/
BUILD_CUSTOM_NODES ?= false
BUILD_ARGS = --build-arg http_proxy=$(HTTP_PROXY)\
--build-arg https_proxy=$(HTTPS_PROXY)\
--build-arg no_proxy=$(NO_PROXY)\
--build-arg ov_source_branch=$(OV_SOURCE_BRANCH)\
--build-arg ov_source_org=$(OV_SOURCE_ORG)\
--build-arg ov_contrib_org=$(OV_CONTRIB_ORG)\
--build-arg ov_use_binary=$(OV_USE_BINARY)\
--build-arg sentencepiece=$(SENTENCEPIECE)\
--build-arg DLDT_PACKAGE_URL=$(DLDT_PACKAGE_URL)\
--build-arg CHECK_COVERAGE=$(CHECK_COVERAGE)\
--build-arg RUN_TESTS=$(RUN_TESTS)\
--build-arg FUZZER_BUILD=$(FUZZER_BUILD)\
--build-arg debug_bazel_flags=$(BAZEL_DEBUG_FLAGS)\
--build-arg minitrace_flags=$(MINITRACE_FLAGS) \
--build-arg CMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)\
--build-arg PROJECT_VERSION=$(PROJECT_VERSION)\
--build-arg BASE_IMAGE=$(BASE_IMAGE)\
--build-arg NVIDIA=$(NVIDIA)\
--build-arg ov_contrib_branch=$(OV_CONTRIB_BRANCH)\
--build-arg INSTALL_RPMS_FROM_URL=$(INSTALL_RPMS_FROM_URL)\
--build-arg INSTALL_DRIVER_VERSION=$(INSTALL_DRIVER_VERSION)\
--build-arg GPU=$(GPU)\
--build-arg RELEASE_BASE_IMAGE=$(BASE_IMAGE_RELEASE)\
--build-arg JOBS=$(JOBS)
.PHONY: default docker_build \
default: docker_build
venv:$(ACTIVATE)
@echo $(BUILD_ARGS)
@echo -n "Using venv "
@. $(ACTIVATE); python3 --version
$(ACTIVATE):
@echo "Updating virtualenv dependencies in: $(VIRTUALENV_DIR)..."
@test -d $(VIRTUALENV_DIR) || $(VIRTUALENV_EXE) $(VIRTUALENV_DIR)
@. $(ACTIVATE); pip3 install --upgrade pip
@. $(ACTIVATE); pip3 install -vUqq setuptools
@. $(ACTIVATE); pip3 install -qq -r tests/requirements.txt
@touch $(ACTIVATE)
cppclean: venv
@echo "Checking cppclean..."
@. $(ACTIVATE); bash -c "./ci/cppclean.sh"
style: venv clang-format-check cpplint cppclean
hadolint:
@echo "Checking SDL requirements..."
@echo "Checking docker files..."
@./tests/hadolint.sh
bandit:
@echo "Checking python files..."
@. $(ACTIVATE); bash -c "./ci/bandit.sh"
license-headers:
@echo "Checking license headers in files..."
@. $(ACTIVATE); bash -c "python3 ./ci/lib_search.py . > missing_headers.txt"
@if ! grep -FRq "All files have headers" missing_headers.txt; then\
echo "Files with missing headers";\
cat missing_headers.txt;\
exit 1;\
fi
@rm missing_headers.txt
sdl-check: venv hadolint bandit license-headers
@echo "Checking forbidden functions in files..."
@. $(ACTIVATE); bash -c "python3 ./ci/lib_search.py . functions > forbidden_functions.txt"
@if ! grep -FRq "All files checked for forbidden functions" forbidden_functions.txt; then\
error Run python3 ./ci/lib_search.py . functions - to see forbidden functions file list.;\
fi
@rm forbidden_functions.txt
cpplint: venv
@echo "Style-checking codebase..."
@. $(ACTIVATE); echo ${PWD}; cpplint ${STYLE_CHECK_OPTS} ${STYLE_CHECK_DIRS}
clang-format: venv
@echo "Formatting files with clang-format.."
@. $(ACTIVATE); find ${STYLE_CHECK_DIRS} -regex '.*\.\(cpp\|hpp\|cc\|cxx\)' -exec clang-format -style=file -i {} \;
clang-format-check: clang-format
@echo "Checking if clang-format changes were committed ..."
@git diff --exit-code || (echo "clang-format changes not commited. Commit those changes first"; exit 1)
@git diff --exit-code --staged || (echo "clang-format changes not commited. Commit those changes first"; exit 1)
.PHONY: docker_build
docker_build: ovms_builder_image targz_package ovms_release_images
ovms_builder_image:
ifeq ($(PYTHON_DISABLE),0)
ifeq ($(MEDIAPIPE_DISABLE),1)
@echo "Cannot build model server with Python support without building with Mediapipe enabled. Use 'MEDIAPIPE_DISABLE=0 PYTHON_DISABLE=0 make docker_build'"; exit 1 ;
endif
endif
ifeq ($(CHECK_COVERAGE),1)
ifeq ($(RUN_TESTS),0)
@echo "Cannot test coverage without running tests. Use 'CHECK_COVERAGE=1 RUN_TESTS=1 make docker_build'"; exit 1 ;
endif
endif
ifeq ($(FUZZER_BUILD),1)
ifeq ($(RUN_TESTS),1)
@echo "Cannot run tests for now with fuzzer build"; exit 1 ;
endif
ifeq ($(CHECK_COVERAGE),1)
@echo "Cannot check coverage with fuzzer build"; exit 1 ;
endif
ifeq ($(BASE_OS),redhat)
@echo "Cannot run fuzzer with redhat"; exit 1 ;
endif
endif
ifeq ($(NVIDIA),1)
ifeq ($(OV_USE_BINARY),1)
@echo "Building NVIDIA plugin requires OV built from source. To build NVIDIA plugin and OV from source make command should look like this 'NVIDIA=1 OV_USE_BINARY=0 make docker_build'"; exit 1 ;
endif
endif
ifeq ($(BASE_OS),redhat)
@mkdir -p entitlement
@mkdir -p rhsm-ca
endif
ifeq ($(NO_DOCKER_CACHE),true)
$(eval NO_CACHE_OPTION:=--no-cache)
@echo "Docker image will be rebuilt from scratch"
@docker pull $(BASE_IMAGE)
ifeq ($(BASE_OS),redhat)
@docker pull registry.access.redhat.com/ubi8/ubi-minimal:$(BASE_OS_TAG_REDHAT)
ifeq ($(NVIDIA),1)
@docker pull docker.io/nvidia/cuda:11.8.0-runtime-ubi8
endif
endif
endif
ifeq ($(USE_BUILDX),true)
$(eval BUILDX:=buildx)
endif
ifeq ($(BUILD_CUSTOM_NODES),true)
@echo "Building custom nodes"
@cd src/custom_nodes && make USE_BUILDX=$(USE_BUILDX) NO_DOCKER_CACHE=$(NO_DOCKER_CACHE) BASE_OS=$(OS) BASE_IMAGE=$(BASE_IMAGE)
@cd src/custom_nodes/tokenizer && make USE_BUILDX=$(USE_BUILDX) NO_DOCKER_CACHE=$(NO_DOCKER_CACHE) BASE_OS=$(OS) BASE_IMAGE=$(BASE_IMAGE)
endif
@echo "Building docker image $(BASE_OS)"
# Provide metadata information into image if defined
@mkdir -p .workspace
ifneq ($(OVMS_METADATA_FILE),)
@cp $(OVMS_METADATA_FILE) .workspace/metadata.json
else
@touch .workspace/metadata.json
endif
@cat .workspace/metadata.json
docker $(BUILDX) build $(NO_CACHE_OPTION) -f Dockerfile.$(OS) . \
$(BUILD_ARGS) \
-t $(OVMS_CPP_DOCKER_IMAGE)-build:$(OVMS_CPP_IMAGE_TAG)$(IMAGE_TAG_SUFFIX) \
--target=build
targz_package:
docker $(BUILDX) build -f Dockerfile.$(OS) . \
$(BUILD_ARGS) \
--build-arg BUILD_IMAGE=$(OVMS_CPP_DOCKER_IMAGE)-build:$(OVMS_CPP_IMAGE_TAG)$(IMAGE_TAG_SUFFIX) \
-t $(OVMS_CPP_DOCKER_IMAGE)-pkg:$(OVMS_CPP_IMAGE_TAG) \
--target=pkg && \
rm -vrf dist/$(OS) && mkdir -p dist/$(OS) && \
ID=$$(docker create $(OVMS_CPP_DOCKER_IMAGE)-pkg:$(OVMS_CPP_IMAGE_TAG)) && \
docker cp $$ID:/ovms_pkg/$(OS) dist/ && \
docker rm $$ID
cd dist/$(OS) && sha256sum --check ovms.tar.gz.sha256
cd dist/$(OS) && sha256sum --check ovms.tar.xz.sha256
ovms_release_images:
ifeq ($(USE_BUILDX),true)
$(eval BUILDX:=buildx)
$(eval NO_CACHE_OPTION:=--no-cache-filter release)
endif
docker $(BUILDX) build $(NO_CACHE_OPTION) -f Dockerfile.$(OS) . \
$(BUILD_ARGS) \
-t $(OVMS_CPP_DOCKER_IMAGE):$(OVMS_CPP_IMAGE_TAG)$(IMAGE_TAG_SUFFIX) \
--target=release && \
docker $(BUILDX) build $(NO_CACHE_OPTION) -f Dockerfile.$(OS) . \
$(BUILD_ARGS) \
--build-arg GPU=1 \
-t $(OVMS_CPP_DOCKER_IMAGE)-gpu:$(OVMS_CPP_IMAGE_TAG)$(IMAGE_TAG_SUFFIX) \
--target=release && \
docker tag $(OVMS_CPP_DOCKER_IMAGE)-gpu:$(OVMS_CPP_IMAGE_TAG)$(IMAGE_TAG_SUFFIX) $(OVMS_CPP_DOCKER_IMAGE):$(OVMS_CPP_IMAGE_TAG)-gpu$(IMAGE_TAG_SUFFIX)
ifeq ($(BUILD_NGINX), 1)
cd extras/nginx-mtls-auth && \
http_proxy=$(HTTP_PROXY) https_proxy=$(HTTPS_PROXY) no_proxy=$(NO_PROXY) ./build.sh "$(OVMS_CPP_DOCKER_IMAGE):$(OVMS_CPP_IMAGE_TAG)$(IMAGE_TAG_SUFFIX)" "$(OVMS_CPP_DOCKER_IMAGE)-nginx-mtls:$(OVMS_CPP_IMAGE_TAG)$(IMAGE_TAG_SUFFIX)" "$(OS)" && \
docker tag $(OVMS_CPP_DOCKER_IMAGE)-nginx-mtls:$(OVMS_CPP_IMAGE_TAG)$(IMAGE_TAG_SUFFIX) $(OVMS_CPP_DOCKER_IMAGE):$(OVMS_CPP_IMAGE_TAG)-nginx-mtls$(IMAGE_TAG_SUFFIX)
endif
release_image:
ifeq ($(USE_BUILDX),true)
$(eval BUILDX:=buildx)
$(eval NO_CACHE_OPTION:=--no-cache-filter release)
endif
docker $(BUILDX) build $(NO_CACHE_OPTION) -f Dockerfile.$(OS) . \
$(BUILD_ARGS) \
-t $(OVMS_CPP_DOCKER_IMAGE):$(OVMS_CPP_IMAGE_TAG)
--target=release
ifeq ($(BUILD_NGINX), 1)
cd extras/nginx-mtls-auth && \
http_proxy=$(HTTP_PROXY) https_proxy=$(HTTPS_PROXY) no_proxy=$(NO_PROXY) ./build.sh "$(OVMS_CPP_DOCKER_IMAGE):$(OVMS_CPP_IMAGE_TAG)" "$(OVMS_CPP_DOCKER_IMAGE)-nginx-mtls:$(OVMS_CPP_IMAGE_TAG)" "$(OS)" && \
docker tag $(OVMS_CPP_DOCKER_IMAGE)-nginx-mtls:$(OVMS_CPP_IMAGE_TAG) $(OVMS_CPP_DOCKER_IMAGE):$(OVMS_CPP_IMAGE_TAG)-nginx-mtls
endif
python_image: release_image
@docker build --build-arg http_proxy="$(http_proxy)" --build-arg https_proxy="$(https_proxy)" --build-arg IMAGE_NAME=$(OVMS_CPP_DOCKER_IMAGE):$(OVMS_CPP_IMAGE_TAG) demos/python_demos -t $(OVMS_CPP_DOCKER_IMAGE):$(OVMS_PYTHON_IMAGE_TAG)
# Ci build expects index.html in genhtml directory
get_coverage:
@echo "Copying coverage report from build image to genhtml if exist..."
@docker create -ti --name $(OVMS_CPP_CONTAINER_NAME) $(OVMS_CPP_DOCKER_IMAGE)-build:$(OVMS_CPP_IMAGE_TAG) bash
@docker cp $(OVMS_CPP_CONTAINER_NAME):/ovms/genhtml/ . || true
@docker rm -f $(OVMS_CPP_CONTAINER_NAME) || true
@if [ -d genhtml/src ]; then $(MAKE) check_coverage; \
else echo "ERROR: genhtml/src was not generated during build"; \
fi
check_coverage:
@echo "Checking if coverage is above threshold..."
@docker run $(OVMS_CPP_DOCKER_IMAGE)-build:$(OVMS_CPP_IMAGE_TAG) ./check_coverage.bat | grep success
test_checksec: venv
@echo "Running checksec on libovms_shared library..."
@docker rm -f $(OVMS_CPP_CONTAINER_NAME) || true
@docker create -ti --name $(OVMS_CPP_CONTAINER_NAME) $(OVMS_CPP_DOCKER_IMAGE)-pkg:$(OVMS_CPP_IMAGE_TAG) bash
@docker cp $(OVMS_CPP_CONTAINER_NAME):/libovms_shared.so /tmp
@docker cp $(OVMS_CPP_CONTAINER_NAME):/ovms_release/bin/ovms /tmp
@docker rm -f $(OVMS_CPP_CONTAINER_NAME) || true
@. $(ACTIVATE); checksec -j /tmp/libovms_shared.so | jq '.[]| join(",")' > checksec.txt
@if ! grep -FRq "Full,true,true,DSO,false,true,true,true" checksec.txt; then\
echo "ERROR: OVMS shared library security settings changed. Run checksec on ovms shared library and fix issues." ; \
. $(ACTIVATE); checksec /tmp/libovms_shared.so ;\
exit 1;\
fi
@echo "Running checksec on ovms binary..."
@. $(ACTIVATE); checksec -j /tmp/ovms | jq '.[]| join(",")' > checksec.txt
@if ! grep -FRq "Full,true,true,PIE,false,true,true,true" checksec.txt; then\
echo "ERROR: OVMS binary security settings changed. Run checksec on ovms binary and fix issues."; \
. $(ACTIVATE); checksec /tmp/ovms ; \
exit 1;\
fi
@rm -f checksec.txt
@rm -f /tmp/ovms
@rm -f /tmp/libovms_shared.so
@echo "Checksec check success."
test_perf: venv
@echo "Dropping test container if exist"
@docker rm --force $(OVMS_CPP_CONTAINER_NAME) || true
@echo "Starting docker image"
@./tests/performance/download_model.sh
@docker run -d --name $(OVMS_CPP_CONTAINER_NAME) \
-v $(HOME)/resnet50-binary:/models/resnet50-binary \
-p $(OVMS_CPP_CONTAINER_PORT):$(OVMS_CPP_CONTAINER_PORT) \
$(OVMS_CPP_DOCKER_IMAGE):$(OVMS_CPP_IMAGE_TAG) \
--model_name resnet-binary --model_path /models/resnet50-binary --port $(OVMS_CPP_CONTAINER_PORT); sleep 5
@echo "Running latency test"
@. $(ACTIVATE); python3 tests/performance/grpc_latency.py \
--grpc_port $(OVMS_CPP_CONTAINER_PORT) \
--images_numpy_path tests/performance/imgs.npy \
--labels_numpy_path tests/performance/labels.npy \
--iteration 1000 \
--batchsize 1 \
--report_every 100 \
--input_name 0 \
--output_name 1463 \
--model_name resnet-binary
@echo "Removing test container"
@docker rm --force $(OVMS_CPP_CONTAINER_NAME)
test_perf_dummy_model: venv
@echo "Dropping test container if exist"
@docker rm --force $(OVMS_CPP_CONTAINER_NAME) || true
@echo "Starting docker image"
@docker run -d --name $(OVMS_CPP_CONTAINER_NAME) \
-v $(PWD)/src/test/dummy/1:/dummy/1 \
-p $(OVMS_CPP_CONTAINER_PORT):$(OVMS_CPP_CONTAINER_PORT) \
$(OVMS_CPP_DOCKER_IMAGE):$(OVMS_CPP_IMAGE_TAG) \
--model_name dummy --model_path /dummy --port $(OVMS_CPP_CONTAINER_PORT); sleep 5
@echo "Running latency test"
@. $(ACTIVATE); python3 tests/performance/grpc_latency.py \
--grpc_port $(OVMS_CPP_CONTAINER_PORT) \
--images_numpy_path tests/performance/dummy_input.npy \
--labels_numpy_path tests/performance/dummy_lbs.npy \
--iteration 10000 \
--batchsize 1 \
--report_every 1000 \
--input_name b \
--output_name a \
--model_name dummy
@echo "Removing test container"
@docker rm --force $(OVMS_CPP_CONTAINER_NAME)
test_throughput: venv
@echo "Dropping test container if exist"
@docker rm --force $(OVMS_CPP_CONTAINER_NAME) || true
@echo "Starting docker image"
@./tests/performance/download_model.sh
@docker run -d --name $(OVMS_CPP_CONTAINER_NAME) \
-v $(HOME)/resnet50-binary:/models/resnet50-binary \
-p $(OVMS_CPP_CONTAINER_PORT):$(OVMS_CPP_CONTAINER_PORT) \
$(OVMS_CPP_DOCKER_IMAGE):$(OVMS_CPP_IMAGE_TAG) \
--model_name resnet-binary \
--model_path /models/resnet50-binary \
--port $(OVMS_CPP_CONTAINER_PORT); \
sleep 10
@echo "Running throughput test"
@. $(ACTIVATE); cd tests/performance; ./grpc_throughput.sh 28 \
--grpc_port $(OVMS_CPP_CONTAINER_PORT) \
--images_numpy_path imgs.npy \
--labels_numpy_path labels.npy \
--iteration 500 \
--batchsize 1 \
--input_name 0 \
--output_name 1463 \
--model_name resnet-binary
@echo "Removing test container"
@docker rm --force $(OVMS_CPP_CONTAINER_NAME)
test_throughput_dummy_model: venv
@echo "Dropping test container if exist"
@docker rm --force $(OVMS_CPP_CONTAINER_NAME) || true
@echo "Starting docker image"
@docker run -d --name $(OVMS_CPP_CONTAINER_NAME) \
-v $(PWD)/src/test/dummy/1:/dummy/1 \
-p $(OVMS_CPP_CONTAINER_PORT):$(OVMS_CPP_CONTAINER_PORT) \
$(OVMS_CPP_DOCKER_IMAGE):$(OVMS_CPP_IMAGE_TAG) \
--model_name dummy \
--model_path /dummy \
--port $(OVMS_CPP_CONTAINER_PORT); \
sleep 10
@echo "Running throughput test"
@. $(ACTIVATE); cd tests/performance; ./grpc_throughput.sh 28 \
--grpc_port $(OVMS_CPP_CONTAINER_PORT) \
--images_numpy_path dummy_input.npy \
--labels_numpy_path dummy_lbs.npy \
--iteration 10000 \
--batchsize 1 \
--input_name b \
--output_name a \
--model_name dummy
@echo "Removing test container"
@docker rm --force $(OVMS_CPP_CONTAINER_NAME)
test_functional: venv
@. $(ACTIVATE); pytest --json=report.json -v -s $(TEST_PATH)
# Client library make style target, by default uses Python 3 env in .venv path
# This fact is used in test_client_lib, where make build runs in .venv Python 3 environment
test_client_lib:
@cd client/python/ovmsclient/lib && \
make style || exit 1 && \
. .venv-ovmsclient/bin/activate; make build || exit 1 && \
make test TEST_TYPE=FULL || exit 1 && \
make clean
test_python_clients:
@echo "Prepare docker image"
@docker build . -f tests/python/Dockerfile -t python_client_test
@echo "Dropping test container if exist"
@docker rm --force $(PYTHON_CLIENT_TEST_CONTAINER_NAME) || true
@echo "Download models"
@if [ ! -d "tests/python/models" ]; then cd tests/python && \
mkdir models && \
docker run -u $(id -u):$(id -g) -v ${PWD}/tests/python/models:/models openvino/ubuntu20_dev:latest omz_downloader --name resnet-50-tf --output_dir /models && \
docker run -u $(id -u):$(id -g) -v ${PWD}/tests/python/models:/models:rw openvino/ubuntu20_dev:latest omz_converter --name resnet-50-tf --download_dir /models --output_dir /models --precisions FP32 && \
docker run -u $(id -u):$(id -g) -v ${PWD}/tests/python/models:/models:rw openvino/ubuntu20_dev:latest mv /models/public/resnet-50-tf/FP32 /models/public/resnet-50-tf/1; fi
@echo "Start test container"
@docker run -d --rm --name $(PYTHON_CLIENT_TEST_CONTAINER_NAME) -v ${PWD}/tests/python/models/public/resnet-50-tf:/models/public/resnet-50-tf -p $(PYTHON_CLIENT_TEST_REST_PORT):8000 -p $(PYTHON_CLIENT_TEST_GRPC_PORT):9000 openvino/model_server:latest --model_name resnet --model_path /models/public/resnet-50-tf --port 9000 --rest_port 8000 && \
sleep 10
@echo "Run tests"
@exit_status=0 docker run --rm --network="host" python_client_test --grpc=$(PYTHON_CLIENT_TEST_GRPC_PORT) --rest=$(PYTHON_CLIENT_TEST_REST_PORT) --verbose --fastFail || exit_status=$?
@echo "Removing test container"
@docker rm --force $(PYTHON_CLIENT_TEST_CONTAINER_NAME)
@exit $(exit_status)
tools_get_deps:
cd tools/deps/$(OS) && docker build --build-arg http_proxy="$(http_proxy)" --build-arg https_proxy="$(https_proxy)" -t $(OVMS_CPP_DOCKER_IMAGE)-deps:$(OVMS_CPP_IMAGE_TAG) .
-docker rm -f ovms-$(BASE_OS)-deps
docker run -d --rm --name ovms-$(BASE_OS)-deps $(OVMS_CPP_DOCKER_IMAGE)-deps:$(OVMS_CPP_IMAGE_TAG)
sleep 5
docker cp ovms-$(OS)-deps:/root/rpms.tar.xz ./
sleep 5
-docker rm -f ovms-$(OS)-deps
@echo "Success! Dependencies saved to rpms.tar.xz in this directory"
cpu_extension:
cd src/example/SampleCpuExtension && \
docker build -f Dockerfile.$(OS) -t sample_cpu_extension:latest \
--build-arg http_proxy=${http_proxy} \
--build-arg https_proxy=${https_proxy} \
--build-arg no_proxy=${no_proxy} \
--build-arg DLDT_PACKAGE_URL=${DLDT_PACKAGE_URL} \
--build-arg APT_OV_PACKAGE=${APT_OV_PACKAGE} \
--build-arg BASE_IMAGE=${BASE_IMAGE} .
mkdir -p ./lib/${OS}
docker cp $$(docker create --rm sample_cpu_extension:latest):/workspace/libcustom_relu_cpu_extension.so ./lib/${OS}