Processing Energy Modeling for Neural Network Based Image Compression
Nowadays, the compression performance of neural-networkbased image
compression algorithms outperforms state-of-the-art compression approaches such
as JPEG or HEIC-based image compression. Unfortunately, most neural-network
based compression methods are executed on GPUs and consume a high amount of
energy during execution. Therefore, this paper performs an in-depth analysis on
the energy consumption of state-of-the-art neural-network based compression
methods on a GPU and show that the energy consumption of compression networks
can be estimated using the image size with mean estimation errors of less than
7%. Finally, using a correlation analysis, we find that the number of
operations per pixel is the main driving force for energy consumption and
deduce that the network layers up to the second downsampling step are consuming
most energy.
Christian Herglotz, Fabian Brand, Andy Regensky, Felix Rievel, André Kaup
# Processing Energy Modeling

###### Abstract

Nowadays, the compression performance of neural-network-based image compression algorithms outperforms state-of-the-art compression approaches such as JPEG or HEIC-based image compression. Unfortunately, most neural-network based compression methods are executed on GPUs and consume a high amount of energy during execution. Therefore, this paper performs an in-depth analysis on the energy consumption of state-of-the-art neural-network based compression methods on a GPU and show that the energy consumption of compression networks can be estimated using the image size with mean estimation errors of less than \(7\%\). Finally, using a correlation analysis, we find that the number of operations per pixel is the main driving force for energy consumption and deduce that the network layers up to the second downsampling step are consuming most energy.

Christian Herglotz, Fabian Brand, Andy Regensky, Felix Rievel, Andre Kaup Multimedia Communications and Signal Processing

Friedrich-Alexander-Universitat Erlangen-Nurnberg (FAU)

Erlangen, Germany video, compression, autoencoder, energy

## 1 Introduction

In the recent years, image compression using neural networks (NNs) has improved significantly. State-of-the-art compression networks outperform classical methods such as JPEG compression and often show a superior performance to high-end codecs such as HEIC or VVC intra [1, 2]. Unfortunately, NNs are very complex due to a large number of parameters and a complex architecture. As a consequence, they are usually executed on highly parallelized GPUs which leads to extremely high processing energies to compress and decompress a picture. As in a recent study it was shown that online video communications contribute significantly to global greenhouse gas emissions [3], it is clear that this high energy consumption must be mitigated before practical application.

To this end, we perform a first analysis on the energy consumption of current NN-based image compression solutions, which we call compression networks in the following, on GPUs. Then, we construct an energy model that shows that the energy consumption can be estimated with high accuracy using the resolution of the image. Finally, we compare the compression energy in terms of operations per pixel with various network parameters and find that the complexity in terms of multiply-accumulate (MAC) operations has the highest correlation with the energy consumption. The contributions of this paper are as follows:

* In-depth analysis of the power consumption of image compression networks,
* Highly accurate energy modeling approach,
* Recommendations for designing energy-efficient networks.

First, Section 2 introduces the compression networks considered for energy analysis. Section 3 explains our energy measurement setup and Section 4 shows that the energy consumption can accurately be modeled using a linear model exploiting the number of pixels. Then, Section 5 analyzes the resulting energy modeling with respect to typical network parameters. Finally, Section 6 concludes this paper.

## 2 Neural-Network-Based Image Compression

Most current neural network based compression techniques are building on the works by Balle et al. [4]. The authors proposed to use an autoencoder [5] with an entropy bottleneck. Autoencoders were primarily used for feature extraction, similar to principle component analysis. An autoencoder consists of an analysis transform and a synthesis transform. The former is used to transform the input image to a (typically lower dimensional) latent representation while the latter transforms this representation back to the original image. Since the intermediate latent space is low dimensional, the network is forced to focus this representation on the most important features in order to reconstruct the image as accurately as possible. Both analysis and synthesis transform are typically implemented with multiple strided convolutions.

