Skip to main content

Amazon Sagemaker specific TensorFlow extensions.

Project description

SageMaker specific extensions to TensorFlow, for Python 2.7, 3.4-3.6 and TensorFlow versions 1.7, 1.8, 1.9, and 1.10. This package includes the PipeModeDataset class, that allows SageMaker Pipe Mode channels to be read using TensorFlow DataSets.

Install

You can build SageMaker TensorFlow into a docker image with the following command:

pip install sagemaker-tensorflow

You can also install sagemaker-tensorflow for a specific version of TensorFlow. The following command will install sagemaker-tensorflow for TensorFlow 1.7:

pip install "sagemaker-tensorflow>=1.7,<1.8"

Build and install from source

The SageMaker TensorFlow build depends on the following:

  • cmake

  • tensorflow

  • curl-dev

To install these run:

pip install cmake tensorflow

On Amazon Linux, curl-dev can be installed with:

yum install curl-dev

On Ubuntu, curl-dev can be installed with:

apt-get install libcurl4-openssl-dev

To build and install this package, run:

pip install .

in this directory.

To build in a SageMaker docker image, you can use the following RUN command in your Dockerfile:

RUN git clone https://github.com/aws/sagemaker-tensorflow-extensions.git && \
    cd sagemaker-tensorflow-extensions && \
    pip install . && \
    cd .. && \
    rm -rf sagemaker-tensorflow-extensions

Building for a specific TensorFlow version

Release branching is used to track different versions of TensorFlow. To build for a specific release of TensorFlow, checkout the release branch prior to running a pip install. For example, to build for TensorFlow 1.7, you can run the following command in your Dockerfile:

RUN git clone https://github.com/aws/sagemaker-tensorflow-extensions.git && \
    cd sagemaker-tensorflow-extensions && \
    git checkout 1.7 && \
    pip install . && \
    cd .. && \
    rm -rf sagemaker-tensorflow-extensions

Requirements

SageMaker TensorFlow extensions builds on Python 2.7, 3.4-3.6 in Linux with a TensorFlow version >= 1.7. Older versions of TensorFlow are not supported. Please make sure to checkout the branch of sagemaker-tensorflow-extensions that matches your TensorFlow version.

SageMaker Pipe Mode

SageMaker Pipe Mode is a mechanism for providing S3 data to a training job via Linux fifos. Training programs can read from the fifo and get high-throughput data transfer from S3, without managing the S3 access in the program itself.

SageMaker Pipe Mode is enabled when a SageMaker Training Job is created. Multiple S3 datasets can be mapped to individual fifos, configured in the training request. Pipe Mode is covered in more detail in the SageMaker documentation: https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms-training-algo.html#your-algorithms-training-algo-running-container-inputdataconfig

Using the PipeModeDataset

The PipeModeDataset is a TensorFlow Dataset for reading SageMaker Pipe Mode channels. After installing the sagemaker tensorflow extensions package, the PipeModeDataset can be imported from a moduled named sagemaker_tensorflow.

To construct a PipeModeDataset that reads TFRecord encoded records from a “training” channel, do the following:

from sagemaker_tensorflow import PipeModeDataset

ds = PipeModeDataset(channel='training', record_format='TFRecord')

A PipeModeDataset should be created for a SageMaker PipeMode channel. Each channel corresponds to a single S3 dataset, configured when the training job is created. You can create multiple PipeModeDataset instances over different channels to read from multiple S3 datasets in the same training program.

A PipeModeDataset can read TFRecord, RecordIO, or text line records, by using the record_format constructor argument. The record_format kwarg can be set to either RecordIO, TFRecord, or TextLine to differentiate between the three encodings. RecordIO is the default.

A PipeModeDataset is a regular TensorFlow Dataset and as such can be used in TensorFlow input processing pipelines, and in TensorFlow Estimator input_fn definitions. All Dataset operations are supported on PipeModeDataset. The following code snippet shows how to create a batching and parsing Dataset that reads data from a SageMaker Pipe Mode channel:

features = {
    'data': tf.FixedLenFeature([], tf.string),
    'labels': tf.FixedLenFeature([], tf.int64),
}

def parse(record):
    parsed = tf.parse_single_example(record, features)
    return ({
        'data': tf.decode_raw(parsed['data'], tf.float64)
    }, parsed['labels'])

ds = PipeModeDataset(channel='training', record_format='TFRecord')
num_epochs = 20
ds = ds.repeat(num_epochs)
ds = ds.prefetch(10)
ds = ds.map(parse, num_parallel_calls=10)
ds = ds.batch(64)

License

SageMaker TensorFlow is licensed under the Apache 2.0 License. It is copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. The license is available at: http://aws.amazon.com/apache2.0/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file sagemaker_tensorflow-1.10.0.1.0.1-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for sagemaker_tensorflow-1.10.0.1.0.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 59e0dfeabfd88788a3141db723d5438cd95dac86c1419516355d13319f44f6ab
MD5 6bdf2bdfafe17a5be369229246eecc9d
BLAKE2b-256 dd3a97b08626809492447d64317066c9be0a53465b8b847f1356df80d882e438

See more details on using hashes here.

File details

Details for the file sagemaker_tensorflow-1.10.0.1.0.1-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for sagemaker_tensorflow-1.10.0.1.0.1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 483bb143040e71e4db27997759c54c92635df193edddb48aec086edf12682110
MD5 70556d30d11c1c30b4817c6b7403b5e9
BLAKE2b-256 2174f4dc086ddda9037d8b99b3a7c7bcd71905909f5c73a0bd664a010fef0154

See more details on using hashes here.

File details

Details for the file sagemaker_tensorflow-1.10.0.1.0.1-cp34-cp34m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for sagemaker_tensorflow-1.10.0.1.0.1-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 cb286769a19856dbe6df0f448652c516a03359bdf03a07578cb062b041573f6f
MD5 8aa5cc4a04c70359863351514db4a00a
BLAKE2b-256 c28ec0e5bc31240899c2f3703d7e4a3459afeeca2ce128d0ac1b769d62e3fdb1

See more details on using hashes here.

File details

Details for the file sagemaker_tensorflow-1.10.0.1.0.1-cp27-cp27mu-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for sagemaker_tensorflow-1.10.0.1.0.1-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2561ce36d54555e7972023e5b7c33b50526ed4165129baa3fe8ce98622fb3bd5
MD5 7f502b5cd5a583ec8d56343d9774518c
BLAKE2b-256 2b1100200ed07b2055c86bf8b6b2064adac6ec555410cd96e91103502edd3ca0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page