Skip to content

Commit

Permalink
feat: add poc multiprocess test
Browse files Browse the repository at this point in the history
  • Loading branch information
dennyabrain committed Feb 9, 2024
1 parent 72bd171 commit f43646b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/api/Dockerfile.vid_vec_rep_resnet
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11-slim-bullseye AS base
FROM python:3.11-slim@sha256:637774748f62b832dc11e7b286e48cd716727ed04b45a0322776c01bc526afc3 AS base
RUN apt-get update \
&& apt-get -y upgrade \
&& apt-get install -y \
Expand Down Expand Up @@ -56,6 +56,10 @@ COPY ./video_vec_operator_profile_pyinstrument.sh /app/video_vec_operator_profil
RUN chmod +x video_vec_operator_profile_memray.sh
RUN chmod +x video_vec_operator_profile_pyinstrument.sh

COPY ./video_vec_operator_multicore.py /app/video_vec_operator_multicore.py
COPY ./video_vec_operator_multicore.sh /app/video_vec_operator_multicore.sh
RUN chmod +x video_vec_operator_multicore.sh

COPY ./benchmark.sh /app/benchmark.sh
RUN chmod +x benchmark.sh

Expand Down
33 changes: 33 additions & 0 deletions src/api/video_vec_operator_multicore.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from multiprocessing import Process
from multiprocessing import cpu_count
from core.operators import vid_vec_rep_resnet
import time


def find_time():
file_path = {"path": r"core/operators/sample_data/sample-cat-video.mp4"}
start_time = time.time()
vid_vec_rep_resnet.run(file_path)
end_time = time.time()
duration = end_time - start_time
print(f"Time taken - {duration}")
print("Video vec time profile complete!")


N = 1
total_cores = cpu_count()

print("number of cpus: ", cpu_count())
print("distribute test on", int(total_cores / N), "cores")

processes = []

vid_vec_rep_resnet.initialize(param=None)

for core in range(int(total_cores / N)):
proc = Process(target=find_time)
processes.append(proc)
proc.start()

for proc in processes:
proc.join()
2 changes: 2 additions & 0 deletions src/api/video_vec_operator_multicore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python video_vec_operator_multicore.py > output_multicore.txt
tail -f /dev/null

0 comments on commit f43646b

Please sign in to comment.