Skip to content

Commit 36581e9

Browse files
authored
ARM support (ARM32v7, ARM64v8) (#10)
- Tested on x64, - Tested on arm64v8 (64-bit Ubuntu 18), - Pending testing on RPi3/Raspbian (32-bit).
1 parent c8acfd8 commit 36581e9

File tree

7 files changed

+50
-24
lines changed

7 files changed

+50
-24
lines changed

app/Dockerfile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1-
FROM python:3.7.3
1+
# FROM python:3.7.3
2+
FROM debian:buster
3+
4+
ENV DEBIAN_FRONTEND=noninteractive
5+
ENV RUNTIME_DEPS "python3 python3-setuptools ca-certificates curl python3-opencv"
6+
7+
RUN set -ex ;\
8+
apt-get -qq update ;\
9+
apt-get -q install -y --no-install-recommends $RUNTIME_DEPS
10+
11+
RUN set -ex ;\
12+
curl -q -s https://bootstrap.pypa.io/get-pip.py -o /tmp/get-pip.py ;\
13+
python3 /tmp/get-pip.py
214

315
WORKDIR /app
416
ADD . /app
517

6-
RUN set -ex; \
7-
pip install -r requirements.txt;
18+
RUN pip3 install -r requirements.txt
819

920
ENTRYPOINT [ "python3" ]

app/gear.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import cv2
55
import base64
66
import redisAI
7+
import numpy
78

89
framesToDrop = 0
910

@@ -27,8 +28,11 @@ def addToGraphRunner(x):
2728
dataM = imageio.imread(data).astype(dtype='float32')
2829
newImg = (cv2.resize(dataM, (224, 224)) / 128) - 1
2930

31+
l = numpy.asarray(newImg, dtype=numpy.float32)
32+
img_ba = bytearray(l.tobytes())
33+
3034
# converting the matrix color to Tensor
31-
v1 = redisAI.createTensorFromValues('FLOAT', [1, 224, 224, 3], toOneList(newImg.tolist()))
35+
v1 = redisAI.createTensorFromBlob('FLOAT', [1, 224, 224, 3], img_ba)
3236

3337
# creating the graph runner, 'g1' is the key in redis on which the graph is located
3438
graphRunner = redisAI.createModelRunner('mobilenet:model')
@@ -45,15 +49,15 @@ def addToGraphRunner(x):
4549

4650
def addToStream(x):
4751
# save animal name into a new stream
48-
redisgears.executeCommand('xadd', 'cats', 'MAXLEN', '~', '1000', '*', 'image', 'data:image/jpeg;base64,' + base64.b64encode(x[1]))
52+
redisgears.executeCommand('xadd', 'cats', 'MAXLEN', '~', '1000', '*', 'image', 'data:image/jpeg;base64,' + base64.b64encode(x[1]).decode('utf8'))
4953

5054
def shouldTakeFrame(x):
5155
global framesToDrop
5256
framesToDrop += 1
5357
return framesToDrop % 10 == 0
5458

5559
def passAll(x):
56-
redisgears.executeCommand('xadd', 'all', 'MAXLEN', '~', '1000', '*', 'image', 'data:image/jpeg;base64,' + base64.b64encode(x['img']))
60+
redisgears.executeCommand('xadd', 'all', 'MAXLEN', '~', '1000', '*', 'image', 'data:image/jpeg;base64,' + base64.b64encode(x['img']).decode('utf8'))
5761

5862
# creating execution plane
5963
gearsCtx('StreamReader').\

app/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
opencv-python==4.0.1.23
1+
# opencv-python
22
redis==3.2.1

camera/Dockerfile

100644100755
File mode changed.

camera/Dockerfile.debian

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM python:2
2+
3+
RUN set -ex;\
4+
apt-get -qq update;\
5+
apt-get install -y python-opencv
6+
7+
WORKDIR /usr/src/app
8+
ADD read_camera.py ./
9+
RUN pip install redis
10+
11+
CMD [ "python", "./read_camera.py" ]

docker-compose.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
version: '3'
22
services:
33
redis:
4-
build: ./redis/.
4+
build: ./redis
55
ports:
66
- "6379:6379"
77
weball:
8-
build: ./frontend/.
8+
build: ./frontend
99
ports:
1010
- "3000:3000"
1111
environment:
@@ -14,7 +14,7 @@ services:
1414
depends_on:
1515
- redis
1616
webcats:
17-
build: ./frontend/.
17+
build: ./frontend
1818
ports:
1919
- "3001:3000"
2020
environment:
@@ -23,7 +23,7 @@ services:
2323
depends_on:
2424
- redis
2525
app:
26-
build: ./app/.
26+
build: ./app
2727
depends_on:
2828
- redis
2929
command: ['init.py', '--url', 'redis://redis:6379']

redis/Dockerfile

100644100755
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
FROM redisai/redisai:0.2.0 as redisai
2-
FROM redislabs/redisgears:0.2.1 as redisgears
31

4-
ENV LD_LIBRARY_PATH /usr/lib/redis/modules/
5-
ENV RUNTIME_DEPS "python python-setuptools python-pip python-dev build-essential libglib2.0-0 libsm6 libxext6 libfontconfig1 libxrender1"
6-
ENV PYTHON_DEPS "setuptools redis argparse imageio opencv-python pybase64 redisAI==0.3.0"
2+
# OSNICK=stretch|bionic|buster
3+
ARG OSNICK=buster
74

8-
WORKDIR /data
5+
#----------------------------------------------------------------------------------------------
6+
FROM redisfab/redisedgevision-${OSNICK}:0.1.0
97

10-
RUN set -ex;\
11-
apt-get update;\
12-
apt-get install -y --no-install-recommends $RUNTIME_DEPS;
8+
# This is due on the following error on ARMv8:
9+
# /usr/lib/aarch64-linux-gnu/libgomp.so.1: cannot allocate memory in static TLS block
10+
# Something is exausting TLS, causing libgomp to fail. Preloading it as a workaround helps.
11+
ENV LD_PRELOAD /usr/lib/aarch64-linux-gnu/libgomp.so.1
1312

14-
COPY --from=redisai /usr/lib/redis/modules/*.so* "$LD_LIBRARY_PATH"
13+
ENV LD_LIBRARY_PATH /usr/lib/redis/modules/
1514

16-
RUN pip install -t /usr/local/lib/python2.7/site-packages ${PYTHON_DEPS}
15+
WORKDIR /data
1716

1817
EXPOSE 6379
1918
ENTRYPOINT ["redis-server"]
19+
2020
CMD ["--loadmodule", "/usr/lib/redis/modules/redisai.so", \
21-
"--loadmodule", "/usr/lib/redis/modules/redisgears.so", \
22-
"PythonHomeDir", "/usr/lib/redis/modules/deps/cpython/"]
21+
"--loadmodule", "/usr/lib/redis/modules/redisgears.so", \
22+
"PythonHomeDir", "/opt/redislabs/lib/modules/python3/"]

0 commit comments

Comments
 (0)