Submitted:
31 May 2024
Posted:
31 May 2024
You are already at the latest version
Abstract
Keywords:
1. Introduction
- Comparative Analysis of ML Development Libraries: We have provided an extensive comparative analysis between high-level and low-level programming libraries for developing ML models, catering to a range of IoT machine learning tasks. This analysis leverages two distinct datasets, each aligned with a common IoT ML image classification objective.
- Green Carbon Footprint Calculation Algorithm: A novel algorithm has been introduced to calculate the carbon footprint associated with the execution of ML training codes. This algorithm incorporates a comprehensive set of parameters, including execution time, memory utilization, power consumption, and CPU temperature.
- Decision Support System: Based on the exhaustive experimental findings, a decision support system has been synthesized, presenting key insights and recommendations for developers. This system aids in navigating the complex landscape of IoT-ML integration, highlighting optimal development approaches that balance performance, hardware compatibility, and environmental sustainability.
2. Literature Review
3. Methodology
3.1. Selection of Dataset and Model
3.1.1. Convolutional Neural Network
3.2. Selection of Programming Libraries
3.3. Measuring Green Carbon Footprint
| Algorithm 1 Calculate Carbon Footprint |
|
3.3.1. Mathematical Representation
- P = Power consumption (in kW)
- T = Execution time (in hours)
- = Power to Carbon Conversion Factor
- M = Memory utilization (in kB)
- = Memory to Carbon Conversion Factor
- = Temperature Cost, a function of CPU temperature
3.4. Experimental Setup
3.5. Evaluation Metrics
- Accuracy: Defined as the ratio of correctly predicted observations to the total observations.
- Precision: The ratio of correctly predicted positive observations to the total predicted positive observations. It reflects the model’s ability to return relevant results.
- Recall (Sensitivity): The ratio of correctly predicted positive observations to the all observations in actual class - yes. It measures the model’s capability to find all relevant cases.
- F1 Score: The harmonic mean of Precision and Recall. This score takes both false positives and false negatives into account, making it a better measure of the incorrectly classified cases than the Accuracy metric alone.
- Execution Time: Measures the total time taken by the machine learning model to complete its training process. A shorter execution time is generally preferable, indicating an efficient model capable of learning quickly, which is crucial in time-sensitive or resource-limited environments. In Python, the execution time can be accurately measured using the time library.
- Memory Utilization: Reflects the amount of memory required by the machine learning models during their execution. Effective memory management is critical, especially in environments with limited memory resources such as IoT devices. The command line utility free is used to monitor and optimize memory consumption during model training.
- Power Consumption: Indicates the electrical power used by the computing device while running the machine learning model. Energy efficiency is paramount in scenarios where power availability is constrained, such as mobile or embedded systems. Power consumption is typically measured using a USB power meter or multimeter to track the voltage and current draw of a device, like a Raspberry Pi, thus allowing calculation of power usage in watts. Power draw can be estimated using powertop. The command also logs CPU usage.
- CPU Temperature: Monitoring CPU temperature is essential for maintaining system stability and efficiency. High temperatures may suggest excessive computational demand or inadequate cooling, potentially leading to hardware throttling or failure. Temperature can be tracked using the vcgencmd utility on the device, which allows real-time temperature monitoring. This will allow us critical data for managing thermal conditions during intensive computational tasks.
3.6. Decision Support System Framework
- Raw Data Collection: Gathering unprocessed data from various sources relevant to the application domain.
- Data Transformation: Applying transformations to the raw data to convert it into a more manageable or suitable format for analysis.
- Data Normalization: Normalizing data to ensure that the model is not biased towards variables with larger scales.
- Data Cleaning: Removing or correcting data anomalies, missing values, and outliers to improve data quality.
- Data Compression: Reducing the size of the data through various compression techniques to enhance storage efficiency and speed up processing.
- Feeding Data to Model: Inputting the processed data into the machine learning model for training.
- Model Deployment: Deploying the trained model into a real-world environment where it can provide insights or make decisions based on new data.
4. Result Analysis
4.1. Training on FashionMNIST
4.2. Training on MNIST dataset
4.3. Validation of the Green Carbon Footprint Algorithm
4.3.1. Determining Conversion Factors
- Power to Carbon Conversion Factor (PGCF): This factor converts the energy consumed (in kWh) by the system into grams of CO2 equivalent. It is influenced by the regional energy mix and the efficiency of the power supply. To establish this factor, data from local utility companies and renewable energy contributions are considered.
- Memory to Carbon Conversion Factor (MGCF): Memory utilization is converted to carbon emissions based on the energy cost of memory operations and the production impact of the memory hardware. This factor accounts for the embodied carbon of producing and maintaining memory hardware, amortized over its operational lifespan.
- Temperature Cost Conversion: The CPU temperature directly affects the system’s energy efficiency and cooling requirements. A higher temperature indicates more energy-intensive cooling, translating to higher emissions. A mathematical model is developed to relate CPU temperature to carbon output, using empirical data from thermal performance studies.
4.3.2. Empirical Validation and Adjustments
- Iterative Adjustments: The initial results are compared against independently verified benchmarks of carbon emissions for similar operations [29]. Discrepancies lead to iterative adjustments in the conversion factors. This iterative process continues until the calculated carbon emissions align closely with the benchmark data, ensuring accuracy and reliability.
- Algorithm Sensitivity Analysis: Sensitivity analysis is also performed to understand how changes in each factor affect the overall carbon footprint. This analysis helps prioritize adjustments in the conversion factors to minimize errors in the footprint estimation.
4.3.3. Finalization and Implementation
5. Case Studies
- PyTorch Model Size:
- LibTorch Model Size:
5.1. Case Study 1: FashionMNIST with PyTorch
5.1.1. Temperature Cost Calculation
5.1.2. Factor Adjustment
5.1.3. GCF Calculation
5.2. Case Study 2: FashionMNIST with LibTorch
6. Limitations and Future Works
7. Conclusion
Acknowledgments
References
- Rysak, P. Comparative analysis of code execution time by C and Python based on selected algorithms. Journal of Computer Sciences Institute 2023, 26, 93–99. [CrossRef]
- Salihu, B.; Tafa, Z. On Computational Performances of the Actual Image Classification Methods in C# and Python. 2020 9th Mediterranean Conference on Embedded Computing (MECO). IEEE, 2020, pp. 1–5.
- de la Fraga, L.G.; Tlelo-Cuautle, E.; Azucena, A.D.P. On the execution time of a computational intensive application in scripting languages. 2017 5th International Conference in Software Engineering Research and Innovation (CONISOFT). IEEE, 2017, pp. 149–152.
- Zehra, F.; Javed, M.; Khan, D.; Pasha, M. Comparative Analysis of C++ and Python in Terms of Memory and Time. 2020. Preprints.[Google Scholar] 2020.
- Prechelt, L. An empirical comparison of c, c++, java, perl, python, rexx and tcl. IEEE Computer 2000, 33, 23–29. [CrossRef]
- Georgiou, S.; Kechagia, M.; Spinellis, D. Analyzing programming languages’ energy consumption: An empirical study. Proceedings of the 21st Pan-Hellenic Conference on Informatics, 2017, pp. 1–6.
- Onyango, K.A.; Mariga, G.W. Comparative Analysis on the Evaluation of the Complexity of C, C++, Java, PHP and Python Programming Languages based on Halstead Software Science 2023.
- Mengistu, D.; Frisk, F. Edge machine learning for energy efficiency of resource constrained IoT devices. SPWID 2019: The Fifth International Conference on Smart Portable, Wearable, Implantable and Disabilityoriented Devices and Systems, 2019, pp. 9–14.
- Lu, Q.; Murmann, B. Enhancing the energy efficiency and robustness of TinyML computer vision using coarsely-quantized log-gradient input images. ACM Transactions on Embedded Computing Systems 2023. [CrossRef]
- Blum, R.; Bresnahan, C. Python Programming for Raspberry Pi.
- Kesrouani, K.; Kanso, H.; Noureddine, A. A preliminary study of the energy impact of software in raspberry pi devices. 2020 IEEE 29th International Conference on Enabling Technologies: Infrastructure for Collaborative Enterprises (WETICE). IEEE, 2020, pp. 231–234.
- Ghael, H.D.; Solanki, L.; Sahu, G. A review paper on raspberry pi and its applications. International Journal of Advances in Engineering and Management (IJAEM) 2020, 2, 4.
- Corral-García, J.; González-Sánchez, J.L.; Pérez-Toledano, M.Á. Evaluation of strategies for the development of efficient code for Raspberry Pi devices. Sensors 2018, 18, 4066. [CrossRef]
- Abdulkareem, S.A.; Abboud, A.J. Evaluating python, c++, javascript and java programming languages based on software complexity calculator (halstead metrics). IOP Conference Series: Materials Science and Engineering. IOP Publishing, 2021, Vol. 1076, p. 012046.
- Plauska, I.; Liutkevičius, A.; Janavičiūtė, A. Performance evaluation of c/c++, micropython, rust and tinygo programming languages on esp32 microcontroller. Electronics 2022, 12, 143. [CrossRef]
- Besimi, N.; Çiço, B.; Besimi, A.; Shehu, V. Using distributed raspberry PIs to enable low-cost energy-efficient machine learning algorithms for scientific articles recommendation. Microprocessors and Microsystems 2020, 78, 103252. [CrossRef]
- Lannelongue, L.; Grealey, J.; Inouye, M. Green algorithms: quantifying the carbon footprint of computation. Advanced science 2021, 8, 2100707. [CrossRef]
- Herelius, S. Green coding: Can we make our carbon footprint smaller through coding?, 2022.
- Pandey, D.; Agrawal, M.; Pandey, J.S. Carbon footprint: current methods of estimation. Environmental monitoring and assessment 2011, 178, 135–160. [CrossRef]
- Vieira, G.; Barbosa, J.; Leitão, P.; Sakurada, L. Low-cost industrial controller based on the raspberry pi platform. 2020 IEEE international conference on industrial technology (ICIT). IEEE, 2020, pp. 292–297.
- Abdulsalam, S.; Lakomski, D.; Gu, Q.; Jin, T.; Zong, Z. Program energy efficiency: The impact of language, compiler and implementation choices. International Green Computing Conference. IEEE, 2014, pp. 1–6.
- Shoaib, M.; Venkataramani, S.; Hua, X.S.; Liu, J.; Li, J. Exploiting on-device image classification for energy efficiency in ambient-aware systems. Mobile Cloud Visual Media Computing: From Interaction to Service 2015, pp. 167–199.
- Benavente-Peces, C.; Ibadah, N. Buildings energy efficiency analysis and classification using various machine learning technique classifiers. Energies 2020, 13, 3497. [CrossRef]
- Mehmood, M.U.; Chun, D.; Han, H.; Jeon, G.; Chen, K.; others. A review of the applications of artificial intelligence and big data to buildings for energy-efficiency and a comfortable indoor living environment. Energy and Buildings 2019, 202, 109383. [CrossRef]
- Zhang, X.; Wang, Y.; Shi, W. {pCAMP}: Performance Comparison of Machine Learning Packages on the Edges. USENIX workshop on hot topics in edge computing (HotEdge 18), 2018.
- Oliveira, L.P.; Santos, J.H.d.S.; de Almeida, E.L.; Barbosa, J.R.; da Silva, A.W.; de Azevedo, L.P.; da Silva, M.V. Deep learning library performance analysis on raspberry (IoT device). International Conference on Advanced Information Networking and Applications. Springer, 2021, pp. 383–392.
- Foundation, G.S. Software Carbon Intensity Standard, 2021.
- Climate Transparency Report 2022, 2022.
- Dodge, J.; Prewitt, T.; Tachet des Combes, R.; Odmark, E.; Schwartz, R.; Strubell, E.; Luccioni, A.S.; Smith, N.A.; DeCario, N.; Buchanan, W. Measuring the carbon intensity of ai in cloud instances. Proceedings of the 2022 ACM conference on fairness, accountability, and transparency, 2022, pp. 1877–1894.






