The Sivers function describes the correlation between the transverse spin of a nucleon and the transverse motion of its partons. It was extracted from measurements of the azimuthal asymmetry of hadrons produced in semi-inclusive deep inelastic scattering of leptons off transversely polarised nucleon targets, and it turned out to be non-zero for quarks. In this letter the evaluation of the Sivers asymmetry for gluons in the same process is presented. The analysis method is based on a Monte Carlo simulation that includes three hard processes: photon-gluon fusion, QCD Compton scattering and leading-order virtual-photon absorption process. The Sivers asymmetries of the three processes are simultaneously extracted using the LEPTO event generator and a neural network approach. The method is applied to samples of events containing at least two hadrons with large transverse momentum from the COMPASS data taken with a 160 GeV/$c$ muon beam scattered off transversely polarised deuterons and protons. With a significance of more than two standard deviations a negative value is obtained for the gluon Sivers asymmetry. The result of a similar analysis for a Collins-like asymmetry for gluons is consistent with zero.