Shutdown graphical user interface in order to use more GPU ram

I wrote a program in PyTorch but unfortunately I need one more GB of GPU ram. My GPU is 1080 Ti and my OS is Ubuntu 18.04.
In other to solve my problem I need to shutdown the Graphical User Interface of Ubuntu 18.04. However I don’t know how do that.