Home

Awesome

GitHub issues CircleCI Dockerhub codecov Total alerts

RedisAI

Forum Discord

A Redis module for serving tensors and executing deep learning models.

Cloning

If you want to run examples, make sure you have git-lfs installed when you clone.

Quickstart

  1. Docker
  2. Build

Docker

To quickly tryout RedisAI, launch an instance using docker:

docker run -p 6379:6379 -it --rm redislabs/redisai

For docker instance with GPU support, you can launch it from tensorwerk/redisai-gpu

docker run -p 6379:6379 --gpus all -it --rm redislabs/redisai:latest-gpu

But if you'd like to build the docker image, you need a machine that has Nvidia driver (CUDA 10.0), nvidia-container-toolkit and Docker 19.03+ installed. For detailed information, checkout nvidia-docker documentation

docker build -f Dockerfile-gpu -t redisai-gpu .
docker run -p 6379:6379 --gpus all -it --rm redisai-gpu

Note that Redis config is located at /usr/local/etc/redis/redis.conf which can be overridden with a volume mount

Give it a try

On the client, set the model

redis-cli -x AI.MODELSET foo TF CPU INPUTS a b OUTPUTS c BLOB < tests/test_data/graph.pb

Then create the input tensors, run the computation graph and get the output tensor (see load_model.sh). Note the signatures:

redis-cli
> AI.TENSORSET bar FLOAT 2 VALUES 2 3
> AI.TENSORSET baz FLOAT 2 VALUES 2 3
> AI.MODELRUN foo INPUTS bar baz OUTPUTS jez
> AI.TENSORGET jez META VALUES
1) dtype
2) FLOAT
3) shape
4) 1) (integer) 2
5) values
6) 1) "4"
   2) "9"

Building

You should obtain the module's source code and submodule using git like so:

git clone --recursive https://github.com/RedisAI/RedisAI

This will checkout and build and download the libraries for the backends (TensorFlow, PyTorch, ONNXRuntime) for your platform. Note that this requires CUDA 10.0 to be installed.

bash get_deps.sh

Alternatively, run the following to only fetch the CPU-only backends even on GPU machines.

bash get_deps.sh cpu

Once the dependencies are downloaded, build the module itself. Note that CMake 3.0 or higher is required.

ALL=1 make -C opt clean build

Note: in order to use the PyTorch backend on Linux, at least gcc 4.9.2 is required.

Running the server

You will need a redis-server version 5.0.7 or greater. This should be available in most recent distributions:

redis-server --version
Redis server v=5.0.7 sha=00000000:0 malloc=libc bits=64 build=c49f4faf7c3c647a

To start Redis with the RedisAI module loaded:

redis-server --loadmodule install-cpu/redisai.so

Client libraries

Some languages have client libraries that provide support for RedisAI's commands:

ProjectLanguageLicenseAuthorURL
JRedisAIJavaBSD-3RedisLabsGithub
redisai-pyPythonBSD-3RedisLabsGithub
redisai-goGoBSD-3RedisLabsGithub
redisai-jsTypescript/JavascriptBSD-3RedisLabsGithub
redis-modules-sdkTypeScriptBSD-3-ClauseDani TseitlinGithub

Backend Dependancy

RedisAI currently supports PyTorch (libtorch), Tensorflow (libtensorflow), TensorFlow Lite, and ONNXRuntime as backends. This section shows the version map between RedisAI and supported backends. This extremely important since the serialization mechanism of one version might not match with another. For making sure your model will work with a given RedisAI version, check with the backend documentation about incompatible features between the version of your backend and the version RedisAI is built with.

RedisAIPyTorchTensorFlowTFLiteONNXRuntime
0.1.01.0.11.12.0NoneNone
0.2.11.0.11.12.0NoneNone
0.3.11.1.01.12.0None0.4.0
0.4.01.2.01.14.0None0.5.0
0.9.01.3.11.14.02.0.01.0.0
1.0.01.5.01.15.02.0.01.2.0
master1.7.01.15.02.0.01.2.0

Note: Keras and TensorFlow 2.x are supported through graph freezing. See this script to see how to export a frozen graph from Keras and TensorFlow 2.x. Note that a frozen graph will be executed using the TensorFlow 1.15 backend. Should any 2.0 ops be not supported on the 1.15 after freezing, please open an Issue.

Documentation

Read the docs at redisai.io. Checkout our showcase repo for a lot of examples written using different client libraries.

Mailing List / Forum

Got questions? Feel free to ask at the RedisAI Forum

License

Redis Source Available License Agreement - see LICENSE

Copyright 2020, Redis Labs, Inc