According to Rambam (Melachim 10):
"A gentile who inadvertently violates one of his commandments is exempt from all punishment with the exception of a person who kills inadvertently. ...
When does the above apply? When he inadvertently violates a command without sinful intention; for example, a person who engages in relations with his colleague's wife under the impression that she is his own wife or unmarried.
If, however, one knew that she was his colleague's wife, but did not know that she was forbidden to him or it occurred to him that this act was permitted or one killed without knowing that it is forbidden to kill, he is considered close to having sinned intentionally and is executed. This is not considered as an inadvertent violation. For he should have learned the obligations incumbent upon him and did not."