To have a GUI that exists only in memory, I would suggest using Xvfb (X Virtual Frame Buffer). I have written an answer on this previously, so I will just reproduce the same here with some minor edits.
Xvfb (X Virtual Frame Buffer) allows you to have a display that exists only in-memory, so that tests/operations with graphical dependencies can be completed without actually using a GUI.
On CentOS, you can install Xvfb from the core CentOS repository with yum:
yum install xorg-x11-server-Xvfb
Once Xvfb is installed, prefix your command with
xvfb-run to use it:
xvfb-run is a wrapper command that does a few useful things. First, it initializes an Xvfb display and passes it to your command for execution. Once the command runs to completion, the display is also gracefully shut down.