Measurements of the $\mathrm pp \to W \gamma\gamma $ and $\mathrm pp \to Z \gamma\gamma $ cross sections and limits on anomalous quartic gauge couplings at $\sqrts =$ 8 TeV