Introducing OmniSci

Before diving into leveraging OmniSci, let us quickly recap the well-known database story.

Relational databases have long been the standard for storing pre-processed data. Although they cannot keep up with today’s applications requirements in terms of raw performance and volumetry, they stay by far the most popular and the most widely used databases. Their low learning curve still makes them a popular choice.

With applications becoming more and more data-centric, the amount of data increased dramatically. A new era then started: NoSQL or NotOnlySQL. Instead of relying on a single server for computation and disk I/O, NoSQL databases started to extensively rely on parallelism and sharding, i.e. multiples servers are used to fulfill the computation needs. Distributed filesystems and the map-reduce ecosystem also became popular to deal with Tb or Pb of data. Variants of SQL re-appeared on top of these to provide developers with higher-level APIs. Although it is overly simplified, it is common to refer that whole trend as “Big Data”.

Big Data gave us all some respite… until artificial intelligence came in. Developers now expect to have at hand many great algorithms to apply machine learning and deep learning processing to their data. These algorithms unleash lots of great use cases: classification, predictive analysis, pattern recognition, image processing etc..

CPUs alone are not powerful enough to deal with these use cases. Vectorized data, which are widely used in deep-learning and machine-learning algorithms require GPU power. Not to say that if you mix big data and deep learning you end up with distributed GPU clusters.

Without surprise, GPUs capable databases are now entering the game.  In this post, we introduced one of these new player: OmniSci, and we provide a walkthrough guide for you to combine it with the Punchplatform.

Introducing OmniSci

OmniSci (formerly Mapd)  is an in-memory columnar SQL engine designed to run on both GPUs and CPUs. OmniSci supports Apache Arrow for data ingest and data interchange via CUDA IPC handles.

Some features that distinguished MapD from its competitors are:

  • built-in interface for data exploration and data visualization (GeoSpatial data)
  • built-in algorithms and functions to manipulate GeoSpatial data
  • makes use of both CPUs and GPUs instead of CPUs only
  • a low learning curve
  • .. and SQL of course

The PunchPlatform now integrates OmniSci into its ecosystem. Let us see how we can put all of this into play on a (16.04LTS) ubuntu server.

WalkThrough : The Basics

GPU driver Installation

To start with, you need GPUs. Here is how to setup your environment on a NVIDIA equipped laptop. Of course this may be skipped if you have a cloud GPU box ready.

You first need to install the NVIDIA CUDA Toolkit for application development. Download the DEB package from the  NVIDIA CUDA zone.
Install the CUDA repository, update local repository cache, and then install the CUDA Toolkit and GPU drivers:

Check the installation of the GPU drivers by running the following command:

Install OmniSci 

Download OmniSci here. Use the .targz for this tutorial. Starting MapD (the database itself) is as simple as:

Inserting Data

To insert data, we will set up a punchplatform topology. The punch 5.2.1 version now includes a mapd bolt which makes it easy to feed MapD with any data coming from the many possible punch data sources: Kafka, files, sockets, whatsoever.

We assume you are already familiar with the PunchPlatform.  In short, it lets you design Storm or Spark pipeline using simple configuration files. These files can now include a MapD connector, hence MapD is just one of many possible data sink in the PunchPlatform.

Here is how it works: the MapD bolt is inserted as a sink in a (storm) DAG (Directed Acyclic Graph) and receives its data from a spout or previous bolt.  It expects a valid flat K-V (Key-Value) map. In other words, a row in your database is represented as a map object where the key corresponds to the target SQL column name.

Note that when you insert data into MapD, you can also include Geo-Spatial primitives  (see this link for a complete list). For instance, given the following table:

You can insert a polygon using the POLYGON primitive inside your insert SQL query statement:

To see and check your data :

Let us see a punchplatform topology example that will fill MapD with automatically generated geolocation points.  This topology uses the Generator Spout to generate the data, forwarded to the MapD bolt to insert it into MapD. We also added a punchlet (embedded in the topology using the Punch Bolt). Punchlets are handy to refine and enrich the data in your pipelines, which is a fundamental step in a real-world scenario.

Here is the topology:

And here is the punchlet:

What it does is to determine geolocation from the IP address and format our data stream to a valid one. Notice the insertion of the MapD POINT primitive.

To create the table, we will use the OmniSci Immerse. Immerse is for OmniSci is what Kibana is for ElasticSearch. It also includes a SQL editor to create tables and execute arbitrary SQL statements. It looks like this.

Once the table is created, simply run the topology: (here mapd.json is your topology filename)

You can now query the data, again from the SQL editor:

Visualise Your Data

Now that the data is in,  we can create visualizations. Here is an example histogram setup in a few clicks. It is somehow similar to the Kibana experience: straightforward.

Here we are displaying the frequencies of the inserted data age distribution. OmniSci Immerse can do much richer and powerful visualizations, checkout examples of what can be done here.

WalkThrough: Machine Learning and TensorFlow

This part is subtle, we hope you can stick with us until the end of this blog. It gives a first sense of going datascience with OmniSci.

Before that a few words on Apache Arrow that is in the picture:

Apache Arrow is a cross-language development platform for in-memory data. It specifies a standardized language-independent columnar memory format for flat and hierarchical data, organized for efficient analytic operations on modern hardware. It also provides computational libraries and zero-copy streaming messaging and interprocess communication. Languages currently supported include C, C++, Java, JavaScript, Python, and Ruby.

In short,  Apache Arrow is used as a core component in many big data components (Spark, Tensorflow, OmniSci, etc…) for data interchange.

 

What we will try to achieve in our next part is something similar to the code below:

We will also use Anaconda, well-known python package used for data manipulation. It comes with handy features, in particular, the Jupyter Notebook. Grab anaconda installation script for Ubuntu and restart terminal after installation:

Make sure none of your conda environment is currently activated:

Now, we are going to configure our anaconda working environment by executing the commands lines below: We are going to create fresh python virtual environment by using anaconda cli (conda):

Once you made sure the environment is created (your virtualenv name will appear on your terminal), installs the python libraries below:

For debugging purpose you may want to list all your virtual environment by using:

or if you want to see the list of installed libraries in your conda virtual environment:

Note:

you might want to install pandas, numpy, etc… just use conda install XXX where XXX is the name of the package you want to install

Using TensorFlow

Test in jupyter if everything is working – don’t forget to set the python kernel to the one you just created: python 3 tensorflow

In your Jupyter Notebook, run the codes below:

Running the above code should display as result: Hello, TensorFlow!

Now, let’s try to fetch some data inside our GPU memory. Here comes Arrow into play. (checkout OmniSci blog for details).

First we check that pymapd and MapD are properly installed on our  GPU by executing the code below in Jupyter:

Once you passed that step above, grab the tab-delimited PUF dataset here: download. Note that you might want to take only a subset of the downloaded data for your test.

Load the  data  into a pandas dataframe (change host, password, user, dbname, port parameters accordingly to yours):

Your Jupyter notebook should now display a bunch of results.

Note:

The handling of nulls is crucial when working with pandas and MapD…

Finally, the code below shows how to remove N.A values from a pandas dataframe and save it a MapD database.

And at last, we display how to load data from a MapD database directly to GPU memory by using Arrow.

It is now up to you to try some coding – i.e feed data from MapD to tensorflow by using GPU only memory.

Hope you enjoy this small ride 🙂 !