Alright I got why… cudaMemset, like a plain memset, only set each byte to the target value, while int is, in most machines, 4 bytes. Hence the issue.