The reliability of infrared (IR) and ultraviolet (UV) emissions to measure star formation rates (SFRs) in galaxies is investigated for a large sample of galaxies observed with the Spectral and Photometric Imaging Receiver (SPIRE) and the Photodetector ArrayCamera and Spectrometer (PACS) instruments on Herschel as part of the Herschel Multi-Tiered Extragalactic Survey (HerMES) project. We build flux-limited 250-mu m samples of sources at redshift z < 1, cross-matched with the Spitzer/MIPS and GALEX catalogues. About 60 per cent of the Herschel sources are detected in UV. The total IR luminosities, L-IR, of the sources are estimated using a spectral energy distribution (SED) fitting code that fits to fluxes between 24 and 500 mu m. Dust attenuation is discussed on the basis of commonly used diagnostics: the L-IR/L-UV ratio and the slope, beta, of the UV continuum. A mean dust attenuation A(UV) of similar or equal to 3 mag is measured in the samples. L-IR/L-UV is found to correlate with L-IR. Galaxies with L-IR > 10(11) L-circle dot and 0.5 < z < 1 exhibit a mean dust attenuation A(UV) of about 0.7 mag lower than that found for their local counterparts, although with a large dispersion. Our galaxy samples span a large range of beta and L-IR/L-UV values which, for the most part, are distributed between the ranges defined by the relations found locally for starburst and normal star-forming galaxies. As a consequence the recipe commonly applied to local starbursts is found to overestimate the dust attenuation correction in our galaxy sample by a factor of similar to 2-3. The SFRs deduced from L-IR are found to account for about 90 per cent of the total SFR; this percentage drops to 71 per cent for galaxies with SFR < 1M(circle dot) yr(-1) (or L-IR < 10(10) L-circle dot). For these faint objects, one needs to combine UV and IR emissions to obtain an accurate measure of the SFR.