Fully relativistic calculations are presented for the double K-shell photoionization cross section for several neutral medium-Z atoms, from magnesium (Z = 10) up to silver (Z = 47). The calculations take into account all multipoles of the absorbed photon as well as the retardation of the electron-electron interaction. The approach is based on the partial-wave representation of the Dirac continuum states and uses the Green-function technique to represent the full Dirac spectrum of intermediate states. The method is strictly gauge invariant, which is used as an independent cross check of the computational procedure. The calculated ratios of the double-to-single K-shell ionization cross sections are compared with the experimental data and with previous computations.