We present an algorithm for numerical simulation of electric current in rock samples and numerical upscaling of heterogeneous samples electrical resistivity (conductivity). The solver is oriented on solving strongly heterogeneous problems so that partially saturated multi-mineral core samples can be treated. The algorithm is based on the Krylov-type solver, where the preconditioner is the inverse Laplace operator for homogeneous media. To compute the preconditioner, we use the spectral method in the directions normal to the current and solving series of 1D problems by Thomas algorithm. The solver is implemented using Graphic Processor Units and allows handling samples of the size up to 4003 voxels by a single GPU.