In your defense, and as someone who never really frequented a gym, why is it tacky to hit on someone at the gym? Is it because presumably people aren't there to socialize? Are people there to be in their own head working out and pushing themselves?
Maybe it would be fine if you had some other interaction(s) first... Like if you offered to help spot them, or how to work a machine, or offered them a spare Gatorade, or were in a workout class together, etc.