diff --git a/examples/Dask/dask.ipynb b/examples/Dask/dask.ipynb new file mode 100644 index 0000000..65399c3 --- /dev/null +++ b/examples/Dask/dask.ipynb @@ -0,0 +1,161 @@ +{ + "cells": [ + { + "cell_type": "code", + "source": [ + "from dask.distributed import Client, LocalCluster, progress\n", + "client = Client(LocalCluster(ip='0.0.0.0', scheduler_port=12345, n_workers=0))\n", + "client" + ], + "outputs": [], + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": false, + "outputs_hidden": false + }, + "nteract": { + "transient": { + "deleting": false + } + }, + "gather": { + "logged": 1720186325924 + } + } + }, + { + "cell_type": "code", + "source": [ + "import time\n", + "import random\n", + "\n", + "def inc(x):\n", + " time.sleep(random.random())\n", + " return x + 1\n", + "\n", + "def double(x):\n", + " time.sleep(random.random())\n", + " return 2 * x\n", + "\n", + "def add(x, y):\n", + " time.sleep(random.random())\n", + " return x + y\n", + " " + ], + "outputs": [], + "execution_count": null, + "metadata": { + "gather": { + "logged": 1720186729193 + } + } + }, + { + "cell_type": "code", + "source": [ + "zs = []" + ], + "outputs": [], + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": false, + "outputs_hidden": false + }, + "nteract": { + "transient": { + "deleting": false + } + }, + "gather": { + "logged": 1720186731185 + } + } + }, + { + "cell_type": "code", + "source": [ + "%%time\n", + "\n", + "for i in range(1024):\n", + " x = client.submit(inc, i) # x = inc(i)\n", + " y = client.submit(double, x) # y = inc(x)\n", + " z = client.submit(add, x, y) # z = inc(y)\n", + " zs.append(z)" + ], + "outputs": [], + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": false, + "outputs_hidden": false + }, + "nteract": { + "transient": { + "deleting": false + } + } + } + }, + { + "cell_type": "code", + "source": [ + "client.shutdown()" + ], + "outputs": [], + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": false, + "outputs_hidden": false + }, + "nteract": { + "transient": { + "deleting": false + } + }, + "gather": { + "logged": 1720187187366 + } + } + } + ], + "metadata": { + "kernelspec": { + "name": "python38-azureml", + "language": "python", + "display_name": "Python 3.8 - AzureML" + }, + "language_info": { + "name": "python", + "version": "3.9.19", + "mimetype": "text/x-python", + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "pygments_lexer": "ipython3", + "nbconvert_exporter": "python", + "file_extension": ".py" + }, + "microsoft": { + "ms_spell_check": { + "ms_spell_check_language": "en" + }, + "host": { + "AzureML": { + "notebookHasBeenCompleted": true + } + } + }, + "kernel_info": { + "name": "python38-azureml" + }, + "nteract": { + "version": "nteract-front-end@1.0.0" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/examples/Dask/dask.job b/examples/Dask/dask.job new file mode 100644 index 0000000..878de0c --- /dev/null +++ b/examples/Dask/dask.job @@ -0,0 +1,7 @@ +#!/bin/bash + +conda init +source activate base +pip install dask==2023.2.0 distributed==2023.2.0 +export PATH=$PATH:/home/azureuser/.local/bin +dask worker tcp://10.0.1.5:12345