Add more info about your system, as detailed in https://retropie.org.uk/forum/topic/3/read-this-first.
Installation logs are kept in $HOME/RetroPie-Setup/logs - get the latest log from there (you'll need SSH to copy it), then post its contents on pastebin.com.
The error is a generic one, the root cause for this should be detailed in the log file.