Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Hosting ONNX models with Amazon Elastic Inference\n",
"# Hosting ONNX models with Amazon Elastic Inference (Testing)\n",
"\n",
"*(This notebook was tested with the \"Python 3 (MXNet CPU Optimized)\" kernel.)*\n",
"\n",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Hello World!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"How are you?"
]
}
],
"metadata": {
"anaconda-cloud": {},
"celltoolbar": "Tags",
"instance_type": "ml.t3.medium",
"kernelspec": {
"display_name": "Python 3 (Data Science)",
"language": "python",
"name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:us-west-2:236514542706:image/datascience-1.0"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Some Dumb Notebook I Wrote"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook has no purpose"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import sagemaker"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(\"Hello world with code!\")"
]
}
],
"metadata": {
"anaconda-cloud": {},
"celltoolbar": "Tags",
"instance_type": "ml.t3.medium",
"kernelspec": {
"display_name": "Python 3 (Data Science)",
"language": "python",
"name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:us-west-2:236514542706:image/datascience-1.0"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Original file line number Diff line number Diff line change
Expand Up @@ -200,25 +200,6 @@
"with fs.open(data_s3fs_location) as f:\n",
" print(pd.read_csv(f, nrows=5))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### 3.2 AWS Data Wrangler\n",
"[AWS Data Wrangler](https://github.com/awslabs/aws-data-wrangler) is an open-source Python library that extends the power of the Pandas library to AWS connecting DataFrames and AWS data related services (Amazon Redshift, AWS Glue, Amazon Athena, Amazon EMR, Amazon QuickSight, etc), which we will cover in later sections. It is built on top of other open-source projects like Pandas, Apache Arrow, Boto3, s3fs, SQLAlchemy, Psycopg2 and PyMySQL, and offers abstracted functions to execute usual ETL tasks like load/unload data from Data Lakes, Data Warehouses and Databases. Note that you would need `s3fs version > 0.4.0` for the `awswrangler csv reader` to work."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"data_wr_location = \"s3://{}/{}/{}\".format(bucket, prefix, filename) # S3 URL\n",
"wr_data = wr.s3.read_csv(path=data_wr_location, nrows=5)\n",
"wr_data.head()"
]
}
],
"metadata": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,18 +480,6 @@
"text_data_new.to_csv(filename, index=False)\n",
"upload_to_s3(bucket, \"text_twitter_sentiment_full\", filename)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Citation\n",
"Twitter140 Data, Go, A., Bhayani, R. and Huang, L., 2009. Twitter sentiment classification using distant supervision. CS224N Project Report, Stanford, 1(2009), p.12.\n",
"\n",
"SMS Spaming data, Almeida, T.A., Gómez Hidalgo, J.M., Yamakami, A. Contributions to the Study of SMS Spam Filtering: New Collection and Results. Proceedings of the 2011 ACM Symposium on Document Engineering (DOCENG'11), Mountain View, CA, USA, 2011.\n",
"\n",
"J! Archive, J! Archive is created by fans, for fans. The Jeopardy! game show and all elements thereof, including but not limited to copyright and trademark thereto, are the property of Jeopardy Productions, Inc. and are protected under law. This website is not affiliated with, sponsored by, or operated by Jeopardy Productions, Inc."
]
}
],
"metadata": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# MNIST Training with MXNet and Gluon\n",
"## MNIST Training with MXNet and Gluon (Testing)\n",
"\n",
"MNIST is a widely used dataset for handwritten digit classification. It consists of 70,000 labeled 28x28 pixel grayscale images of hand-written digits. The dataset is split into 60,000 training images and 10,000 test images. There are 10 classes (one for each of the 10 digits). This tutorial shows how to train and test an MNIST model on SageMaker using MXNet and the Gluon API.\n",
"\n",
Expand Down Expand Up @@ -36,7 +36,8 @@
"\n",
"sagemaker_session = sagemaker.Session()\n",
"\n",
"role = get_execution_role()"
"role = get_execution_role()\n",
"print(role)"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@
"# SageMaker Real-time Dynamic Batching Inference with Torchserve"
]
},
{
"cell_type": "markdown",
"id": "d1647aa0-0140-40fc-bf58-bd8cf786d7a4",
"metadata": {},
"source": [
"This notebook demonstrates the use of dynamic batching on SageMaker with [torchserve](https://github.com/pytorch/serve/) as a model server. It demonstrates the following\n",
"1. Batch inference using DLC i.e. SageMaker's default backend container. This is done by using SageMaker python sdk in script-mode.\n",
"2. Specifying inference parameters for torchserve using environment variables.\n",
"3. Option to use a custom container with config file for torchserve baked-in the container."
]
},
{
"cell_type": "markdown",
"id": "beb7434c-2d73-41dc-a56c-7db10b9f552f",
Expand Down Expand Up @@ -264,16 +253,6 @@
"source": [
"predictor.delete_endpoint(predictor.endpoint_name)"
]
},
{
"cell_type": "markdown",
"id": "1c7d981a-46de-46af-9e96-fcd66e3f057a",
"metadata": {},
"source": [
"## Conclusion\n",
"\n",
"Through this exercise, we were able to understand the basics of batch inference using torchserve on Amazon SageMaker. We learnt that we can have several inference requests from different processes/users batched together, and the results will be processed as a batch of inputs. We also learnt that we could either use SageMaker's default DLC container as the base environment, and supply an inference.py script with the model, or create a custom container that can be used with SageMaker for more involved workflows."
]
}
],
"metadata": {
Expand Down
20 changes: 10 additions & 10 deletions sagemaker-python-sdk/pytorch_mnist/pytorch_mnist.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,7 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[33mWARNING: Skipping torchvison as it is not installed.\u001b[0m\n",
"yes: standard output: Broken pipe\n"
]
}
],
"outputs": [],
"source": [
"!yes | pip uninstall torchvison\n",
"!pip install -qU torchvision"
Expand Down Expand Up @@ -711,6 +702,15 @@
"source": [
"sagemaker_session.delete_endpoint(endpoint_name=predictor.endpoint_name)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(\"End of notebook\")"
]
}
],
"metadata": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,72 +148,7 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%capture output\n",
"\n",
"from sagemaker.processing import ProcessingInput, ProcessingOutput\n",
"\n",
"sklearn_processor.run(\n",
" code=\"preprocessing.py\",\n",
" # arguments = [\"arg1\", \"arg2\"], # Arguments can optionally be specified here\n",
" inputs=[ProcessingInput(source=\"dataset.csv\", destination=\"/opt/ml/processing/input\")],\n",
" outputs=[\n",
" ProcessingOutput(source=\"/opt/ml/processing/output/train\"),\n",
" ProcessingOutput(source=\"/opt/ml/processing/output/validation\"),\n",
" ProcessingOutput(source=\"/opt/ml/processing/output/test\"),\n",
" ],\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Get the Processing job logs and retrieve the job name."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(output)\n",
"job_name = str(output).split(\"\\n\")[1].split(\" \")[-1]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Confirm that the output dataset files were written to S3."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import boto3\n",
"\n",
"s3_client = boto3.client(\"s3\")\n",
"default_bucket = sagemaker.Session().default_bucket()\n",
"for i in range(1, 4):\n",
" prefix = s3_client.list_objects(\n",
" Bucket=default_bucket, Prefix=job_name + \"/output/output-\" + str(i) + \"/\"\n",
" )[\"Contents\"][0][\"Key\"]\n",
" print(\"s3://\" + default_bucket + \"/\" + prefix)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Conclusion\n",
"\n",
"In this notebook, we read a dataset from S3 and processed it into train, test, and validation sets using a SageMaker Processing job. You can extend this example for preprocessing your own datasets in preparation for machine learning or other applications."
]
"source": []
}
],
"metadata": {
Expand Down

This file was deleted.