I assume M18 refers to 18mm Outside Diameter, but to work out which nut would fit, you need to know the Inside Diameter, or at least the wall thickness of the tubing to work it out
This Link will take you to a table of Across Flat/Across Corner dimension of metric nuts. There are many similar tables on the net for other threads/spanner sizes.
So say your tube is 18mm OD wall thickness 1.5mm then ID is 15mm.
M8 would be too loose @ 14.3mm M10 too tight @ 17.8mm
Your only option would be to look around for a different thread, or file a bit off each of the corners of the nut.
I'm assuming you don't have access to a lathe to do the job.
Bill