Balle et al. additionally included an entropy constraint to this latent space. Therefore, a probability distribution for the latent elements is estimated which is then used to estimate the rate required to transmit the latent representation using an asymptotically optimal coder (such as, e.g., an arithmetic coder). The network is then trained to jointly minimize the distortion and the required rate.
It is easily seen that the quality of the probability model is crucial for the performance of the compression network. Therefore, subsequent work concerned not only with improving the backbone autoencoder and thereby the feature generation, but also the probability modeling for the latent space. In [6], Balle et. al proposed a refined probability model, which relies on the so-called hyperprior network, which is a second autoencoder transmitting scale information about the features on a side channel. Thereby, regions with low dynamic information can be compressed more efficiently as the low variance can be taken into account by the probability model.

This work was further refined by Minnen et al. [7], who proposed an autoregressive context model, such that the probability model can take spatial correlation into consideration. The context model consists of causal masked convolutional layers, which together with the hyperprior network estimates mean and variance of a multivariate Gaussian distribution.

The previously mentioned approaches use four strided convolution layers with similar dimensions. In contrast, Cheng et al. [8] proposed an autoencoder structure which is much larger and consists of multiple residual blocks and attention layers. Furthermore, the network uses Gaussian mixture models with three Gaussians instead of simple Gaussian models. Thereby, the number of parameters for probability modeling, which need to be estimated, increases.

Table 1 summarizes all compression networks evaluated in this work and their main properties. We show proposed quality levels, the number of parameters, and the required operations in kMAC per pixel. The huge number of parameters hints at the immense complexity of NN-based image compression. NNs are thus commonly executed on GPUs leveraging their extreme parallelization capabilities. This is possible as GPUs provide thousands of compute cores that perform the same instruction on a large number of inputs simultaneously, an operation that is typical for NNs [9]. Since Krizhevsky et al. first successfully employed GPUs for the training and inference of large-scale neural networks [10], GPUs have become the de-facto standard for deep learning research and manufacturers have even extended their hardware to provide dedicated tensor cores for these tasks [11, 12].

## 3 Measurement Setup

For our measurements, we use desktop PCs (Linux OS) equipped with Nvidia Quadro RTX 4000 GPUs run by Intel Core i5-10505 CPUs. As power meters, we use the internal power meters of the GPU that can be read-out using the NVIDIA SMI interface [13] at a sampling rate of \(f_{\mathrm{s}}=10\) Hz.

An example for the power consumption of the GPU during the execution of a compression network (model is already loaded to the GPU) is illustrated in Fig. 1. The plot shows the power consumption of the GPU as returned by NVIDIA SMI before, during, and after the execution of the compression network. Execution starts at \(t=5\) s and ends at \(t=6.2\) s, as indicated by the red vertical lines. The higher power value after the execution (\(t>6.2\) s) corresponds to a higher performance state of the GPU [14]. As the visible delay in state changes is an inherent property of the power control cycle of the GPU but not part of the compression procedure, it is not taken into account in our measurements.

In our automated measurement script, we perform the following procedure to obtain mean processing energies: First, we perform a reference measurement in which the GPU is in idle mode. For this, we read all power consumption samples over \(120\) seconds and calculate the mean power \(P_{\mathrm{idle}}\).

Then, we load the network models on the GPU and pre-heat the GPU to \(80^{\circ}\) C by running the current compression network repeatedly until the temperature is reached. Preheating is performed because during the measurement, we execute the compression network multiple times in a row. Preheating ensures that the temperature of the GPU is constant across all executions, such that static power losses are constant, too.

Afterwards, we start a measurement loop in which the energy consumption \(E_{\mathrm{comp}}\) of compression network execution is measured. For this, we perform \(K\) measurements of the same compression modality (compression network, image, and quality level) to ensure statistical validity of the measurement. In each iteration of the \(K\) measurements, the modality is executed \(M\) times in a row, because the duration of a single execution is often close to the sampling time of the power meter. Consequently, the mean energy is obtained by

