Giter Club home page Giter Club logo

smwshop_ebt5's Introduction

smwshop

Build the Apache MXNet deployment package for AWS Lambda

Launch an Amazon EC2 instance with the proper AMI

In order to compile MXNet for the Lambda function, you would need an environment running the AMI that the Lambda service is using. The current version is:

amzn-ami-hvm-2017.03.1.20170812-x86_64-gp2

double-checking that the current version is still the one above by visiting https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html.

You will have to launch an Amazon EC2 instance with that AMI and then access it by using an SSH client.

Install the required libraries

First, install development tools and the libraries required to compile MXNet. Apache MXNet requires several libraries as prerequisites. In this tutorial we will be using:

We are NOT going to use OpenCV, required by MXNet for image processing functions, and NVIDIA CUDA / cuDNN since we do not need to run Apache MXNet with GPU support.

If you want to know more on the dependencies and options to build Apache MXNet from sources, please visit https://mxnet.incubator.apache.org/install/build_from_source.html.

Execute the following commands in your home folder:

sudo yum groupinstall -y "Development Tools" && sudo yum install -y git

sudo yum install atlas-devel

sudo yum install openblas openblas-devel.x86_64 lapack-devel.x86_64

Build Apache MXNet

We are now ready to build Apache MXNet from sources. We are going to get the sources from the GitHub repository where MXNet is maintained and then build with the proper settings.

git clone --recursive https://github.com/apache/incubator-mxnet mxnet
cd mxnet

make -j $(nproc) USE_OPENCV=0 USE_CUDNN=0 USE_CUDA=0 USE_BLAS=openblas USE_LAPACK=1

Install language bindings

When the build process is completed, we will need to install the Python bindings as we want to use Python as programming language. All language bindings supported by MXNet are configured after building the framework, except C++ that needs to be included during the compilation.

To install language bindings, execute the following commands:

cd python

sudo python setup.py install

Build the package

Once the bindings are installed, we are ready to build a package that will contain all the relevant libraries to run MXNet in Lambda.

Please note that these instructions assume using the latest version of Apache MXNet and Numpoy, which, at the time being, are 1.3.1 and 1.15.2. This means that, if a new version is released, you might have to update the paths below.

cd

mkdir mxnetpackage

cp -r /usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet mxnetpackage/

cd mxnetpackage

sudo pip install numpy

cp -r /usr/local/lib/python2.7/site-packages/numpy-1.15.2-py2.7-linux-x86_64.egg/numpy/ .

mkdir lib

cp /usr/lib64/atlas/libatlas.so.3 lib/

cp /usr/lib64/atlas/libcblas.so.3 lib/

cp /usr/lib64/atlas/libclapack.so.3 lib/

cp /usr/lib64/atlas/libf77blas.so.3 lib/

cp /usr/lib64/libgfortran.so.3 lib/

cp /usr/lib64/libgfortran.so.3.0.0 lib/

cp /usr/lib64/libgomp.so.1 lib/

cp /usr/lib64/libgomp.so.1.0.0 lib/

cp /usr/lib64/atlas/liblapack.so.3 lib/

cp /usr/lib64/libopenblas.so.0 lib/

cp /usr/lib64/atlas/libptcblas.so.3 lib/

cp /usr/lib64/atlas/libptf77blas.so.3 lib/

cp /usr/lib64/libquadmath.so.0 lib/

Save the package

We are now going to compress and save the package to Amazon S3 as the final step.

tar cfz mxnet.tar.gz *

aws s3 cp mxnet.tar.gz s3://{your_bucket}/

Now you can run a test by creating an AWS Lambda function starting from the package content and write a simple Python lambda handler that executes some basic MXNet code.

Finally, after ensuring the package works as expected, you can terminate the EC2 instance to avoid incurring in unexpected charges.

smwshop_ebt5's People

Contributors

diegonat avatar npalm avatar trellixvulnteam avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.