Skip to Content

You might have already seen my earlier blog introducing SAP HANA External Machine Learning library which discusses how you can access TensorFlow models from HANA?

Well in the rush to produce hands-on video tutorials in time for RTC (release to customer) perhaps the content wasn’t as elegant as it could be.

The scenario involved tweaking of the standard TensorFlow MNIST model to change the default signature and a HANA table with 784 columns – Ouch!

Partly this was due to me using an internal pre-release – some things changed between that and RTC – but also very much due to my lack of knowledge. Interesting your feedback also made it clear that not everyone has a TensorFlow Serving environment up and running – so perhaps we could provide some pointers in that area too?

A lot of water has passed under the bridge since then and having had time for additional research we’ve been able to significantly revise the content. Yesterday we published 6 all-new video tutorials that show how to get going with the EML and TensorFlow and all in the context of SAP HANA, express edition.

The scenario now uses the standard MNIST model without modification, has a single BLOB column in HANA to store the image of a handwritten digit, and uses Database Explorer (via Web IDE for SAP HANA) rather than Eclipse as the development environment (though you could still use Eclipse if you prefer).

There’s a video showing how to install and configure TensorFlow with Tensorflow Serving from scratch in Google Cloud Platform – and given that SAP HANA, Express Edition is also available there you can take full advantage of the free trial!

Very much inspired by Frank Gottfried‘s excellent blog here. there’s also a video showing how to get started with the now fully supported Python driver delivered with SAP HANA Client Tools in SPS 02. This enables you to load test data directly into HANA using a Python script. You don’t need to do this to follow along with the tutorials however as a few rows of MNIST test data have also been published to our GitHub repository which can easily be imported via Database Explorer.

It’s the same playlist as before: SAP HANA Academy – EML Playlist

There are now 7 main videos covering the following topics:

UPDATE: 11Oct17 – HANA 2.0 SPS02 revision 21 introduces significant changes to the way output tensors are handled. If you’re using revision 21 please refer to the following tutorial for updates to the real-time scoring example with MNIST:

The previous videos are still there at the foot of the playlist – just in case you’re addicted to Eclipse:

You’ll also find above tutorials posted to the What’s New for Predictive HANA 2.0 SPS 02 playlist where you can also get the low down on enhancements to the Predictive Analysis Library (PAL) featuring the all-new web-based Application Function Modeler, as well improvements to R Integration.

If you’re interested to learn about what’s new with HANA 2.0 SPS 02 in general check out the following blog.

Should you be attending SAP TechEd please drop by our SAP HANA Academy event on the Monday. A full day of lecture/demo and hands-on sessions where we’ll be covering the EML / TensorFlow as well as other hot HANA topics – and unlike YouTube you can interrupt us to ask questions! Attendance is free and we’ll help you get started with SAP HANA, express edition on the Google Cloud Platform using the free trial – so you can keep your work afterwards.

May your tensors flow with HANA!

The SAP HANA Academy provides free online video tutorials for the developers, consultants, partners and customers of SAP HANA.

Topics range from practical how-to instructions on administration, data loading and modeling, and integration with other SAP solutions, to more conceptual projects to help build out new solutions using mobile applications or predictive analysis.

For the full library, see SAP HANA Academy Library – by the SAP HANA Academy

For the full list of blogs, see Blog Posts – by the SAP HANA Academy

To report this post you need to login first.

24 Comments