\[\overline{E_{\mathrm{comp}}}=\frac{1}{K}\sum_{k=1}^{K}\frac{\left(\sum_{i=1}^{ N}t_{\mathrm{s}}\cdot P_{i,k}\right)-E_{\mathrm{idle}}}{M}, \tag{1}\]

where \(N\) is the number of power samples from the power measurement interval, \(i\) the corresponding sample index, \(t_{\mathrm{s}}=\frac{1}{f_{s}}\) the sampling time of the power meter, \(P_{i,k}\) the power read-out at sample index \(i\) from measurement iteration \(k\), and \(E_{\mathrm{idle}}\) the corresponding energy consumed in idle mode. \(E_{\mathrm{idle}}\) is calculated by \(E_{\mathrm{idle}}=N\cdot t_{\mathrm{s}}\cdot P_{\mathrm{idle}}\). It is subtracted because we are interested in the dynamic, and not the static energy consumption. As measurement interval, we choose the beginning and the ending of the \(M\) executions (samples in-between the red vertical lines in Fig. 1). \(M\) is chosen such that the total duration of all \(M\) executions exceeds \(5\) s.

Figure 1: GPU power over time (blue) during the execution of the compression network (between the red dashed lines). The network model is loaded to the GPU beforehand.
The value of \(K\) is determined at measurement runtime to ensure statistical validity of the measurement using confidence interval tests as proposed in [15]. The resulting mean energy \(\overline{E_{\mathrm{comp}}}\) is then used for further analysis and modeling.

Note that the measurements are performed with the following conditions: First, we test with the GPU in deterministic execution mode to ensure reproducibility [16] which is required in practice. Second, we do not perform entropy encoding and decoding of the latent space, because this is often performed on the CPU. Third, we measure the complete encoder-decoder chain.

We measure the energy for all compression networks listed in Table 1, where we use the implementations from [17]. For each model, we test all available quality levels on \(60\) images from the CLIC image database [18] (test images). Note that the network architectures are provided in two variants with a differing number of parameters: a low level and a high level variant, where the former is used for low quality and the latter for high quality compression. The resolutions of the images span from \(751\times 500\) to \(2048\times 1366\). All images are padded according to the restrictions of the compression networks, which means that the height and the width are padded either to multiples of \(16\) or \(128\).

To ensure the validity of energy measurements using the internal power meter (NVIDIA SMI), we performed additional experiments using an external power meter, a ZES Zimmer LMG661. We measured the energy consumption of the full desktop PC including the GPU through the main power supply of the PC. In total, we measured the execution of \(440\) compression network instances including different networks, images, and deterministic as well as non-deterministic execution. On the power meter, we used the same measurement procedure to derive energies as used for NVIDIA SMI, but we directly read integrated energy values from the power meter as explained in [15]. As a result from this benchmark, we find that apart from a constant offset energy, which is related to the PC's peripheral components such as CPU, memory, motherboard etc., NVIDIA SMI's energy measurements are correlated to the power meter's energy measurements with a correlation factor of \(0.9986\). We conclude that in the measurement conditions used in this analysis, NVIDIA SMI returns accurate energy measurements.

## 4 Energy Modeling

Using the measured data for the six different networks, we attempt to model the energy consumption using high-level properties of the image. To this end, Fig. 2 shows the measured energies (NVIDIA SMI) over the number of pixels per image for the Bhyp compression network. We can see that if we consider a fixed network architecture including a fixed number of network parameters, e.g., the low quality levels of the Bhyp compression network (blue markers), the measured energy values closely follow a linear relationship with the number of pixels. The same holds true for the high quality levels. The linear correlation yields \(0.93\) and \(0.92\) for the low and the high quality levels, respectively, with similar results for other compression networks.

Consequently, we propose to model the energy consumption of neural network processing using a linear equation given by

\[\hat{E}=\alpha\cdot S+\beta, \tag{2}\]

