Skip to main content

Start LM Studio server as a Windows service on system boot

 In order to connect to LM Studio from your LAN, and use programs like Chatbox with it, you need to start its server mode, and enable CORS: https://lmstudio.ai/docs/api

However, currently there is no simple way to start LM Studio on PC startup, without logging in as a user. You can if you auto-login by following these steps: https://lmstudio.ai/docs/api/headless

However, I want to start the PC remotely (via Wake-on-LAN), and be able to connect to LM Studio, select the desired model and use it, without logging into the PC. 

Here's what we can do:

1. Download NSSM: https://nssm.cc/ and copy it to "C:\Program Files\nssm" for convenience.

2. Identify the location of lms.exe. In my case it's in "%UserProfile%\.cache\lm-studio\bin". Replace "%UserProfile%" with the real path for your system (e.g. "C:\Users\MyUser").

3. Navigate to "%UserProfile%\.cache\lm-studio\bin" and create the following file named lms-startup.batAdd the following code to it and save it: 

@echo off

lms.exe server start --cors

pause

4. In a privileged command prompt, run nssm install and you will get a GUI for creating a new Windows Service:


5. Under Path select the path of the lms-startup.bat file, Startup Directory should be the same path. Under Arguments leave blank. Under Service name add "LMStudio":






6. Under Log on tab, select Log on as "This Account" and input your windows username and password. This will allow the program to run as your user, having access to the models you download via the GUI:



7. Under the Exit actions tab, set "Delay restart if application runs for less than 0 ms"

8. When you're done, click Install service. The new service should be visible under Windows Services and should start on boot (note that there isn't a graceful way of restarting/stopping the service). 


Comments

Popular posts from this blog

Home Assistant + Android TV = fun

Here's a quick setup guide for controlling your Android TV from within Home Assistant. I've used it to control a genuine Android TV (Philips 7304) and an Odroid N2 running Android TV. For this to work you need ADB access. It can usually be enabled from within Developer Settings. The great part is - you don't need root access! The most important things are described in the androidtv component for Home Assistant: https://www.home-assistant.io/integrations/androidtv/ Make sure you go through the adb setup. My configuration is simple (inside configuration.yaml): media_player:   - platform: androidtv     name: TV Bedroom ATV     host: 192.168.1.61     device_class: androidtv Once Home Assistant restarts, your TV might require you to accept the connection (adb authentication). This happens only once (or until you reset your ATV to factory settings). Once running the integration will show you the current ATV state (on or off) and al...

SmokePing + InfluxDB export + docker + slaves + Grafana = fun

I've been working for a while on this project - with the purpose of getting SmokePing measurements from different hosts (slaves) into InfluxDB so that we can better graph them with Grafana. The slaves run multiple Smokeping instances inside Docker so that they have separate networking (measure through different uplinks, independently). This will not be a comprehensive configuration guide, but a quick "how to" to handle setup and basic troubleshooting. It assumes you already know how to set up and operate a regular Smokeping install with or without slaves and that you are fluent in Smokeping configuration syntax, know your way around Docker and aren't a stranger from InfluxDB and Grafana (sorry, there's a lot of information to take in). 1. Getting Smokeping with InfluxDB support - you can get it either from the official page (most changes have been merged) - https://github.com/oetiker/SmokePing (PR discussion here: https://github.com/oetiker/SmokePing/issues/...

Installing Home Assistant Supervised on an old 32bit HP laptop

 I've received a challenge from my former boss: an old HP laptop that was born in 2005:  an HP-Compaq NC6220 ( https://www.pocket-lint.com/laptops/reviews/hp/68181-hp-compaq-nc6220-notebook-laptop/ ). The specs are abysmal: So, i386, 1.7GHz single-core CPU (remember those?), 1G of DDR2 RAM (2x512M) and a 40GB ATA (not SATA!) drive. But hey, at least it has a serial port!  The challenge is to install HomeAssistant ( https://www.home-assistant.io/ ) on it so that he can monitor some Zigbee temperature sensors and relays (via a gateway). The first hurdle was to remove the BIOS password - following this nice guide: https://www.youtube.com/watch?v=ZaGKyb0ntSg Next-up - install HASSOS. Unfortunately, it doesn't support i386, but only x86_64... So, I went the Home Assistant Supervised route, and installed Debian 11 i386 edition from a netinstall USB ( https://cdimage.debian.org/debian-cd/current/i386/iso-cd/debian-11.6.0-i386-netinst.iso ).   Once Debian was up and run...