Mobile edge computing (MEC) is considered as an effective technology to enhance the storage and computation capability of smart power sensors (SPSs) in smart grid networks. The MEC server is composed of multiple virtual machines (VMs) with powerful computation capability, and each VM can process multiple tasks independently, which cannot be ignored during the task computation period. In this work, we aim to minimize the energy consumption of SPSs subject to the task offloading delay by jointly optimizing the VM selection and computation resource allocation. Considering the formulated problem is nonconvex, we first utilize the linearization method to transform it into a convex optimization problem. And then, by using the branch and bound method, we propose the joint VM selection and computation resource allocation (JVMSRA) algorithm. Considering the complexity of the JVMSRA algorithm is high, we decompose the primal problem into two subproblems and solve them by utilizing the ant colony method and CVX package, respectively. Based on the solutions of the two subproblems, the resource allocation-based ant colony (RAAC) algorithm is proposed. Simulation results show that the proposed RAAC algorithm and JVMSRA algorithm decrease by 6% and 8.8% on average compared with the benchmark algorithm, respectively, when the computation resources of each VM increase from
1
to
3
GHz.