The official answer for this question is that you have to learn the gender of each new noun individually. However, quite often it is possible to guess the gender of nouns from their endings. For example, all nouns ending in -tion or -sion are feminine. All nouns ending in -isme are masculine, and all nouns ending in -eau (except for l'eau, which is feminine). Also many common nouns ending in -é are masculine. Guides like this can make it easier to work out or remember the gender of some nouns, but in the end you have to learn most noun genders individually.