{"id":685,"date":"2021-02-15T08:00:20","date_gmt":"2021-02-15T08:00:20","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/sustainable-software\/?p=685"},"modified":"2021-02-16T08:49:09","modified_gmt":"2021-02-16T08:49:09","slug":"how-can-i-calculate-co2eq-emissions-for-my-azure-vm","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/sustainable-software\/how-can-i-calculate-co2eq-emissions-for-my-azure-vm\/","title":{"rendered":"How Can I Calculate CO2eq emissions for my Azure VM?"},"content":{"rendered":"<p><span class=\"TextRun SCXW191217861 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW191217861 BCX8\">In this post we will look at two different Azure virtual machines, run software on them and calculate the CO2eq emissions of\u00a0<\/span><span class=\"NormalTextRun SCXW191217861 BCX8\">the\u00a0<\/span><span class=\"NormalTextRun SCXW191217861 BCX8\">software.\u00a0<\/span><span class=\"NormalTextRun SCXW191217861 BCX8\">In my\u00a0<\/span><span class=\"NormalTextRun SCXW191217861 BCX8\">previous<\/span><span class=\"NormalTextRun SCXW191217861 BCX8\">\u00a0posts I have written about how one can go about measuring the power consumption of a backend service.\u00a0<\/span><span class=\"NormalTextRun SCXW191217861 BCX8\">This post is about how<\/span><span class=\"NormalTextRun SCXW191217861 BCX8\">\u00a0<\/span><span class=\"NormalTextRun SCXW191217861 BCX8\">to put the tools to work.\u00a0<\/span><span class=\"NormalTextRun SCXW191217861 BCX8\">If you have not read my\u00a0<\/span><\/span><a class=\"Hyperlink SCXW191217861 BCX8\" href=\"https:\/\/devblogs.microsoft.com\/sustainable-software\/how-to-measure-the-power-consumption-of-your-backend-service\/?WT.mc_id=-green-8647-cxa\" target=\"_blank\" rel=\"noreferrer noopener\"><span class=\"TextRun Underlined SCXW191217861 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW191217861 BCX8\" data-ccp-charstyle=\"Hyperlink\">previous<\/span><span class=\"NormalTextRun SCXW191217861 BCX8\" data-ccp-charstyle=\"Hyperlink\">\u00a0post<\/span><span class=\"NormalTextRun SCXW191217861 BCX8\" data-ccp-charstyle=\"Hyperlink\">\u00a0on power consumption<\/span><\/span><\/a><span class=\"TextRun SCXW191217861 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW191217861 BCX8\">, I recommend going there and then coming back to this post, as we will extend the concepts presented there<\/span><span class=\"NormalTextRun SCXW191217861 BCX8\">! <\/span><span class=\"NormalTextRun SCXW191217861 BCX8\">Let\u2019s<\/span><span class=\"NormalTextRun SCXW191217861 BCX8\">\u00a0go!<\/span><\/span><span class=\"EOP SCXW191217861 BCX8\" data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<h2><span class=\"TextRun SCXW226329122 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW226329122 BCX8\" data-ccp-parastyle=\"heading 1\">Power Consumption<\/span><\/span><span class=\"EOP SCXW226329122 BCX8\" data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:240,&quot;335559739&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h2>\n<p><span class=\"TextRun BCX8 SCXW134195721\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun BCX8 SCXW134195721\">We will use this formula for calculating power consumption:<\/span><\/span><span class=\"EOP BCX8 SCXW134195721\" data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/sustainable-software\/wp-content\/uploads\/sites\/60\/2020\/09\/Sara-Formula-Illustration-1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-220\" src=\"https:\/\/devblogs.microsoft.com\/sustainable-software\/wp-content\/uploads\/sites\/60\/2020\/09\/Sara-Formula-Illustration-1.png\" alt=\"A mathematical formula. Power, in kilowatt, equals the number of CPUs times the Power consumption of the CPU plus the power consumption of the memory + the number of GPUs times the power consumption of GPUs and divide it all by 1000.\" width=\"1958\" height=\"1251\" srcset=\"https:\/\/devblogs.microsoft.com\/sustainable-software\/wp-content\/uploads\/sites\/60\/2020\/09\/Sara-Formula-Illustration-1.png 1958w, https:\/\/devblogs.microsoft.com\/sustainable-software\/wp-content\/uploads\/sites\/60\/2020\/09\/Sara-Formula-Illustration-1-300x192.png 300w, https:\/\/devblogs.microsoft.com\/sustainable-software\/wp-content\/uploads\/sites\/60\/2020\/09\/Sara-Formula-Illustration-1-1024x654.png 1024w, https:\/\/devblogs.microsoft.com\/sustainable-software\/wp-content\/uploads\/sites\/60\/2020\/09\/Sara-Formula-Illustration-1-768x491.png 768w, https:\/\/devblogs.microsoft.com\/sustainable-software\/wp-content\/uploads\/sites\/60\/2020\/09\/Sara-Formula-Illustration-1-1536x981.png 1536w\" sizes=\"(max-width: 1958px) 100vw, 1958px\" \/><\/a><\/p>\n<p><span data-contrast=\"auto\">P will be the overall power in kW and P[kW]=(c\u2219P_c+ P_r+g\u2219P_g)\/1000. Where P_c the power consumption of the CPU, P_g is the power consumption of the GPU and P_r is the power consumption of the memory. I will be using the thermal design power (TDP) of the hardware components to estimate the power consumption. Remember that this is an estimate and measuring the exact power consumption directly is more accurate, but not always available to us.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\"> If you wish to get the kWh, multiply the power consumption P = (c\u2219P_c+ P_r+g\u2219P_g)\/1000 by the amount of hours you are interested in. Example for a 4 hour time period the energy consumption in kWh can be expressed as E[kWh]=4*(c\u2219P_c+ P_r+g\u2219P_g)\/1000.<\/span><\/p>\n<p><span data-contrast=\"auto\">To make the example easier, we will pretend to run software and use fake loads on the various components. The same method can be applied to real software. You can measure the load of different components, for example, by using\u00a0<\/span><a href=\"https:\/\/devblogs.microsoft.com\/sustainable-software\/measuring-your-application-power-and-carbon-impact-part-1\/\"><span data-contrast=\"none\">this method for measuring power consumption<\/span><\/a><span data-contrast=\"none\">,<\/span><span data-contrast=\"auto\">\u00a0presented by my\u00a0colleague\u00a0Scott\u00a0Chamberlin.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<h2><span class=\"TextRun SCXW135088827 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW135088827 BCX8\" data-ccp-parastyle=\"heading 2\">Example 1 \u2013 A General Purpose Machine<\/span><\/span><span class=\"EOP SCXW135088827 BCX8\" data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:40,&quot;335559739&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h2>\n<p><span data-contrast=\"auto\">For\u00a0the\u00a0first example,\u00a0I\u00a0chose a\u00a0general-purpose\u00a0machine for Azure, which would be suitable for\u00a0small\u00a0to medium\u00a0sized\u00a0business applications.\u00a0I\u00a0picked\u00a0Standard_D2s_v3 from\u00a0<\/span><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/virtual-machines\/dv3-dsv3-series\"><span data-contrast=\"none\">the Dsv3\u00a0series<\/span><\/a><span data-contrast=\"none\">,<\/span><span data-contrast=\"auto\">\u00a0which uses\u00a0an Intel Xeon Platinum 8171M (Skylake)\u00a0CPU\u00a0that\u00a0has a\u00a0<\/span><a href=\"https:\/\/ark.intel.com\/content\/www\/us\/en\/ark\/compare.html?productIds=120507\"><span data-contrast=\"none\">TDP of\u00a0165\u00a0W<\/span><\/a><span data-contrast=\"auto\">\u00a0and 2 vCPU cores.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Since there is no GPU, P_g will be 0. The memory energy consumption is much smaller than the CPU consumption, which essentially means P &gt;= (2*P_c).<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Let\u2019s\u00a0assume the following load on the CPU for a 24-hour period:<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<table style=\"font-weight: 400; width: 57.4176%;\" data-tablestyle=\"MsoTableGrid\" data-tablelook=\"1696\">\n<tbody>\n<tr>\n<td style=\"width: 38.277%;\" data-celllook=\"0\"><span data-contrast=\"auto\">Time<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.1418%;\" data-celllook=\"0\"><span data-contrast=\"auto\">00.00-04.00<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.1418%;\" data-celllook=\"0\"><span data-contrast=\"auto\">04.00-08.00<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.2508%;\" data-celllook=\"0\"><span data-contrast=\"auto\">08.00-12.00<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.4711%;\" data-celllook=\"0\"><span data-contrast=\"auto\">12.00-16.00<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.0306%;\" data-celllook=\"0\"><span data-contrast=\"auto\">16.00-20.00<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.2508%;\" data-celllook=\"0\"><span data-contrast=\"auto\">20.00-00.00<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 38.277%;\" data-celllook=\"0\"><span data-contrast=\"auto\">P_g<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.1418%;\" data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.1418%;\" data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.2508%;\" data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.4711%;\" data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.0306%;\" data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.2508%;\" data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 38.277%;\" data-celllook=\"0\"><span data-contrast=\"auto\">P_r<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.1418%;\" data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.1418%;\" data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.2508%;\" data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.4711%;\" data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.0306%;\" data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.2508%;\" data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 38.277%;\" data-celllook=\"0\"><span data-contrast=\"auto\">TDP of CPU\u00a0[W]<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.1418%;\" data-celllook=\"0\"><span data-contrast=\"auto\">165<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.1418%;\" data-celllook=\"0\"><span data-contrast=\"auto\">165<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.2508%;\" data-celllook=\"0\"><span data-contrast=\"auto\">165<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.4711%;\" data-celllook=\"0\"><span data-contrast=\"auto\">165<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.0306%;\" data-celllook=\"0\"><span data-contrast=\"auto\">165<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.2508%;\" data-celllook=\"0\"><span data-contrast=\"auto\">165<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 38.277%;\" data-celllook=\"0\"><span data-contrast=\"auto\">Load of CPU\u00a0[%]<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.1418%;\" data-celllook=\"0\"><span data-contrast=\"auto\">30%<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.1418%;\" data-celllook=\"0\"><span data-contrast=\"auto\">50%<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.2508%;\" data-celllook=\"0\"><span data-contrast=\"auto\">80%<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.4711%;\" data-celllook=\"0\"><span data-contrast=\"auto\">90%<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.0306%;\" data-celllook=\"0\"><span data-contrast=\"auto\">50%<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.2508%;\" data-celllook=\"0\"><span data-contrast=\"auto\">30%<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 38.277%;\" data-celllook=\"0\"><span data-contrast=\"auto\">E1 = P_c * hours = (2 * TDP * load * hours)\/1000\n[kWh]<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.1418%;\" data-celllook=\"0\"><span data-contrast=\"auto\">0.369<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.1418%;\" data-celllook=\"0\"><span data-contrast=\"auto\">0.66<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.2508%;\" data-celllook=\"0\"><span data-contrast=\"auto\">1.056<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.4711%;\" data-celllook=\"0\"><span data-contrast=\"auto\">1.188<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.0306%;\" data-celllook=\"0\"><span data-contrast=\"auto\">0.66<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td style=\"width: 10.2508%;\" data-celllook=\"0\"><span data-contrast=\"auto\">0.369<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span data-contrast=\"auto\">This means we get:<\/span><strong> E<\/strong><b><span data-contrast=\"auto\">1\u00a0=\u00a04.302\u00a0kWh\u00a0for a\u00a024-hour\u00a0period.\u00a0<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">This is a measure of how much energy is consumed by\u00a0the\u00a0software over this\u00a0specific\u00a0time period.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<h2><span class=\"TextRun BCX8 SCXW118523250\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun BCX8 SCXW118523250\" data-ccp-parastyle=\"heading 2\">Example 2 \u2013 A Machine for GPU Intense Workloads<\/span><\/span><span class=\"EOP BCX8 SCXW118523250\" data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:40,&quot;335559739&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h2>\n<p><span data-contrast=\"auto\">For\u00a0the\u00a0second example,\u00a0let us consider a VM\u00a0that\u00a0would be more suitable for a GPU intense workload, like a machine learning application or experimentation.\u00a0I\u00a0picked\u00a0the Standard_NC6s_v3 from\u00a0<\/span><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/virtual-machines\/ncv3-series\"><span data-contrast=\"none\">the NCv3 series<\/span><\/a><span data-contrast=\"auto\">. This VM is powered by NVIDIA Tesla V100 GPUs that has a <\/span><a href=\"https:\/\/images.nvidia.com\/content\/tesla\/pdf\/Tesla-V100-PCIe-Product-Brief.pdf\"><span data-contrast=\"none\">TDP of\u00a0250\u00a0W<\/span><\/a><span data-contrast=\"auto\">.\u00a0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">For this\u00a0VM type there\u00a0are\u00a0no CPU cores initially, which\u00a0yields\u00a0P_c\u00a0= 0 and once again,\u00a0the memory\u00a0energy\u00a0consumption is much smaller than the GPU consumption, which\u00a0essentially means\u00a0P &gt;= P_g.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Let\u2019s\u00a0assume the following load on the GPU\u00a0for\u00a0a 24-hour period:<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<table data-tablestyle=\"MsoTableGrid\" data-tablelook=\"1696\">\n<tbody>\n<tr>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">Time<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">00.00-04.00<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">04.00-08.00<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">08.00-12.00<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">12.00-16.00<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">16.00-20.00<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">20.00-00.00<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">P_c<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">P_r<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">TDP of\u00a0GPU\u00a0[W]<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">250<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">250<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335551550&quot;:1,&quot;335551620&quot;:1,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">250<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335551550&quot;:1,&quot;335551620&quot;:1,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">250<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335551550&quot;:1,&quot;335551620&quot;:1,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">250<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335551550&quot;:1,&quot;335551620&quot;:1,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">250<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335551550&quot;:1,&quot;335551620&quot;:1,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">Load of\u00a0GPU\u00a0[%]<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">30%<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">50%<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">80%<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">90%<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">50%<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">30%<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">E2 = P_g * hours = (1 * TDP * load * hours)\/1000\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">[kWh]<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">0.3<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">0.5<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">0.8<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">0.9<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335551550&quot;:1,&quot;335551620&quot;:1,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">0.5<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<td data-celllook=\"0\"><span data-contrast=\"auto\">0.3<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span data-contrast=\"auto\">This means we get:<\/span> <b><span data-contrast=\"auto\">E2<\/span><\/b><span data-contrast=\"auto\">\u00a0<\/span><b><span data-contrast=\"auto\">=\u00a03.3\u00a0kWh for a 24-hour period.<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<h2 aria-level=\"2\"><span data-contrast=\"none\">What about cooling?<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:40,&quot;335559739&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h2>\n<p><span data-contrast=\"auto\">Now you may wonder, what about the cooling of a data center? For this example, we can assume that all data centers have a Power Usage Effectiveness (PUE) value. The PUE is a ratio that determines how effective a datacenter is at utilizing its energy. For example, a PUE of 2.0 means for every 1 kWh of electricity that reached the server, the data center needs 2 kWh to account for waste and other services like cooling. In 2015, Microsoft\u2019s average PUE for its new datacenters was 1.125 so that is the number we use, even though it may not be 100% accurate. This number changes slowly over time with new improvements to data center design, so you can generally consider it constant when measuring power consumption over time.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">To adjust the power consumption based on the PUE we need to multiply E1 and E2 with the PUE. Our new E1 is then 4.83975 kWh and our new E2 is then 3.7125 kWh.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<h1 aria-level=\"1\"><span data-contrast=\"none\">Going from\u00a0kWh\u00a0to CO2eq<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:240,&quot;335559739&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h2>\n<p><span data-contrast=\"auto\">Now we know the amount of energy our software consumes! Next, we need to multiply the amount of energy by the carbon intensity, which is a measure of the grams of CO2eq emitted per kWh. Azure has been carbon neutral since 2012, meaning the emissions are offset, which is great for our customers, but not a very fun example when calculating. To make this an end-to-end example let\u2019s take the general energy mix of the region in question as our carbon intensity. I\u2019m living in Norway, so I\u2019ll assume we are using the Azure region Norway East. According to <a href=\"https:\/\/www.electricitymap.org\/map\">electricitymap.org<\/a>, which uses EU data, the carbon intensity is approximately 30 grams per kWh right now. Choosing Norway also makes our math easier as the carbon intensity is fairly constant over the day thanks to the use of hydropower.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/sustainable-software\/wp-content\/uploads\/sites\/60\/2020\/11\/001.SiteMapElectGreen.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-484\" src=\"https:\/\/devblogs.microsoft.com\/sustainable-software\/wp-content\/uploads\/sites\/60\/2020\/11\/001.SiteMapElectGreen.png\" alt=\"Electricity Map is ranking countries by carbon intensity of electricity consumed (gCO\u2082eq\/kWh)\" width=\"1344\" height=\"798\" srcset=\"https:\/\/devblogs.microsoft.com\/sustainable-software\/wp-content\/uploads\/sites\/60\/2020\/11\/001.SiteMapElectGreen.png 1344w, https:\/\/devblogs.microsoft.com\/sustainable-software\/wp-content\/uploads\/sites\/60\/2020\/11\/001.SiteMapElectGreen-300x178.png 300w, https:\/\/devblogs.microsoft.com\/sustainable-software\/wp-content\/uploads\/sites\/60\/2020\/11\/001.SiteMapElectGreen-1024x608.png 1024w, https:\/\/devblogs.microsoft.com\/sustainable-software\/wp-content\/uploads\/sites\/60\/2020\/11\/001.SiteMapElectGreen-768x456.png 768w\" sizes=\"(max-width: 1344px) 100vw, 1344px\" \/><\/a><\/p>\n<p><span data-contrast=\"auto\">Multiplying E1 = 4. 83975 kWh with 30 grams\/kWh gives a total of 145.1925 grams of CO2eq emissions for our general-purpose machine over a 24-hour period. For our GPU intense machine, we multiply E2 = 3.7125 kWh with 30 grams\/kWh to get 111.375 grams of CO2eq emissions over the same 24-hour period. This is roughly the same as driving Tesla model 3 for 22 km, according to their <\/span><a href=\"https:\/\/www.tesla.com\/charging\"><span data-contrast=\"none\">charging estimator<\/span><\/a><span data-contrast=\"auto\">.\u00a0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<h1 aria-level=\"1\">Take Action<\/h2>\n<p><span data-contrast=\"auto\">When running on serverless,\u00a0there are sustainability gains to be had,\u00a0which\u00a0I have\u00a0not covered in this post.\u00a0Read this blog post\u00a0about\u00a0<\/span><a href=\"https:\/\/aka.ms\/sse\/azure-serverless-architecture\"><span data-contrast=\"none\">adopting a serverless architecture to help reduce CO2 emissions<\/span><\/a><span data-contrast=\"auto\">\u00a0by\u00a0my\u00a0colleague\u00a0Srinivasan\u00a0to learn more.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The second principle of Sustainable Software Engineering is to build energy efficient applications. The very first step in that direction is to measure the energy cost of your application. In this post we will look at two different Azure virtual machines, run software on them and calculate the CO2eq emissions of\u00a0the\u00a0software.\u00a0<\/p>\n","protected":false},"author":37028,"featured_media":220,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[76,71,22],"tags":[75,50,68,70,24],"class_list":["post-685","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-datacentres","category-measurement","category-sustainable-software-engineering","tag-azure","tag-cloud-computing","tag-electricity","tag-power-measurement","tag-sse"],"acf":[],"blog_post_summary":"<p>The second principle of Sustainable Software Engineering is to build energy efficient applications. The very first step in that direction is to measure the energy cost of your application. In this post we will look at two different Azure virtual machines, run software on them and calculate the CO2eq emissions of\u00a0the\u00a0software.\u00a0<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/sustainable-software\/wp-json\/wp\/v2\/posts\/685","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/sustainable-software\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/sustainable-software\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/sustainable-software\/wp-json\/wp\/v2\/users\/37028"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/sustainable-software\/wp-json\/wp\/v2\/comments?post=685"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/sustainable-software\/wp-json\/wp\/v2\/posts\/685\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/sustainable-software\/wp-json\/wp\/v2\/media\/220"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/sustainable-software\/wp-json\/wp\/v2\/media?parent=685"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/sustainable-software\/wp-json\/wp\/v2\/categories?post=685"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/sustainable-software\/wp-json\/wp\/v2\/tags?post=685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}