iMac RAM expansion compatibility

Apple has a support document explaining this, see https://support.apple.com/en-us/HT201191#27inch2017 for your model:

enter image description here