You just have to memorize the gender. One exception is that nouns that end in -ность are feminine (I can't think of any exceptions to this rule, but I'm not a native).