Skip to content

Commit b7c316c

Browse files
rafielantiga
authored andcommitted
Fixed RLEC problem of loading redisai.so (#143)
* Fixed RLEC problem of loading redisai.so Fixed RLEC problem of loading redisai.so by setting RUNPATH to /opt/redislabs/lib (via patchelf). * Fixed RLEC problem of loading redisai.so #2 * Add libgomp1 as dependency in Dockerfile * Moved redisai.so RUNPATH fix code into Makefile * Moved redisai.so RUNPATH fix code into Makefile #2 * Moved redisai.so RUNPATH fix code into Makefile #3 * Tabs to spaces in .circleci/config.yml * Fixed RLEC problem of loading redisai.so Fixed RLEC problem of loading redisai.so by setting RUNPATH to /opt/redislabs/lib (via patchelf). * Fixed RLEC problem of loading redisai.so #2 * Moved redisai.so RUNPATH fix code into Makefile * Moved redisai.so RUNPATH fix code into Makefile #2 * Moved redisai.so RUNPATH fix code into Makefile #3 * Tabs to spaces in .circleci/config.yml
1 parent 7f158bf commit b7c316c

File tree

5 files changed

+74
-5
lines changed

5 files changed

+74
-5
lines changed

.circleci/config.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
name: install dependencies
1919
command: |
2020
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
21-
sudo apt-get install -y git-lfs
21+
sudo apt-get install -y git-lfs patchelf
2222
git lfs install
2323
curl -o cmake-3.12.4-Linux-x86_64.sh https://cmake.org/files/v3.12/cmake-3.12.4-Linux-x86_64.sh
2424
mkdir /home/circleci/project/cmake-bin
@@ -43,6 +43,8 @@ jobs:
4343
cd build
4444
cmake -DDEPS_PATH=../deps/install ..
4545
make
46+
cd ..
47+
make rlec_runpath_fix
4648
4749
- run:
4850
name: Test
@@ -59,7 +61,7 @@ jobs:
5961
name: Persist Artifacts
6062
command: |
6163
mkdir -p ~/workspace/build
62-
cp build/$MODULE_ARTIFACT ~/workspace/
64+
cp build/ramp/$MODULE_ARTIFACT ~/workspace/
6365
cp deps/install/lib/*.so* ~/workspace/
6466
cp ramp.yml ~/workspace/
6567
- persist_to_workspace:

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ SET_TARGET_PROPERTIES(redisai PROPERTIES SUFFIX ".so")
5353
IF (APPLE)
5454
SET_TARGET_PROPERTIES(redisai PROPERTIES
5555
LINK_FLAGS "-undefined dynamic_lookup")
56-
ENDIF()
56+
ENDIF()

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM redis AS builder
22

3-
ENV DEPS "build-essential git ca-certificates curl unzip wget libgomp1"
3+
ENV DEPS "build-essential git ca-certificates curl unzip wget libgomp1 patchelf"
44

55
# install latest cmake
66
ADD https://cmake.org/files/v3.12/cmake-3.12.4-Linux-x86_64.sh /cmake-3.12.4-Linux-x86_64.sh

Dockerfile-gpu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04 AS builder
22

3-
ENV DEPS "build-essential git ca-certificates curl unzip wget libgomp1"
3+
ENV DEPS "build-essential git ca-certificates curl unzip wget libgomp1 patchelf"
44
ENV NVIDIA_VISIBLE_DEVICES all
55
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
66

Makefile

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
2+
ifeq ($(CUDA),1)
3+
DEPS_FLAGS=
4+
else
5+
DEPS_FLAGS=cpu
6+
endif
7+
8+
export REDIS_ENT_LIB_PATH=/opt/redislabs/lib
9+
10+
GIT_BRANCH:=$(shell git rev-parse --abbrev-ref HEAD)
11+
GIT_COMMIT:=$(shell git describe --always --abbrev=7 --dirty="+")
12+
13+
ifeq ($(VERSION),)
14+
PACK_VER:=$(GIT_BRANCH)-$(GIT_COMMIT)
15+
else
16+
PACK_VER:=$(VERSION)
17+
endif
18+
19+
BINDIR=$(PWD)/build
20+
21+
.PHONY: all clean deps pack rlec_runpath_fix
22+
23+
all:
24+
ifeq ($(wildcard build/.),)
25+
mkdir -p build
26+
cd build; \
27+
cmake -DDEPS_PATH=../deps/install ..
28+
endif
29+
$(MAKE) -C build
30+
31+
clean:
32+
ifeq ($(ALL),1)
33+
rm -rf build deps
34+
else
35+
$(MAKE) -C build clean
36+
endif
37+
38+
deps:
39+
@echo Fetching dependencies...
40+
@./get_deps.sh $(DEPS_FLAGS)
41+
42+
# in pack: create ramp/redisai.so with RUNPATH set to /opt/redislabs/lib for RLEC compliance
43+
rlec_runpath_fix:
44+
@echo Fixing RLEC RUNPATH...
45+
@mkdir -p $(BINDIR)/ramp
46+
@cp -f $(BINDIR)/redisai.so $(BINDIR)/ramp/
47+
@patchelf --set-rpath $(REDIS_ENT_LIB_PATH) $(BINDIR)/ramp/redisai.so
48+
49+
pack: rlec_runpath_fix
50+
@[ ! -z `command -v redis-server` ] || { echo "Cannot find redis-server - aborting."; exit 1; }
51+
@[ ! -e $(REDIS_ENT_LIB_PATH) ] || { echo "$(REDIS_ENT_LIB_PATH) exists - aborting."; exit 1; }
52+
ifeq ($(wildcard build/pyenv/.),)
53+
@virtualenv build/pyenv ;\
54+
. ./build/pyenv/bin/activate ;\
55+
pip install git+https://github.com/RedisLabs/RAMP
56+
endif
57+
@echo "Building RAMP file ..."
58+
@set -e ;\
59+
. ./build/pyenv/bin/activate ;\
60+
ln -fs $(PWD)/deps/install/lib/ $(REDIS_ENT_LIB_PATH) ;\
61+
ramp pack -m $(PWD)/ramp.yml -o "build/redisai.{os}-{architecture}.${PACK_VER}.zip" $(BINDIR)/ramp/redisai.so 2>&1 > /dev/null ;\
62+
rm $(REDIS_ENT_LIB_PATH)
63+
@echo Done.
64+
@echo "Building dependencies file redisai-dependencies.${PACK_VER}.tgz ..."
65+
@cd deps/install/lib; \
66+
tar pczf ../../../build/redisai-dependencies.${PACK_VER}.tgz *.so*
67+
@echo Done.

0 commit comments

Comments
 (0)