where \(\hat{E}\) is the estimated energy consumption, \(S\) the number of pixels in the image, i.e. the image width multiplied with the image height, \(\alpha\) the slope of the linear function, and \(\beta\) the offset. Illustratively, \(\alpha\) can be interpreted as the mean energy consumption per pixel and \(\beta\) as an energy offset per execution.

To prove the accuracy of the linear estimator from Eq. (2), we also calculate the mean relative estimation error of the model [15]. It is given by

\[\bar{\varepsilon}=\frac{1}{|\mathcal{I}|\cdot|\mathcal{Q}|}\sum_{i\in \mathcal{I}}\sum_{q\in\mathcal{Q}}\frac{|\hat{E}_{q,i}-E_{q,i}|}{E_{q,i}}, \tag{3}\]

\begin{table}
\begin{tabular}{l|l|c|c|c|c|c||c|c||c} \hline Network name & Abbr. & Source & low l. & high l. & low param. & high param. & padd & kMAC & kMAC (\(2^{\mathrm{nd}}\)) \\ \hline \hline bmshj2018\_factorized & Bfac & [4] & 1-5 & 6-8 & 2.998,147 & 7,030,531 & \(16\) & \(73.6/163.2\) & \(56/122.4\) \\ \hline bmshj2018\_hyperprior & Bhyp & [6] & 1-5 & 6-8 & 5,075,843 & 11,816,323 & \(128\) & \(76.3/169.7\) & \(56/122.4\) \\ \hline mbt2018\_mean & Mmean & [7] & 1-4 & 5-8 & 7,028,003 & 17,561,699 & \(128\) & \(80.3/181.4\) & \(56/122.4\) \\ \hline mbt2018 & Mcont & [7] & 1-4 & 5-8 & 14,130,467 & 25,504,596 & \(128\) & \(166.2/201.8\) & \(122.4/122.4\) \\ \hline cheng2020\_anchor & Canch & [8] & 1-3 & 4-6 & 11,833,149 & 26,598,956 & \(128\) & \(373.4/834.8\) & \(345.2/771.2\) \\ \hline cheng2020\_attn & Cattn & [8] & 1-3 & 4-6 & 13,183,293 & 29,631,788 & \(128\) & \(415.9/930.3\) & \(385.1/861.1\) \\ \hline \end{tabular}
\end{table}
Table 1: Compression networks and main properties. ‘low l.’ and ‘high l.’ represent parameter levels, ‘padd’ is short for ‘image padding’. The two rightmost columns show the kMAC per pixel (low/high) of the entire and up to the \(2^{\mathrm{nd}}\) layer, respectively.

Figure 2: GPU energy over number of image pixels for the Bhyp compression network. The red markers correspond to high quality levels (HQ), the blue markers to low quality levels (LQ). The lines are linear least-squares fits to the points.
where \(i\) is the image index from the complete set of images \(\mathcal{I}\) and \(q\) the quality level index from the set of quality indices \(\mathcal{Q}\), where this set either contains the high qualities or the low qualities. \(E_{q,i}\) and \(\hat{E}_{q,i}\) correspond to the measured and the estimated processing energies from Eq. (1) and Eq. (2), respectively, of the \(i\)-th picture and the \(q\)-th quality level. Training and validation is performed using \(10\)-fold cross-validation.

The slope \(\alpha\), the offset \(\beta\), and the mean estimation errors \(\bar{\varepsilon}\) are summarized for all tested compression networks, separated by high and low quality levels, in Table 2. Considering the estimation error, we can see that the proposed linear model leads to mean estimation errors below \(7\%\). For the Canch and Cattn model, the error is significantly lower (below \(4\%\)). This behavior is probably related to the utilized capacity of the GPU, which is significantly higher for the Canch and Cattn network, as indicated by NVIDIA SMI. This conjecture is an interesting aspect for future research.

The values of the offset parameter \(\beta\) show that there is a significant offset energy needed to execute the compression networks. However, considering image sizes of at least \(1120\times 760\) pixels (only a single image from the set has a lower resolution), the offset energy never exceeds a ratio of \(20\%\) of the total measured energy.