| Reference | Key Findings or Features | Identified Gaps and Our Contributions |
|---|---|---|
| Shoaib et al. [22] | Introduced a lightweight ML model for image classification and an optimized hardware engine for IoT devices. | Limited to image processing tasks using one library. Our work extends to use low-level library, offering a more holistic IoT solution. |
| Benavente-Peces et al.[23] | Analyzed power consumption for ML models in cloud environments. | Did not consider on-device execution. We have provided an in-depth analysis of on-device power consumption and its environmental impact. |
| Mehmood et al. [24] | Developed a decision support system for selecting ML models based on performance. | Overlooked environmental sustainability. Our system includes an environmental impact assessment, guiding towards more sustainable ML development. |
| Zhang et al. [25] | Compared and analysed the deployment of two trained model architechture using five ML libraries in multiple types of devices | Only trained models were loaded in the device. We train the model in the device. |
| Oliveira et al. [26] | Compared two commonly used deep learning library in Raspberry Pi by considering resource usage and energy consumption. | Limited to only high-level language library. Low-level libraries for deep learning is assessed in our study. |
| Entity | Specification |
|---|---|
| Processor | ARM64 Quad-Core |
| RAM | LPDDR4-3200 8 GB |
| Power consumption | 2.5 A |
| Operating temperature | 0 - 50 oC ambient |
| Interfaces | 2 USB jacks, Gigabit Ethernet |
| Storage | 32GB micro-SD Card |
| Operating System | Raspberry Pi OS |
| Metrics | PyTorch | Libtorch |
|---|---|---|
| Accuracy | 89.52% | 89.7% |
| Precision | 89.50% | 88.7% |
| Recall | 89.52% | 89.3% |
| F1-Score | 89.48% | 88.9% |
| Training time | 3.03 hrs | 2.01 hrs |
| Total Power | 2.925 kW | 2.511 kW |
| Average Temperature | 51.4 C | 50.2 C |
| Metrics | PyTorch | Libtorch |
|---|---|---|
| Accuracy | 98.53% | 98.80% |
| Precision | 98.52% | 98.73% |
| Recall | 98.51% | 98.79% |
| F1-Score | 98.51% | 98.75% |
| Training time | 1.20 hrs | 1.29 hrs |
| Total Power | 0.21 kW | 0.14 kW |
| Average Temperature | 76.3 C | 78.5 C |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2024 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).