Merge branch 'master' into mat_dev_revision

This commit is contained in:
MSalvaris 2018-04-10 11:38:52 +01:00
Родитель 7897c03b47 7d49470dad
Коммит 494fe6bcf5
8 изменённых файлов: 699 добавлений и 977 удалений

Просмотреть файл

@ -11,42 +11,26 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"In this notebook, we will develop the API that will call our model. This module initializes the model, transforms the input so that it is in the appropriate format and defines the scoring method that will produce the predictions."
"In this notebook, we will develop the API that will call our model. This module initializes the model, transforms the input so that it is in the appropriate format and defines the scoring method that will produce the predictions. The API will expect the input to be in JSON format. Once a request is received, the API will convert the json encoded request body into the image format. There are two main functions in the API. The first function loads the model and returns a scoring function. The second function process the images and uses the first function to score them."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Using TensorFlow backend.\n"
]
}
],
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from resnet152 import ResNet152\n",
"from keras.preprocessing import image\n",
"from keras.applications.imagenet_utils import preprocess_input, decode_predictions\n",
"\n",
"import numpy as np\n",
"import timeit as t\n",
"import base64\n",
"import json\n",
"from PIL import Image\n",
"from PIL import ImageOps\n",
"from io import BytesIO\n",
"import logging"
"import logging\n",
"from testing_utilities import img_url_to_json"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here, we develop the functions that will go into the module. Let's first load the model and define the number of top predictions to return."
"We use the writefile magic to write the contents of the below cell to driver.py which includes the driver methods."
]
},
{
@ -58,285 +42,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 16.7 s, sys: 846 ms, total: 17.5 s\n",
"Wall time: 17.3 s\n"
]
}
],
"source": [
"%%time\n",
"model = ResNet152(weights='imagenet')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"number_results = 3"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The API will expect the input to be in JSON format. Below we define the function to convert the image to json using the image path as key and the value as image encoded as a base64 string ."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def img_to_json(img_path):\n",
" with open(img_path, 'rb') as file:\n",
" encoded = base64.b64encode(file.read())\n",
" img_dict = {img_path: encoded.decode('utf-8')}\n",
" body = json.dumps(img_dict)\n",
" return body"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"img_path = '220px-Lynx_lynx_poing.jpg'\n",
"body = img_to_json(img_path)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Once a request is received by the API, we will convert the json encoded request body into the image format."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"base64Dict = json.loads(body) \n",
"for k, v in base64Dict.items():\n",
" img_file_name, base64Img = k, v \n",
"decoded_img = base64.b64decode(base64Img)\n",
"img_buffer = BytesIO(decoded_img)\n",
"imageData = Image.open(img_buffer).convert(\"RGB\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We will then preprocess the image and score it using the model."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'220px-Lynx_lynx_poing.jpg': [('n02127052', 'lynx', 0.98164833),\n",
" ('n02128385', 'leopard', 0.0077441484),\n",
" ('n02123159', 'tiger_cat', 0.0036861449)]}"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"img = ImageOps.fit(imageData, (224, 224), Image.ANTIALIAS)\n",
"img = image.img_to_array(img)\n",
"img = np.expand_dims(img, axis=0)\n",
"img = preprocess_input(img)\n",
"preds = model.predict(img)\n",
"preds = decode_predictions(preds, top=number_results)[0]\n",
"resp = {img_path: preds}\n",
"resp"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Below, we create two functions. The first function loads the model and returns a scoring function. The second function process the images and uses the first function to score them."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def create_scoring_func():\n",
" \"\"\" Initialize ResNet 152 Model \n",
" \"\"\" \n",
" print(\"Executing create_scoring_func() method...\")\n",
" number_results = 3 \n",
" logger = logging.getLogger(\"model_driver\")\n",
"\n",
" start = t.default_timer()\n",
" model = ResNet152(weights='imagenet')\n",
" end = t.default_timer()\n",
" \n",
" loadTimeMsg = \"Model loading time: {0} ms\".format(round((end-start)*1000, 2))\n",
" logger.info(loadTimeMsg)\n",
" \n",
" print(\"Model loading time: {0} ms\".format(round((end-start)*1000, 2)))\n",
" \n",
" def call_model(img_array):\n",
" img_array = np.expand_dims(img_array, axis=0)\n",
" img_array = preprocess_input(img_array)\n",
" preds = model.predict(img_array)\n",
" preds = decode_predictions(preds, top=number_results)[0] \n",
" return preds\n",
" \n",
" return call_model"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def get_model_api():\n",
" logger = logging.getLogger(\"model_driver\")\n",
" scoring_func = create_scoring_func()\n",
" \n",
" def process_and_score(inputString):\n",
" \"\"\" Classify the input using the loaded model\n",
" \"\"\"\n",
" start = t.default_timer()\n",
"\n",
" responses = []\n",
" base64Dict = json.loads(inputString) \n",
" for k, v in base64Dict.items():\n",
" img_file_name, base64Img = k, v \n",
" decoded_img = base64.b64decode(base64Img)\n",
" img_buffer = BytesIO(decoded_img)\n",
" imageData = Image.open(img_buffer).convert(\"RGB\")\n",
" img = ImageOps.fit(imageData, (224, 224), Image.ANTIALIAS)\n",
" img_array = image.img_to_array(img)\n",
" preds = scoring_func(img_array)\n",
" resp = {img_file_name: preds}\n",
" responses.append(resp)\n",
"\n",
" end = t.default_timer()\n",
" \n",
" logger.info(\"Predictions: {0}\".format(responses))\n",
" logger.info(\"Predictions took {0} ms\".format(round((end-start)*1000, 2)))\n",
" return (responses, \"Computed in {0} ms\".format(round((end-start)*1000, 2)))\n",
" return process_and_score"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's test our methods using the same Lynx image."
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"logging.basicConfig(level=logging.DEBUG)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Executing create_scoring_func() method...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:model_driver:Model loading time: 16294.2 ms\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Model loading time: 16294.2 ms\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:model_driver:Predictions: [{'220px-Lynx_lynx_poing.jpg': [('n02127052', 'lynx', 0.98164833), ('n02128385', 'leopard', 0.0077441484), ('n02123159', 'tiger_cat', 0.0036861449)]}]\n",
"INFO:model_driver:Predictions took 1676.34 ms\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"([{'220px-Lynx_lynx_poing.jpg': [('n02127052', 'lynx', 0.98164833), ('n02128385', 'leopard', 0.0077441484), ('n02123159', 'tiger_cat', 0.0036861449)]}], 'Computed in 1676.34 ms')\n"
]
}
],
"source": [
"predict_for = get_model_api()\n",
"img_path = '220px-Lynx_lynx_poing.jpg'\n",
"body = img_to_json(img_path)\n",
"resp = predict_for(body)\n",
"print(resp)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We use the writefile magic to write the contents of the below cell which includes the driver methods we developed earlier to the file driver.py."
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Writing driver.py\n"
"Overwriting driver.py\n"
]
}
],
@ -359,18 +65,17 @@
"number_results = 3\n",
"logger = logging.getLogger(\"model_driver\")\n",
"\n",
"def img_to_json(img_path):\n",
" with open(img_path, 'rb') as file:\n",
" encoded = base64.b64encode(file.read())\n",
" img_dict = {img_path: encoded.decode('utf-8')}\n",
" body = json.dumps(img_dict)\n",
" return body\n",
"def _base64img_to_numpy(base64_img_string):\n",
" decoded_img = base64.b64decode(base64_img_string)\n",
" img_buffer = BytesIO(decoded_img)\n",
" imageData = Image.open(img_buffer).convert(\"RGB\")\n",
" img = ImageOps.fit(imageData, (224, 224), Image.ANTIALIAS)\n",
" img = image.img_to_array(img)\n",
" return img\n",
"\n",
"def create_scoring_func():\n",
" \"\"\" Initialize ResNet 152 Model \n",
" \"\"\" \n",
" print(\"Executing create_scoring_func() method...\")\n",
" \n",
" start = t.default_timer()\n",
" model = ResNet152(weights='imagenet')\n",
" end = t.default_timer()\n",
@ -378,8 +83,6 @@
" loadTimeMsg = \"Model loading time: {0} ms\".format(round((end-start)*1000, 2))\n",
" logger.info(loadTimeMsg)\n",
" \n",
" print(\"Model loading time: {0} ms\".format(round((end-start)*1000, 2)))\n",
" \n",
" def call_model(img_array):\n",
" img_array = np.expand_dims(img_array, axis=0)\n",
" img_array = preprocess_input(img_array)\n",
@ -396,19 +99,13 @@
" def process_and_score(inputString):\n",
" \"\"\" Classify the input using the loaded model\n",
" \"\"\"\n",
" print(\"Executing process_and_score() method...\")\n",
" \n",
" start = t.default_timer()\n",
"\n",
" responses = []\n",
" base64Dict = json.loads(inputString) \n",
" for k, v in base64Dict.items():\n",
" img_file_name, base64Img = k, v \n",
" decoded_img = base64.b64decode(base64Img)\n",
" img_buffer = BytesIO(decoded_img)\n",
" imageData = Image.open(img_buffer).convert(\"RGB\")\n",
" img = ImageOps.fit(imageData, (224, 224), Image.ANTIALIAS)\n",
" img_array = image.img_to_array(img)\n",
" img_array = _base64img_to_numpy(base64Img)\n",
" preds = scoring_func(img_array)\n",
" resp = {img_file_name: preds}\n",
" responses.append(resp)\n",
@ -421,14 +118,7 @@
" return process_and_score\n",
"\n",
"def version():\n",
" return tf.__version__\n",
"\n",
"if __name__ == \"__main__\": \n",
" predict_for = get_model_api()\n",
" img_path = '220px-Lynx_lynx_poing.jpg'\n",
" body = img_to_json(img_path)\n",
" resp = predict_for(body)\n",
" print(resp)"
" return tf.__version__"
]
},
{
@ -440,44 +130,32 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"logging.basicConfig(level=logging.DEBUG)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We run the file driver.py which will bring everything into the context of the notebook."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Executing create_scoring_func() method...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:model_driver:Model loading time: 17030.51 ms\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Model loading time: 17030.51 ms\n",
"Executing process_and_score() method...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:model_driver:Predictions: [{'220px-Lynx_lynx_poing.jpg': [('n02127052', 'lynx', 0.98164833), ('n02128385', 'leopard', 0.0077441484), ('n02123159', 'tiger_cat', 0.0036861449)]}]\n",
"INFO:model_driver:Predictions took 2110.16 ms\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"([{'220px-Lynx_lynx_poing.jpg': [('n02127052', 'lynx', 0.98164833), ('n02128385', 'leopard', 0.0077441484), ('n02123159', 'tiger_cat', 0.0036861449)]}], 'Computed in 2110.16 ms')\n"
"Using TensorFlow backend.\n"
]
}
],
@ -485,6 +163,67 @@
"%run driver.py"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We will use the same Lynx image we used ealier to check that our driver works as expected."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"IMAGEURL = \"https://upload.wikimedia.org/wikipedia/commons/thumb/6/68/Lynx_lynx_poing.jpg/220px-Lynx_lynx_poing.jpg\""
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:model_driver:Model loading time: 15510.97 ms\n"
]
}
],
"source": [
"predict_for = get_model_api()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"DEBUG:PIL.PngImagePlugin:STREAM b'IHDR' 16 13\n",
"DEBUG:PIL.PngImagePlugin:STREAM b'iCCP' 41 292\n",
"DEBUG:PIL.PngImagePlugin:iCCP profile name b'ICC Profile'\n",
"DEBUG:PIL.PngImagePlugin:Compression method 0\n",
"DEBUG:PIL.PngImagePlugin:STREAM b'IDAT' 345 65536\n",
"INFO:model_driver:Predictions: [{'image': [('n02127052', 'lynx', 0.98164833), ('n02128385', 'leopard', 0.0077441484), ('n02123159', 'tiger_cat', 0.0036861449)]}]\n",
"INFO:model_driver:Predictions took 113.41 ms\n"
]
}
],
"source": [
"jsonimg = img_url_to_json(IMAGEURL)\n",
"json_load_img = json.loads(jsonimg)\n",
"body = json_load_img['input']\n",
"resp = predict_for(body)"
]
},
{
"cell_type": "markdown",
"metadata": {},

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -95,7 +95,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 10,
"metadata": {
"collapsed": true
},
@ -157,25 +157,10 @@
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\r\n",
" \"id\": \"/subscriptions/edf507a2-6235-46c5-b560-fd463ba2e771/resourceGroups/fbaksrg\",\r\n",
" \"location\": \"eastus\",\r\n",
" \"managedBy\": null,\r\n",
" \"name\": \"fbaksrg\",\r\n",
" \"properties\": {\r\n",
" \"provisioningState\": \"Succeeded\"\r\n",
" },\r\n",
" \"tags\": null\r\n",
"}\r\n"
]
}
],
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"!az group create --name $resource_group --location $location"
]
@ -196,7 +181,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[K{- Finished ..principal creation[##################################] 100.0000%\n",
"\u001b[K{- Finished ..\n",
" \"additionalProperties\": {},\n",
" \"agentPoolProfiles\": [\n",
" {\n",
@ -214,9 +199,9 @@
" }\n",
" ],\n",
" \"dnsPrefix\": \"fbAKSClust-fbaksrg-edf507\",\n",
" \"fqdn\": \"fbaksclust-fbaksrg-edf507-1d0981c7.hcp.eastus.azmk8s.io\",\n",
" \"fqdn\": \"fbaksclust-fbaksrg-edf507-97ac4d0f.hcp.eastus.azmk8s.io\",\n",
" \"id\": \"/subscriptions/edf507a2-6235-46c5-b560-fd463ba2e771/resourcegroups/fbaksrg/providers/Microsoft.ContainerService/managedClusters/fbAKSCluster\",\n",
" \"kubernetesVersion\": \"1.7.9\",\n",
" \"kubernetesVersion\": \"1.8.10\",\n",
" \"linuxProfile\": {\n",
" \"additionalProperties\": {},\n",
" \"adminUsername\": \"azureuser\",\n",
@ -243,8 +228,8 @@
" \"tags\": null,\n",
" \"type\": \"Microsoft.ContainerService/ManagedClusters\"\n",
"}\n",
"\u001b[0mCPU times: user 25.2 s, sys: 7.32 s, total: 32.5 s\n",
"Wall time: 25min 36s\n"
"\u001b[0mCPU times: user 11.5 s, sys: 4.51 s, total: 16 s\n",
"Wall time: 10min 36s\n"
]
}
],
@ -300,7 +285,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 14,
"metadata": {},
"outputs": [
{
@ -324,7 +309,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 15,
"metadata": {},
"outputs": [
{
@ -332,7 +317,7 @@
"output_type": "stream",
"text": [
"NAME STATUS ROLES AGE VERSION\r\n",
"aks-nodepool1-28016997-0 Ready agent 11m v1.7.9\r\n"
"aks-nodepool1-28016997-0 Ready agent 1d v1.8.10\r\n"
]
}
],
@ -349,7 +334,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 16,
"metadata": {},
"outputs": [
{
@ -357,13 +342,13 @@
"output_type": "stream",
"text": [
"NAMESPACE NAME READY STATUS RESTARTS AGE\r\n",
"kube-system heapster-2574232661-dz21t 2/2 Running 0 12m\r\n",
"kube-system kube-dns-v20-2253765213-6z48m 3/3 Running 0 14m\r\n",
"kube-system kube-dns-v20-2253765213-htqfl 3/3 Running 0 14m\r\n",
"kube-system kube-proxy-50n4d 1/1 Running 0 13m\r\n",
"kube-system kube-svc-redirect-lz97p 1/1 Running 0 13m\r\n",
"kube-system kubernetes-dashboard-2898242510-g0rlq 1/1 Running 0 14m\r\n",
"kube-system tunnelfront-3141404306-34mj0 1/1 Running 0 14m\r\n"
"kube-system heapster-75f8df9884-bph6w 2/2 Running 0 1d\r\n",
"kube-system kube-dns-v20-5bf84586f4-22snr 3/3 Running 0 1d\r\n",
"kube-system kube-dns-v20-5bf84586f4-k6c72 3/3 Running 0 1d\r\n",
"kube-system kube-proxy-bqtt8 1/1 Running 0 1d\r\n",
"kube-system kube-svc-redirect-4jqpq 1/1 Running 2 1d\r\n",
"kube-system kubernetes-dashboard-665f768455-mrmmk 1/1 Running 0 1d\r\n",
"kube-system tunnelfront-76cbc478d6-l5z7j 1/1 Running 0 1d\r\n"
]
}
],
@ -387,7 +372,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 17,
"metadata": {
"collapsed": true
},
@ -426,17 +411,9 @@
" ],\n",
" \"volumeMounts\":[\n",
" {\n",
" \"name\": \"bin\",\n",
" \"mountPath\":\"/usr/local/nvidia/bin\" \n",
" },\n",
" {\n",
" \"name\": \"lib\",\n",
" \"mountPath\":\"/usr/local/nvidia/lib64\" \n",
" },\n",
" {\n",
" \"name\": \"libcuda\",\n",
" \"mountPath\":\"/usr/lib/x86_64-linux-gnu/libcuda.so.1\" \n",
" },\n",
" \"mountPath\":\"/usr/local/nvidia\",\n",
" \"name\": \"nvidia\",\n",
" }\n",
" ],\n",
" \"resources\":{\n",
" \"requests\":{\n",
@ -450,21 +427,9 @@
" ],\n",
" \"volumes\":[\n",
" {\n",
" \"name\": \"bin\",\n",
" \"name\": \"nvidia\",\n",
" \"hostPath\":{\n",
" \"path\":\"/usr/lib/nvidia-384/bin\"\n",
" },\n",
" },\n",
" {\n",
" \"name\": \"lib\",\n",
" \"hostPath\":{\n",
" \"path\":\"/usr/lib/nvidia-384\"\n",
" },\n",
" },\n",
" {\n",
" \"name\": \"libcuda\",\n",
" \"hostPath\":{\n",
" \"path\":\"/usr/lib/x86_64-linux-gnu/libcuda.so.1\"\n",
" \"path\":\"/usr/local/nvidia\"\n",
" },\n",
" },\n",
" ]\n",
@ -495,7 +460,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 18,
"metadata": {
"collapsed": true
},
@ -510,7 +475,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 19,
"metadata": {
"collapsed": true
},
@ -521,7 +486,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 20,
"metadata": {
"collapsed": true
},
@ -539,7 +504,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 21,
"metadata": {},
"outputs": [
{
@ -587,16 +552,8 @@
" },\r\n",
" \"volumeMounts\": [\r\n",
" {\r\n",
" \"mountPath\": \"/usr/local/nvidia/bin\",\r\n",
" \"name\": \"bin\"\r\n",
" },\r\n",
" {\r\n",
" \"mountPath\": \"/usr/local/nvidia/lib64\",\r\n",
" \"name\": \"lib\"\r\n",
" },\r\n",
" {\r\n",
" \"mountPath\": \"/usr/lib/x86_64-linux-gnu/libcuda.so.1\",\r\n",
" \"name\": \"libcuda\"\r\n",
" \"mountPath\": \"/usr/local/nvidia\",\r\n",
" \"name\": \"nvidia\"\r\n",
" }\r\n",
" ]\r\n",
" }\r\n",
@ -604,21 +561,9 @@
" \"volumes\": [\r\n",
" {\r\n",
" \"hostPath\": {\r\n",
" \"path\": \"/usr/lib/nvidia-384/bin\"\r\n",
" \"path\": \"/usr/local/nvidia\"\r\n",
" },\r\n",
" \"name\": \"bin\"\r\n",
" },\r\n",
" {\r\n",
" \"hostPath\": {\r\n",
" \"path\": \"/usr/lib/nvidia-384\"\r\n",
" },\r\n",
" \"name\": \"lib\"\r\n",
" },\r\n",
" {\r\n",
" \"hostPath\": {\r\n",
" \"path\": \"/usr/lib/x86_64-linux-gnu/libcuda.so.1\"\r\n",
" },\r\n",
" \"name\": \"libcuda\"\r\n",
" \"name\": \"nvidia\"\r\n",
" }\r\n",
" ]\r\n",
" }\r\n",
@ -661,7 +606,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 22,
"metadata": {},
"outputs": [
{
@ -686,7 +631,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 23,
"metadata": {},
"outputs": [
{
@ -694,14 +639,14 @@
"output_type": "stream",
"text": [
"NAMESPACE NAME READY STATUS RESTARTS AGE\r\n",
"default azure-dl-1885859937-8vrkv 0/1 ContainerCreating 0 40s\r\n",
"kube-system heapster-2574232661-dz21t 2/2 Running 0 17m\r\n",
"kube-system kube-dns-v20-2253765213-6z48m 3/3 Running 0 18m\r\n",
"kube-system kube-dns-v20-2253765213-htqfl 3/3 Running 0 18m\r\n",
"kube-system kube-proxy-50n4d 1/1 Running 0 18m\r\n",
"kube-system kube-svc-redirect-lz97p 1/1 Running 0 18m\r\n",
"kube-system kubernetes-dashboard-2898242510-g0rlq 1/1 Running 0 18m\r\n",
"kube-system tunnelfront-3141404306-34mj0 1/1 Running 0 18m\r\n"
"default azure-dl-5c4bfdb7f9-2cbr8 0/1 ContainerCreating 0 5s\r\n",
"kube-system heapster-75f8df9884-bph6w 2/2 Running 0 1d\r\n",
"kube-system kube-dns-v20-5bf84586f4-22snr 3/3 Running 0 1d\r\n",
"kube-system kube-dns-v20-5bf84586f4-k6c72 3/3 Running 0 1d\r\n",
"kube-system kube-proxy-bqtt8 1/1 Running 0 1d\r\n",
"kube-system kube-svc-redirect-4jqpq 1/1 Running 2 1d\r\n",
"kube-system kubernetes-dashboard-665f768455-mrmmk 1/1 Running 0 1d\r\n",
"kube-system tunnelfront-76cbc478d6-l5z7j 1/1 Running 0 1d\r\n"
]
}
],
@ -718,30 +663,30 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 38,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"LAST SEEN FIRST SEEN COUNT NAME KIND SUBOBJECT TYPE REASON SOURCE MESSAGE\r\n",
"19m 24m 7 aks-nodepool1-28016997-0.152241072750679b Node Normal NodeHasSufficientDisk kubelet, aks-nodepool1-28016997-0 Node aks-nodepool1-28016997-0 status is now: NodeHasSufficientDisk\r\n",
"19m 24m 7 aks-nodepool1-28016997-0.152241072750d04b Node Normal NodeHasSufficientMemory kubelet, aks-nodepool1-28016997-0 Node aks-nodepool1-28016997-0 status is now: NodeHasSufficientMemory\r\n",
"19m 24m 7 aks-nodepool1-28016997-0.152241072750f823 Node Normal NodeHasNoDiskPressure kubelet, aks-nodepool1-28016997-0 Node aks-nodepool1-28016997-0 status is now: NodeHasNoDiskPressure\r\n",
"18s 24m 25 aks-nodepool1-28016997-0.15224107276aae85 Node Warning FailedNodeAllocatableEnforcement kubelet, aks-nodepool1-28016997-0 Failed to update Node Allocatable Limits \"\": failed to set supported cgroup subsystems for cgroup : Failed to set config for supported subsystems : failed to write 59076296704 to memory.limit_in_bytes: write /var/lib/docker/overlay2/4070e9a54f4f4a87849606914ee89de08c93e79ce54ee3531a9b6c3709d42ae4/merged/sys/fs/cgroup/memory/memory.limit_in_bytes: invalid argument\r\n",
"19m 19m 1 aks-nodepool1-28016997-0.1522414beca18a13 Node Normal RegisteredNode controllermanager Node aks-nodepool1-28016997-0 event: Registered Node aks-nodepool1-28016997-0 in NodeController\r\n",
"19m 19m 1 aks-nodepool1-28016997-0.1522414c5efa4db5 Node Normal Starting kube-proxy, aks-nodepool1-28016997-0 Starting kube-proxy.\r\n",
"19m 19m 1 aks-nodepool1-28016997-0.152241509d336387 Node Normal NodeReady kubelet, aks-nodepool1-28016997-0 Node aks-nodepool1-28016997-0 status is now: NodeReady\r\n",
"1m 1m 1 azure-dl-1885859937-8vrkv.1522424350d2a97e Pod Normal Scheduled default-scheduler Successfully assigned azure-dl-1885859937-8vrkv to aks-nodepool1-28016997-0\r\n",
"1m 1m 1 azure-dl-1885859937-8vrkv.1522424360b50d57 Pod Normal SuccessfulMountVolume kubelet, aks-nodepool1-28016997-0 MountVolume.SetUp succeeded for volume \"libcuda\" \r\n",
"1m 1m 1 azure-dl-1885859937-8vrkv.1522424360b57283 Pod Normal SuccessfulMountVolume kubelet, aks-nodepool1-28016997-0 MountVolume.SetUp succeeded for volume \"lib\" \r\n",
"1m 1m 1 azure-dl-1885859937-8vrkv.1522424360d1d3ad Pod Normal SuccessfulMountVolume kubelet, aks-nodepool1-28016997-0 MountVolume.SetUp succeeded for volume \"bin\" \r\n",
"1m 1m 1 azure-dl-1885859937-8vrkv.152242436145e3e8 Pod Normal SuccessfulMountVolume kubelet, aks-nodepool1-28016997-0 MountVolume.SetUp succeeded for volume \"default-token-jjmz3\" \r\n",
"1m 1m 1 azure-dl-1885859937-8vrkv.152242438780c811 Pod spec.containers{azure-dl} Normal Pulling kubelet, aks-nodepool1-28016997-0 pulling image \"fboylu/kerastf-gpu\"\r\n",
"1m 1m 1 azure-dl-1885859937.152242434ff604d9 ReplicaSet Normal SuccessfulCreate replicaset-controller Created pod: azure-dl-1885859937-8vrkv\r\n",
"1m 1m 1 azure-dl.152242434d86dc7a Deployment Normal ScalingReplicaSet deployment-controller Scaled up replica set azure-dl-1885859937 to 1\r\n",
"1m 1m 1 azure-dl.1522424351ea960b Service Normal CreatingLoadBalancer service-controller Creating load balancer\r\n"
"LAST SEEN FIRST SEEN COUNT NAME KIND SUBOBJECT TYPE REASON SOURCE MESSAGE\r\n",
"2m 2m 1 azure-dl-5c4bfdb7f9-2cbr8.1522f0360f3d02c1 Pod Normal Scheduled default-scheduler Successfully assigned azure-dl-5c4bfdb7f9-2cbr8 to aks-nodepool1-28016997-0\r\n",
"2m 2m 1 azure-dl-5c4bfdb7f9-2cbr8.1522f03617f016e9 Pod Normal SuccessfulMountVolume kubelet, aks-nodepool1-28016997-0 MountVolume.SetUp succeeded for volume \"nvidia\" \r\n",
"2m 2m 1 azure-dl-5c4bfdb7f9-2cbr8.1522f03618d2762c Pod Normal SuccessfulMountVolume kubelet, aks-nodepool1-28016997-0 MountVolume.SetUp succeeded for volume \"default-token-m6g6j\" \r\n",
"2m 2m 1 azure-dl-5c4bfdb7f9-2cbr8.1522f03649a8c645 Pod spec.containers{azure-dl} Normal Pulling kubelet, aks-nodepool1-28016997-0 pulling image \"fboylu/kerastf-gpu\"\r\n",
"18s 18s 1 azure-dl-5c4bfdb7f9-2cbr8.1522f050f5e4df8d Pod spec.containers{azure-dl} Normal Pulled kubelet, aks-nodepool1-28016997-0 Successfully pulled image \"fboylu/kerastf-gpu\"\r\n",
"18s 18s 1 azure-dl-5c4bfdb7f9-2cbr8.1522f051056ca105 Pod spec.containers{azure-dl} Normal Created kubelet, aks-nodepool1-28016997-0 Created container\r\n",
"18s 18s 1 azure-dl-5c4bfdb7f9-2cbr8.1522f0510fbe4c26 Pod spec.containers{azure-dl} Normal Started kubelet, aks-nodepool1-28016997-0 Started container\r\n",
"54m 54m 1 azure-dl-5c4bfdb7f9-vj779.1522ed6036c2b01d Pod spec.containers{azure-dl} Normal Killing kubelet, aks-nodepool1-28016997-0 Killing container with id docker://azure-dl:Need to kill Pod\r\n",
"54m 54m 1 azure-dl-5c4bfdb7f9.1522ed5d59cba8cb ReplicaSet Normal SuccessfulDelete replicaset-controller Deleted pod: azure-dl-5c4bfdb7f9-vj779\r\n",
"2m 2m 1 azure-dl-5c4bfdb7f9.1522f0360e28a2b7 ReplicaSet Normal SuccessfulCreate replicaset-controller Created pod: azure-dl-5c4bfdb7f9-2cbr8\r\n",
"54m 54m 1 azure-dl.1522ed5d596a4e3c Deployment Normal ScalingReplicaSet deployment-controller Scaled down replica set azure-dl-5c4bfdb7f9 to 0\r\n",
"54m 54m 1 azure-dl.1522ed5e233e3ee5 Service Normal DeletingLoadBalancer service-controller Deleting load balancer\r\n",
"51m 51m 1 azure-dl.1522ed7fb415b2f5 Service Normal DeletedLoadBalancer service-controller Deleted load balancer\r\n",
"2m 2m 1 azure-dl.1522f0360d81f74d Deployment Normal ScalingReplicaSet deployment-controller Scaled up replica set azure-dl-5c4bfdb7f9 to 1\r\n",
"2m 2m 1 azure-dl.1522f036105ae857 Service Normal EnsuringLoadBalancer service-controller Ensuring load balancer\r\n",
"7s 7s 1 azure-dl.1522f0536ea71117 Service Normal EnsuredLoadBalancer service-controller Ensured load balancer\r\n"
]
}
],
@ -758,7 +703,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 34,
"metadata": {
"collapsed": true
},
@ -770,72 +715,130 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 41,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2018-04-04 14:37:42,384 CRIT Supervisor running as root (no user in config file)\r\n",
"2018-04-04 14:37:42,386 INFO supervisord started with pid 8\r\n",
"2018-04-04 14:37:43,388 INFO spawned: 'program_exit' with pid 18\r\n",
"2018-04-04 14:37:43,389 INFO spawned: 'nginx' with pid 19\r\n",
"2018-04-04 14:37:43,391 INFO spawned: 'gunicorn' with pid 20\r\n",
"2018-04-04 14:37:44,435 INFO success: program_exit entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)\r\n",
"2018-04-04 14:37:44.880056: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA\r\n",
"2018-04-04 14:37:48,887 INFO success: nginx entered RUNNING state, process has stayed up for > than 5 seconds (startsecs)\r\n",
"2018-04-04 14:37:54.419320: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Found device 0 with properties: \r\n",
"2018-04-06 19:44:14,983 CRIT Supervisor running as root (no user in config file)\r\n",
"2018-04-06 19:44:14,985 INFO supervisord started with pid 1\r\n",
"2018-04-06 19:44:15,988 INFO spawned: 'program_exit' with pid 11\r\n",
"2018-04-06 19:44:15,989 INFO spawned: 'nginx' with pid 12\r\n",
"2018-04-06 19:44:15,990 INFO spawned: 'gunicorn' with pid 13\r\n",
"2018-04-06 19:44:17,021 INFO success: program_exit entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)\r\n",
"2018-04-06 19:44:17.421986: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA\r\n",
"2018-04-06 19:44:21,427 INFO success: nginx entered RUNNING state, process has stayed up for > than 5 seconds (startsecs)\r\n",
"2018-04-06 19:44:24.311778: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Found device 0 with properties: \r\n",
"name: Tesla K80 major: 3 minor: 7 memoryClockRate(GHz): 0.8235\r\n",
"pciBusID: f542:00:00.0\r\n",
"pciBusID: f115:00:00.0\r\n",
"totalMemory: 11.17GiB freeMemory: 11.10GiB\r\n",
"2018-04-04 14:37:54.419396: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: Tesla K80, pci bus id: f542:00:00.0, compute capability: 3.7)\r\n",
"2018-04-04 14:38:03,427 INFO success: gunicorn entered RUNNING state, process has stayed up for > than 20 seconds (startsecs)\r\n",
"Executing create_scoring_func() method...\r\n",
"2018-04-06 19:44:24.311825: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: Tesla K80, pci bus id: f115:00:00.0, compute capability: 3.7)\r\n",
"2018-04-06 19:44:36,320 INFO success: gunicorn entered RUNNING state, process has stayed up for > than 20 seconds (startsecs)\r\n",
"Downloading data from https://github.com/adamcasson/resnet152/releases/download/v0.1/resnet152_weights_tf.h5\r\n",
"\r\n",
" 8192/243179624 [..............................] - ETA: 1:08\r\n",
" 1556480/243179624 [..............................] - ETA: 8s \r\n",
" 4546560/243179624 [..............................] - ETA: 5s\r\n",
" 9314304/243179624 [>.............................] - ETA: 3s\r\n",
" 14360576/243179624 [>.............................] - ETA: 3s\r\n",
" 19898368/243179624 [=>............................] - ETA: 2s\r\n",
" 23560192/243179624 [=>............................] - ETA: 2s\r\n",
" 30400512/243179624 [==>...........................] - ETA: 2s\r\n",
" 39231488/243179624 [===>..........................] - ETA: 2s\r\n",
" 48078848/243179624 [====>.........................] - ETA: 1s\r\n",
" 53477376/243179624 [=====>........................] - ETA: 1s\r\n",
" 62218240/243179624 [======>.......................] - ETA: 1s\r\n",
" 69214208/243179624 [=======>......................] - ETA: 3s\r\n",
" 73629696/243179624 [========>.....................] - ETA: 3s\r\n",
" 81166336/243179624 [=========>....................] - ETA: 3s\r\n",
" 86802432/243179624 [=========>....................] - ETA: 3s\r\n",
" 90177536/243179624 [==========>...................] - ETA: 2s\r\n",
" 94543872/243179624 [==========>...................] - ETA: 2s\r\n",
"102400000/243179624 [===========>..................] - ETA: 2s\r\n",
"107134976/243179624 [============>.................] - ETA: 2s\r\n",
"112795648/243179624 [============>.................] - ETA: 2s\r\n",
"118505472/243179624 [=============>................] - ETA: 2s\r\n",
"124223488/243179624 [==============>...............] - ETA: 1s\r\n",
"130670592/243179624 [===============>..............] - ETA: 1s\r\n",
"136347648/243179624 [===============>..............] - ETA: 1s\r\n",
"140025856/243179624 [================>.............] - ETA: 1s\r\n",
"148250624/243179624 [=================>............] - ETA: 1s\r\n",
"157220864/243179624 [==================>...........] - ETA: 1s\r\n",
"166453248/243179624 [===================>..........] - ETA: 1s\r\n",
"173039616/243179624 [====================>.........] - ETA: 0s\r\n",
"178798592/243179624 [=====================>........] - ETA: 0s\r\n",
"187072512/243179624 [======================>.......] - ETA: 0s\r\n",
"193331200/243179624 [======================>.......] - ETA: 0s\r\n",
"198623232/243179624 [=======================>......] - ETA: 0s\r\n",
"201015296/243179624 [=======================>......] - ETA: 0s\r\n",
"203390976/243179624 [========================>.....] - ETA: 0s\r\n",
"211050496/243179624 [=========================>....] - ETA: 0s\r\n",
"215146496/243179624 [=========================>....] - ETA: 0s\r\n",
"222715904/243179624 [==========================>...] - ETA: 0s\r\n",
"231104512/243179624 [===========================>..] - ETA: 0s\r\n",
"239443968/243179624 [============================>.] - ETA: 0s\r\n",
"243187712/243179624 [==============================] - 3s 0us/step\r\n"
" 8192/243179624 [..............................] - ETA: 1:10\r\n",
" 843776/243179624 [..............................] - ETA: 15s \r\n",
" 2981888/243179624 [..............................] - ETA: 8s \r\n",
" 4530176/243179624 [..............................] - ETA: 8s\r\n",
" 5275648/243179624 [..............................] - ETA: 9s\r\n",
" 5971968/243179624 [..............................] - ETA: 10s\r\n",
" 6881280/243179624 [..............................] - ETA: 10s\r\n",
" 7839744/243179624 [..............................] - ETA: 10s\r\n",
" 8847360/243179624 [>.............................] - ETA: 10s\r\n",
" 9633792/243179624 [>.............................] - ETA: 11s\r\n",
" 10346496/243179624 [>.............................] - ETA: 11s\r\n",
" 11214848/243179624 [>.............................] - ETA: 11s\r\n",
" 12050432/243179624 [>.............................] - ETA: 11s\r\n",
" 13058048/243179624 [>.............................] - ETA: 11s\r\n",
" 14090240/243179624 [>.............................] - ETA: 11s\r\n",
" 15114240/243179624 [>.............................] - ETA: 11s\r\n",
" 16195584/243179624 [>.............................] - ETA: 11s\r\n",
" 17465344/243179624 [=>............................] - ETA: 11s\r\n",
" 18685952/243179624 [=>............................] - ETA: 11s\r\n",
" 20013056/243179624 [=>............................] - ETA: 10s\r\n",
" 21397504/243179624 [=>............................] - ETA: 10s\r\n",
" 22323200/243179624 [=>............................] - ETA: 10s\r\n",
" 23502848/243179624 [=>............................] - ETA: 10s\r\n",
" 24707072/243179624 [==>...........................] - ETA: 10s\r\n",
" 25993216/243179624 [==>...........................] - ETA: 10s\r\n",
" 27262976/243179624 [==>...........................] - ETA: 10s\r\n",
" 28639232/243179624 [==>...........................] - ETA: 9s \r\n",
" 30121984/243179624 [==>...........................] - ETA: 9s\r\n",
" 31703040/243179624 [==>...........................] - ETA: 9s\r\n",
" 33316864/243179624 [===>..........................] - ETA: 9s\r\n",
" 34783232/243179624 [===>..........................] - ETA: 9s\r\n",
" 36487168/243179624 [===>..........................] - ETA: 8s\r\n",
" 37953536/243179624 [===>..........................] - ETA: 8s\r\n",
" 39493632/243179624 [===>..........................] - ETA: 8s\r\n",
" 41312256/243179624 [====>.........................] - ETA: 8s\r\n",
" 43073536/243179624 [====>.........................] - ETA: 8s\r\n",
" 44900352/243179624 [====>.........................] - ETA: 8s\r\n",
" 46931968/243179624 [====>.........................] - ETA: 7s\r\n",
" 49004544/243179624 [=====>........................] - ETA: 7s\r\n",
" 51134464/243179624 [=====>........................] - ETA: 7s\r\n",
" 53387264/243179624 [=====>........................] - ETA: 7s\r\n",
" 55656448/243179624 [=====>........................] - ETA: 6s\r\n",
" 57933824/243179624 [======>.......................] - ETA: 6s\r\n",
" 60358656/243179624 [======>.......................] - ETA: 6s\r\n",
" 62808064/243179624 [======>.......................] - ETA: 6s\r\n",
" 65257472/243179624 [=======>......................] - ETA: 6s\r\n",
" 67690496/243179624 [=======>......................] - ETA: 6s\r\n",
" 70246400/243179624 [=======>......................] - ETA: 5s\r\n",
" 72957952/243179624 [========>.....................] - ETA: 5s\r\n",
" 75694080/243179624 [========>.....................] - ETA: 5s\r\n",
" 78462976/243179624 [========>.....................] - ETA: 5s\r\n",
" 81379328/243179624 [=========>....................] - ETA: 5s\r\n",
" 84295680/243179624 [=========>....................] - ETA: 4s\r\n",
" 87343104/243179624 [=========>....................] - ETA: 4s\r\n",
" 90406912/243179624 [==========>...................] - ETA: 4s\r\n",
" 93585408/243179624 [==========>...................] - ETA: 4s\r\n",
" 96829440/243179624 [==========>...................] - ETA: 4s\r\n",
"100114432/243179624 [===========>..................] - ETA: 4s\r\n",
"103333888/243179624 [===========>..................] - ETA: 3s\r\n",
"106758144/243179624 [============>.................] - ETA: 3s\r\n",
"110215168/243179624 [============>.................] - ETA: 3s\r\n",
"113745920/243179624 [=============>................] - ETA: 3s\r\n",
"117161984/243179624 [=============>................] - ETA: 3s\r\n",
"120692736/243179624 [=============>................] - ETA: 3s\r\n",
"124338176/243179624 [==============>...............] - ETA: 3s\r\n",
"127926272/243179624 [==============>...............] - ETA: 2s\r\n",
"130719744/243179624 [===============>..............] - ETA: 2s\r\n",
"133398528/243179624 [===============>..............] - ETA: 2s\r\n",
"136134656/243179624 [===============>..............] - ETA: 2s\r\n",
"138887168/243179624 [================>.............] - ETA: 2s\r\n",
"141598720/243179624 [================>.............] - ETA: 2s\r\n",
"144539648/243179624 [================>.............] - ETA: 2s\r\n",
"147103744/243179624 [=================>............] - ETA: 2s\r\n",
"149987328/243179624 [=================>............] - ETA: 2s\r\n",
"152928256/243179624 [=================>............] - ETA: 2s\r\n",
"156049408/243179624 [==================>...........] - ETA: 2s\r\n",
"158867456/243179624 [==================>...........] - ETA: 2s\r\n",
"162021376/243179624 [==================>...........] - ETA: 1s\r\n",
"165134336/243179624 [===================>..........] - ETA: 1s\r\n",
"168419328/243179624 [===================>..........] - ETA: 1s\r\n",
"171769856/243179624 [====================>.........] - ETA: 1s\r\n",
"175128576/243179624 [====================>.........] - ETA: 1s\r\n",
"178503680/243179624 [=====================>........] - ETA: 1s\r\n",
"181608448/243179624 [=====================>........] - ETA: 1s\r\n",
"185114624/243179624 [=====================>........] - ETA: 1s\r\n",
"188653568/243179624 [======================>.......] - ETA: 1s\r\n",
"192258048/243179624 [======================>.......] - ETA: 1s\r\n",
"195944448/243179624 [=======================>......] - ETA: 1s\r\n",
"199761920/243179624 [=======================>......] - ETA: 0s\r\n",
"203366400/243179624 [========================>.....] - ETA: 0s\r\n",
"207011840/243179624 [========================>.....] - ETA: 0s\r\n",
"210903040/243179624 [=========================>....] - ETA: 0s\r\n",
"214384640/243179624 [=========================>....] - ETA: 0s\r\n",
"218349568/243179624 [=========================>....] - ETA: 0s\r\n",
"222142464/243179624 [==========================>...] - ETA: 0s\r\n",
"226222080/243179624 [==========================>...] - ETA: 0s\r\n",
"230293504/243179624 [===========================>..] - ETA: 0s\r\n",
"234438656/243179624 [===========================>..] - ETA: 0s\r\n",
"238493696/243179624 [============================>.] - ETA: 0s\r\n",
"242671616/243179624 [============================>.] - ETA: 0s\r\n",
"243187712/243179624 [==============================] - 5s 0us/step\r\n"
]
}
],
@ -845,7 +848,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 40,
"metadata": {},
"outputs": [
{
@ -853,7 +856,7 @@
"output_type": "stream",
"text": [
"NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE\r\n",
"azure-dl 1 1 1 1 28m\r\n"
"azure-dl 1 1 1 1 2m\r\n"
]
}
],
@ -870,15 +873,15 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 42,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE\r\n",
"azure-dl LoadBalancer 10.0.107.160 52.224.106.118 80:31114/TCP 28m\r\n"
"NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE\r\n",
"azure-dl LoadBalancer 10.0.12.158 52.186.67.95 80:30022/TCP 2m\r\n"
]
}
],
@ -902,7 +905,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 70,
"metadata": {},
"outputs": [
{
@ -920,15 +923,14 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 31,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[K\u001b[31mDeployment failed. Correlation ID: 4535be5c-80cf-4c58-a2fa-7feef2577a42. Unexpected response trying to delete control plane\u001b[0m\n",
"\u001b[0m"
"\u001b[K\u001b[0minished .."
]
}
],
@ -938,7 +940,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 32,
"metadata": {},
"outputs": [
{

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -39,19 +39,13 @@ def to_img(img_url):
to_rgb,
resize(new_size=(224,224)))
def img_url_to_json(url):
img_data = toolz.pipe(url,
to_img,
def img_url_to_json(url, label='image'):
img_data = toolz.pipe(url,
to_img,
to_base64)
return json.dumps({'input':'[\"{0}\"]'.format(img_data)})
def img_url_to_json_dict(url):
img_url_name = url.split('/')[-1]
encoded = to_base64(to_img(url))
img_dict = {img_url_name: encoded}
img_dict = {label: img_data}
body = json.dumps(img_dict)
return json.dumps({'input':'{}'.format(body)})
return json.dumps({'input':'{0}'.format(body)})
def _plot_image(ax, img):

Просмотреть файл

@ -1,9 +1,9 @@
### Authors: Mathew Salvaris and Fidan Boylu Uz
# Deploy Deep Learning CNN on Kubernetes Cluster with GPUs
In this repository there are a number of tutorials in Jupyter notebooks that have step-by-step instruction on how to deploy a pretrained deep learning model on a GPU enabled Kubernetes cluster. The tutorials cover how to deploy models from the following deep learning frameworks:
In this repository there are a number of tutorials in Jupyter notebooks that have step-by-step instructions on how to deploy a pretrained deep learning model on a GPU enabled Kubernetes cluster. The tutorials cover how to deploy models from the following deep learning frameworks:
* [TensorFlow](Tensorflow)
* Keras (TensorFlow backend)
* [Keras (TensorFlow backend)](Keras_Tensorflow)
* Pytorch
![alt text](static/example.png "Example Classification")
@ -15,7 +15,7 @@ In this repository there are a number of tutorials in Jupyter notebooks that hav
* Testing our Docker image before deployment
* Creating our Kubernetes cluster and deploying our application to it
* Testing the deployed model
* Testing the throughput of out model
* Testing the throughput of our model
The application we will develop is a simple image classification service, where we will submit an image and get back what class the image belongs to.