diff --git a/lectures/2.4_formats_and_performance/exercises/24_formats_and_performance.ipynb b/lectures/2.4_formats_and_performance/exercises/24_formats_and_performance.ipynb
index 1cf6a21f..035b51f0 100644
--- a/lectures/2.4_formats_and_performance/exercises/24_formats_and_performance.ipynb
+++ b/lectures/2.4_formats_and_performance/exercises/24_formats_and_performance.ipynb
@@ -40,7 +40,7 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": 2,
"metadata": {},
"outputs": [
{
@@ -76,14 +76,14 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[codecarbon INFO @ 09:19:47] offline tracker init\n"
+ "[codecarbon INFO @ 11:20:05] offline tracker init\n"
]
}
],
@@ -93,7 +93,6 @@
" log_level=\"error\",\n",
" save_to_file=True,\n",
" output_dir=\"./\",\n",
- " default_cpu_power=21 # TODO: Set the correct value\n",
")"
]
},
@@ -112,7 +111,7 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 4,
"metadata": {},
"outputs": [
{
@@ -177,19 +176,19 @@
" \n",
"
\n",
"
![\"LED](\"../assets/lightbulb.svg\")
\n",
- "
LED Bulb Runtime:
0.38 seconds
\n",
+ "
LED Bulb Runtime:
0.15 seconds
\n",
"
\n",
- " This energy is equivalent to powering a standard 10W LED bulb for 0.38 seconds .\n",
+ " This energy is equivalent to powering a standard 10W LED bulb for 0.15 seconds .\n",
" \n",
"
\n",
" \n",
" \n",
" \n",
"
![\"Smartwatch\"](\"../assets/smartwatch.svg\")
\n",
- "
Smartwatch Runtime idle use:
1.06 minutes
\n",
- "
Smartwatch Runtime normal use:
7.66 seconds
\n",
+ "
Smartwatch Runtime idle use:
24.50 seconds
\n",
+ "
Smartwatch Runtime normal use:
2.94 seconds
\n",
"
\n",
- " The amount of energy used to run the code could power a smartwatch for 1.06 minutes in idle mode and for 7.66 seconds in regular use mode .\n",
+ " The amount of energy used to run the code could power a smartwatch for 24.50 seconds in idle mode and for 2.94 seconds in regular use mode .\n",
" \n",
"
\n",
" \n",
@@ -206,7 +205,7 @@
" text-align: center;\n",
" box-sizing: border-box;\n",
" position: relative;\n",
- " border: 2px solid transparent; /* Initial border */\n",
+ " border: 2px solid transparent;\n",
" transition: border-color 0.3s;\n",
" }\n",
" .item img {\n",
@@ -253,9 +252,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 7,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Starting experiment: 2\n",
+ "Stopped experiment: 2\n"
+ ]
+ }
+ ],
"source": [
"tracker.start_experiment(experiment_id=2)\n",
"\n",
@@ -290,9 +298,103 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 8,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ " \n",
+ " \n",
+ " Emission Equivalents for Latest Run\n",
+ " \n",
+ " \n",
+ " Emission Equivalents for Latest Run
\n",
+ " \n",
+ " \n",
+ "
\n",
+ "
![\"Mars](\"../assets/marsrover.svg\")
\n",
+ "
Mars Rover Perseverance distance:
0.18 Meters
\n",
+ "
\n",
+ " This is equivalent to the amount of energy required to move the Perseverance rover 0.18 meters.\n",
+ " \n",
+ "
\n",
+ " \n",
+ " \n",
+ "
\n",
+ "
![\"LED](\"../assets/lightbulb.svg\")
\n",
+ "
LED Bulb Runtime:
1.29 minutes
\n",
+ "
\n",
+ " This energy is equivalent to powering a standard 10W LED bulb for 1.29 minutes .\n",
+ " \n",
+ "
\n",
+ " \n",
+ " \n",
+ "
\n",
+ "
![\"Smartwatch\"](\"../assets/smartwatch.svg\")
\n",
+ "
Smartwatch Runtime idle use:
3.57 hours
\n",
+ "
Smartwatch Runtime normal use:
25.72 minutes
\n",
+ "
\n",
+ " The amount of energy used to run the code could power a smartwatch for 3.57 hours in idle mode and for 25.72 minutes in regular use mode .\n",
+ " \n",
+ "
\n",
+ "
\n",
+ " \n",
+ " \n",
+ "\n"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"calculate_emission_equivalents(experiment_id=2)"
]
@@ -319,9 +421,32 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 9,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Starting experiment: 3\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "/home/jzvolensky/miniconda3/envs/cubes-and-clouds/lib/python3.11/site-packages/xarray/core/groupby.py:508: FutureWarning: 'M' is deprecated and will be removed in a future version, please use 'ME' instead.\n",
+ " index_grouper = pd.Grouper(\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Stopped experiment: 3\n"
+ ]
+ }
+ ],
"source": [
"tracker.start_experiment(experiment_id=3)\n",
"\n",
@@ -351,9 +476,103 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 10,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ " \n",
+ " \n",
+ " Emission Equivalents for Latest Run\n",
+ " \n",
+ " \n",
+ " Emission Equivalents for Latest Run
\n",
+ " \n",
+ " \n",
+ "
\n",
+ "
![\"Mars](\"../assets/marsrover.svg\")
\n",
+ "
Mars Rover Perseverance distance:
1.67 Meters
\n",
+ "
\n",
+ " This is equivalent to the amount of energy required to move the Perseverance rover 1.67 meters.\n",
+ " \n",
+ "
\n",
+ " \n",
+ " \n",
+ "
\n",
+ "
![\"LED](\"../assets/lightbulb.svg\")
\n",
+ "
LED Bulb Runtime:
11.63 minutes
\n",
+ "
\n",
+ " This energy is equivalent to powering a standard 10W LED bulb for 11.63 minutes .\n",
+ " \n",
+ "
\n",
+ " \n",
+ " \n",
+ "
\n",
+ "
![\"Smartwatch\"](\"../assets/smartwatch.svg\")
\n",
+ "
Smartwatch Runtime idle use:
32.29 hours
\n",
+ "
Smartwatch Runtime normal use:
3.88 hours
\n",
+ "
\n",
+ " The amount of energy used to run the code could power a smartwatch for 32.29 hours in idle mode and for 3.88 hours in regular use mode .\n",
+ " \n",
+ "
\n",
+ "
\n",
+ " \n",
+ " \n",
+ "\n"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"calculate_emission_equivalents(experiment_id=3)"
]
diff --git a/lectures/2.4_formats_and_performance/exercises/codecarbon_utils.py b/lectures/2.4_formats_and_performance/exercises/codecarbon_utils.py
index 07251025..84547b90 100644
--- a/lectures/2.4_formats_and_performance/exercises/codecarbon_utils.py
+++ b/lectures/2.4_formats_and_performance/exercises/codecarbon_utils.py
@@ -38,6 +38,11 @@ class CustomEmissionsTracker(OfflineEmissionsTracker):
"""
def __init__(self, *args, **kwargs):
+
+ lock_file="/tmp/.codecarbon.lock"
+ if os.path.exists(lock_file):
+ os.remove(lock_file)
+ carbon_logger.debug("Removed lock file to prevent double tracker instances.")
super().__init__(*args, **kwargs)
self.current_experiment_id = None
self.emissions_file = os.path.join(