You must be Logged on to comment or reply to a post.

  1. Johnny Chan

    Hi! Please do you know if Is it possible to deploy the entire SAP HANA EML + TensorFlow Serving all within the SAP Cloud (without touching other clouds like Google, AWS, Azure, etc).?

    e.g SAP Cloud containing a HANA DB + a VM instance with Tensorflow running on it. All within the SAP Cloud. (Neo environment)

    (0) 
    1. Philip MUGGLESTONE Post author

      Hi Johnny,

      Not that I’m aware of however you can use the SAP Leonardo Machine Learning Foundation which is built on SAP Cloud Platform: https://cloudplatform.sap.com/capabilities/machine-learning.html.

      Thanks,

      Philip

      (0) 
  2. Nemanja Radojkovic

    Hello, Philip,

     

    we are building a tailored text classifier on the SAP platform, but would like to avoid using Tensorflow, at least for the moment.

    So, could a custom ML model also be served in the same way as TF models are?

    If I understand correctly, the model is served via some kind of an HTTP REST API, where certain “alignments” need to made for it to work seamlessly, which to me doesn’t sounds quite generic and customizeable.

     

    Thanks in advance!

     

    Regards,

     

    Nemanja

     

     

    (1) 
    1. Philip MUGGLESTONE Post author

      H Nemanja,

      SAP HANA provides a number of ways you have make use of ML/predictive, integration with TF is just one of them.

      Just to avoid any confusion, TensorFlow Serving “serves” TF models that have already been trained and is specific technology to TensorFlow. HANA acts as a “client” by the “remote” TF server to perform inference/scoring.

      For custom ML beyond TensorFlow, maybe consider using the R integration for SAP HANA (link to playlist) where you can basically do anything you want on the R side by embedding R script into a HANA stored procedure. Again HANA acts as the “client” and connects to the “remote” Rserve which actually does the processing.

      Hope that helps?

      Philip

      (1) 
      1. Nemanja Radojkovic

        Hi, Philip,

        first of all — thanks for the lightning-fast reply. 🙂

        Yes, I am aware of R integration (which is a bit more “embedded”, as I can see), but we are looking to reuse our existing Python (scikit-learn) code or maybe export the model to PMML and then use “openscoring” to serve the model via a REST API.

        Since TF is also running on a VM within SAP Cloud, and “serves” it’s predictions via an HTTP API, to me it seems like HANA+EML is not actually “married” to Tensorflow and “doesn’t care” what’s on the other side of the line — as long as it responds to its requests and delivers the response in a specific format that HANA requires.

        Did I understand things correctly?

        Many thanks in advance!

         

        Nemanja

        (1) 
        1. Burkhard Neidecker-Lutz

          Hello Nemanja,

           

          the current EML implementation does *not* use a generic REST API, but rather the somewhat higher performing gRPC mechanism and the TensorFlow Serving protocol layered on top of that. Thus the current version is indeed married to TensorFlow.

          If you were absolutely bent on integrating your current code that way, you could write your own python-based TensorFlow Serving server and point the EML at that. A “conforming” server would only need to implement the GetModelMetaData and Predict calls of the full TensorFlow Serving protocol and can actually be implemented in a moderate amount of python. even if it is no match for the full blown C++ based server.

           

          (1) 
  3. Naveen Kumar

    Hello Philip,

    Sorry was on different assignment so did not get time earlier to look into it. I am able to follow you all the way as shown in the video. However I get stuck while running the python script:

    python mnist_softmax.py

    python mnist_softmax.py
    Traceback (most recent call last):
    File “mnist_softmax.py”, line 28, in <module>
    from tensorflow.examples.tutorials.mnist import input_data
    ImportError: No module named tensorflow.examples.tutorials.mnist

     

    I tried to check but not sure if the module is available or not. Can you please suggest something on this.

    Best Regards,

    Naveen

    (0) 
    1. Philip MUGGLESTONE Post author

      Hi Naveen,

      The mnist_softmax.py script is from the standard TF tutorial: https://www.tensorflow.org/get_started/mnist/beginners

      I wonder if you’re tensorflow machine is behind a firewall and that is why the script is unable to download the MNIST demo data?

      I suggest you follow the tutorial (https://www.tensorflow.org/get_started/mnist/beginners) by pasting the code step by step rather than running the entire script in one go – this may help you debug what’s going wrong.

      Thanks,

      Philip

       

      (0) 
    1. Philip MUGGLESTONE Post author

      Hi Sumit,

      Yes of course – using the HXE download manager.

      The download process is shown in the video starting at 2 minutes and the install process at 5 minutes.

      To download and install the HXE download manager itself register here: https://www.sap.com/cmp/ft/crm-xu16-dat-hddedft/index.html

      Regards,

      Philip

      (0) 
      1. Sumit Kumar Kundu

        Hi Philip,

        I did not install HXE locally, Google Cloud launcher service installed it for me as VM on GCP compute engine. The link you provided will also work in my case, I thought this is the whole package of HXE.

        Regards,

        Sumit

        (0) 
  4. Rahul Choudhary

    Hi Philip,

    I am stuck at “ Create Remote Source and Register Model”. 

    When I try to verify MODEL IS UP AND RUNNING ON REMOTE SOURCE, I get back an error:

    “Remote source TensorFlowModelServer server is alive but refused connection”.

    I tried using external IP instead of internal IP. I still get the same message.

    Any ideas?

    Regards,

    Rahul

    (0) 
    1. Philip Mugglestone Post author

      Hi Rahul,

      This error means that it’s able to see the TF server machine (ip address/hostname) but not able to connect to the model. Most likely issues are either that the port is blocked (do you have a firewall? is there a proxy server in-between?) or that the model is not up and running on that server and port.

      Hope this helps,

      Philip

      (0) 
      1. Rahul Choudhary

        Hi Philip,

        I think I could isolate the issue. I create a new VM instance on google cloud platform. I tried accessing the model server from new VM.

        I could not even if I use internal or external IP. How do I open the port to accept connections from external IPs.

        Regards,

        Rahul

         

        (0) 
        1. Philip Mugglestone Post author

          Hi Rahul,

          I’m not sure exactly where your HANA machine is hosted and where the TF serving machine is hosted.

          Assuming TF serving is in GCP and HANA outside GCP, in GCP go to VPC Network > Firewall rules & then create a rule with tcp:<yourTFPortNr> and IP range of the external ip address of your HANA server (or 0.0.0.0/0 to be open to all) and ensure this firewall is associated with your TF serving instance.

          More doc can be found here: https://cloud.google.com/vpc/docs/firewalls

          Philip

           

          (0) 
          1. Rahul Choudhary

            Hi Philip,

            I could connect to TensorFlow model server running on one VM from a client on another VM in different region using both internal and external IP.

            But, I am still not able to connect to the server from HANA. I still get

            “Remote source TensorFlowModelServer server is alive but refused connection”.

            Is there some configuration in HANA that needs to be done to able to connect to external servers? 

            I am trying this from HANA Studio. I have followed steps as per your video. I have confirmed that EML is installed and all the functions are available. 

             

            Regards,

            Rahul

            (0) 
            1. Philip Mugglestone Post author

              Hi Rahul,

              Where is the HANA server hosted? Is it perhaps behind a corporate firewall that is blocking outbound access to the TF serving port?

              Sounds obvious, but perhaps also double-check the model name specified in your HANA SQL Script? It could be that HANA can connect to the TF server port but the requested model is not being served?

              Regards,

              Philip

              (0) 
              1. Rahul Choudhary

                Hi Philip,

                You are right. The HANA Server is hosted behind SAP corporate firewall. Any idea how do I still be able to connect to GCP?

                Or is it strictly not allowed?

                Regards,

                Rahul

                (0) 
                1. Philip Mugglestone Post author

                  Hi Rahul,

                  My understanding is that this isn’t possible right now however the ability to specify a proxy server for use with EML remote sources could be added in a future HANA release.

                  Regards,

                  Philip

                  (0) 

Leave a Reply