-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The tutorials were not very user friendly as they did not provide a method of execution that was easy to quickly setup. This PR solves that by Adding a prod Dockerfile for the tutorials using Smartsim 0.4.0 and SmartRedis 0.3.0 Adding more to the tutorials (specifically about co-located) Adding a make tutorials-prod command to build the tutorials in a linux container where SmartSim is installed Making almost (expect training and ray) all the tutorials into jupyter notebooks that run locally [ committed by @Spartee ] [ reviewed by @al-rigazzi ]
- Loading branch information
Showing
37 changed files
with
2,349 additions
and
906 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
*** | ||
C++ | ||
*** | ||
|
||
|
||
In this section, examples are presented using the SmartRedis C++ | ||
API to interact with the RedisAI tensor, model, and script | ||
data types. Additionally, an example of utilizing the | ||
SmartRedis ``DataSet`` API is also provided. | ||
|
||
|
||
|
||
.. note:: | ||
The C++ API examples rely on the ``SSDB`` environment | ||
variable being set to the address and port of the Redis database. | ||
|
||
|
||
.. note:: | ||
The C++ API examples are written | ||
to connect to a clustered database or clustered SmartSim Orchestrator. | ||
Update the ``Client`` constructor ``cluster`` flag to `false` | ||
to connect to a single shard (single compute host) database. | ||
|
||
|
||
|
||
|
||
Tensors | ||
======= | ||
|
||
The following example shows how to send a receive a tensor using the | ||
SmartRedis C++ client API. | ||
|
||
.. literalinclude:: ../smartredis/examples/serial/cpp/smartredis_put_get_3D.cpp | ||
:linenos: | ||
:language: C++ | ||
|
||
DataSets | ||
======== | ||
|
||
The C++ client can store and retrieve tensors and metadata in datasets. | ||
For further information about datasets, please refer to the :ref:`Dataset | ||
section of the Data Structures documentation page <data_structures_dataset>`. | ||
|
||
The code below shows how to store and retrieve tensors and metadata | ||
which belong to a ``DataSet``. | ||
|
||
.. literalinclude:: ../smartredis/examples/serial/cpp/smartredis_dataset.cpp | ||
:linenos: | ||
:language: C++ | ||
|
||
.. _SR CPP Models: | ||
|
||
|
||
Models | ||
====== | ||
|
||
The following example shows how to store, and use a DL model | ||
in the database with the C++ Client. The model is stored as a file | ||
in the ``../../../common/mnist_data/`` path relative to the | ||
compiled executable. Note that this example also sets and | ||
executes a preprocessing script. | ||
|
||
.. literalinclude:: ../smartredis/examples/serial/cpp/smartredis_model.cpp | ||
:linenos: | ||
:language: C++ | ||
|
||
.. _SR CPP Scripts: | ||
|
||
Scripts | ||
======= | ||
|
||
The example in :ref:`SR CPP Models` shows how to store, and use a PyTorch script | ||
in the database with the C++ Client. The script is stored a file | ||
in the ``../../../common/mnist_data/`` path relative to the | ||
compiled executable. Note that this example also sets and | ||
executes a PyTorch model. | ||
|
||
.. _SR CPP Parallel MPI: | ||
|
||
Parallel (MPI) execution | ||
======================== | ||
|
||
In this example, the example shown in :ref:`SR CPP Models` and | ||
:ref:`SR CPP Scripts` is adapted to run in parallel using MPI. | ||
This example has the same functionality, however, | ||
it shows how keys can be prefixed to prevent key | ||
collisions across MPI ranks. Note that only one | ||
model and script are set, which is shared across | ||
all ranks. | ||
|
||
For completeness, the pre-processing script | ||
source code is also shown. | ||
|
||
**C++ program** | ||
|
||
.. literalinclude:: ../smartredis/examples/parallel/cpp/smartredis_mnist.cpp | ||
:linenos: | ||
:language: C++ | ||
|
||
**Python Pre-Processing** | ||
|
||
.. literalinclude:: ../smartredis/examples/common/mnist_data/data_processing_script.txt | ||
:linenos: | ||
:language: Python | ||
:lines: 15-20 | ||
|
Oops, something went wrong.