The slope parameters \(\alpha\) reflect the observation that compression networks for high visual qualities consume more energy than those for low visual quality, because the high-quality values are greater. We can also observe that the highest value is almost five times higher than the lowest value (\(4.97\) vs. \(1.05\)).

## 5 Model Analysis

In the next step, we compare the energy consumption (in energy per pixel) with network parameters to identify correlations, which could be helpful in network design decisions. Therefore, we analyze the per-pixel-complexity of the networks in the unit multiply-accumulate (MAC) operations per pixel. We calculate the MAC for all networks by counting the operations in each convolutional layer and weighting them according to the current downsampling at this layer. We report the values in Table 1.

To show that the MAC is an important parameter in the energy consumption, we plot the MAC values and the \(\alpha\) values for all networks in Fig. 3. We can see that all parameters closely follow a linear relationship with the complexity of the network in terms of MAC. Next to a linear term, we can also find an offset, which indicates that a minimum energy per pixel is required (e.g., due to memory read and write of the raw image).

We further study the kMAC per network layer to find reasons for the high power consumption of an image compression network. In particular, we focus on the part of the network that is most important for processing complexity. Here, we find that the layers up to and including the second downsampling step are very important (see the corresponding kMAC values in the last column of Table 1). Since the deeper layers are performed on rapidly decreasing resolution, the impact on the kMAC per pixel is small. Performing a similar fit to these \(2^{\rm nd}\)-layer MAC values as to the entire MAC values, we find that the linear correlation is almost as high (MRE of \(7.64\%\) for the entire MAC vs. \(11.16\%\) for the \(2^{\rm nd}\)-layer MAC). We conclude that these layers are the major reason for a high energy consumption of neural-network based image coders, such that they should be the main target when developing energy efficient NN-based compression schemes.

## 6 Conclusions

In this paper, we investigated the energy consumption of state-of-the-art neural-network based image compression networks on a GPU.We showed that the energy consumption linearly depends on the number of pixels and that the network layers up to the second downsampling step contribute most to the overall energy consumption.

In future work, we plan to analyze further networks, to separately analyze the encoding and the decoding process, and to additionally consider entropy encoding and decoding. Finally, we will test other GPUs and optimized hardware to generate a fair comparison with legacy image compression methods.

\begin{table}
\begin{tabular}{r|c|c|c|c|c|c} \hline Network & Bfac & Bhyp & Mmean & Mcont & Canch & Cattn \\ \hline \(\alpha_{\rm low}(\cdot 10^{-5})\) & \(1.05\) & \(1.15\) & \(1.17\) & \(1.75\) & \(1.99\) & \(2.34\) \\ \(\alpha_{\rm high}(\cdot 10^{-5})\) & \(1.50\) & \(1.73\) & \(1.76\) & \(1.82\) & \(4.20\) & \(4.97\) \\ \hline \(\beta_{\rm low}\) & \(1.95\) & \(1.61\) & \(1.58\) & \(3.01\) & \(0.37\) & \(0.42\) \\ \(\beta_{\rm high}\) & \(3.68\) & \(2.93\) & \(3.17\) & \(3.52\) & \(2.32\) & \(2.12\) \\ \hline \(\bar{\varepsilon}_{\rm low}\left[\%\right]\) & \(6.09\) & \(6.08\) & \(6.04\) & \(6.30\) & \(3.55\) & \(3.31\) \\ \(\bar{\varepsilon}_{\rm high}\left[\%\right]\) & \(6.11\) & \(6.24\) & \(6.28\) & \(6.46\) & \(3.88\) & \(3.54\) \\ \hline \end{tabular}
\end{table}
Table 2: Modeling parameters and estimation errors for all considered compression networks.

Figure 3: Slopes \(\alpha\) over the MAC for all compression networks (color) and their quality levels (x’es for low qualities, o’s for high qualities). The dashed line is a linear fit for all points.