2 min read

Launch LM Studio + Open WebUI automatically at startup of your PC

Launch LM Studio + Open WebUI automatically at startup of your PC
The AI Office

When using LM Studio in combination with Open WebUI as a Local AI server at home, it would be nice to have the possibility to start LM Studio and Open WebUI at startup when booting your PC. Don’t know what I’m talking about? Check out this article on how to set up your Local AI home server with LM Studio and Open WebUI.

The advantage is that you can just turn off the PC when you do not need LLMs to talk to and save some money on your electricity bill. The next time that you turn on your PC, LM Studio and Open WebUI will immediately run, so that a press on the ‘power on’ button of your PC is enough to ask questions in Open WebUI.

LM Studio Autostart

The configuration of this article is based on the installation steps we took here. Make sure that there are LLM models selected on the ‘Developer’ page.

With an autostart desktop script, it is possible to open LM Studio at startup. This is necessary to make use of the LM Studio server.

  • First, open a terminal by pressing the Windows button. Then type ‘cmd’ and press Enter. Go to the home directory of the logged user:
cd ~
  • Create the following directory:
mkdir .config/autostart
  • Now open nano and create a new .desktop file:
nano .config/autostart/lmstudio.desktop
  • Copy and paste the following:
[Desktop Entry]
Type=Application
Name=LM Studio
Exec=/path/to/LM-Studio.AppImage --no-sandbox
Hidden=false
NoDisplay=false
X-GNOME-Autostart-Enabled=true
Terminal=false
  • Replace /path/to/ with the path where you stored the LM-Studio.AppImage file.
  • Press ‘Ctrl + X’, then press ‘Y’, and ‘Enter’.

Open WebUI as Systemd Service

  • Now create a Service File:
nano ~/.config/systemd/user/open-webui.service
  • Paste the following content into the file:
[Unit]
Description=Open WebUI
After=network.target

[Service]
Type=simple
ExecStart=/home/<user>/open-webui/venv/bin/open-webui serve
Restart=on-failure
WorkingDirectory=/home/<user>/open-webui
  • Replace <user> with the name of the logged Ubuntu user.
  • Then Save and Close the File: ‘Ctrl+X’, ‘Y’, ‘Enter’ in nano.

For example, in my case:

[Unit]
Description=Open WebUI
After=network.target

[Service]
Type=simple
ExecStart=/home/rencz/open-webui/venv/bin/open-webui serve
Restart=on-failure
WorkingDirectory=/home/rencz/open-webui
  • Enable and Start the Service:
systemctl --user enable open-webui.service
systemctl --user start open-webui.service
  • Check the Status:
systemctl --user status open-webui.service
  • Now reboot the PC. At any device on the home network it should now be possible to use Open WebUI when the PC is turned on.