"project = \"cstvs\" # your project: zam, training19xx, etc."
"project = \"zam\" # your project: zam, training19xx, etc."
]
},
{
...
...
%% Cell type:markdown id: tags:
# Dask Extension
%% Cell type:markdown id: tags:
This notebook will give you a short introduction into the Dask Extension on JURECA. It allows you to run Jobs on the compute nodes, even if your JupyterLab is running interactively on the login node.
First you have to define on which project and partition it should be running.
%% Cell type:code id: tags:
``` python
queue="batch"# batch, gpus, develgpus, etc.
project="cstvs"# your project: zam, training19xx, etc.
project="zam"# your project: zam, training19xx, etc.
```
%% Cell type:markdown id: tags:
# Monte-Carlo Estimate of $\pi$
We want to estimate the number $\pi$ using a [Monte-Carlo method](https://en.wikipedia.org/wiki/Pi#Monte_Carlo_methods) exploiting that the area of a quarter circle of unit radius is $\pi/4$ and that hence the probability of any randomly chosen point in a unit square to lie in a unit circle centerd at a corner of the unit square is $\pi/4$ as well. So for N randomly chosen pairs $(x, y)$ with $x\in[0, 1)$ and $y\in[0, 1)$, we count the number $N_{circ}$ of pairs that also satisfy $(x^2 + y^2) < 1$ and estimage $\pi \approx 4 \cdot N_{circ} / N$.
We want each calculation to take only a few seconds. Dask will try to add more workers to the cluster when workloads are high and remove workers when idling.
_**Watch** how the cluster will scale down to the minimum a few seconds after being made adaptive._
%% Cell type:code id: tags:
``` python
ca=cluster.adapt(minimum=4,maximum=100)
sleep(4)# Allow for scale-down
```
%% Cell type:code id: tags:
``` python
client
```
%% Cell type:markdown id: tags:
## Repeat the calculation from above with larger work loads