library(rlmstudio)
lms_installed <- has_lms()
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)The rlmstudio package provides robust support for
running LM Studio in completely headless environments. This is ideal for
Linux servers, Docker containers, remote cloud instances, and automated
CI/CD pipelines where a visual desktop application is unavailable or
inconvenient.
To operate without a GUI, LM Studio relies on a background process
called the llmster daemon. This vignette will walk you
through managing the daemon, starting the local server, and fully
automating your local LLM workflows.
If you are setting up a fresh remote server, you can use the package
to download and install the LM Studio CLI automatically via the
terminal. Run install_lmstudio(method = "headless") in your
console to execute the automated installation script.
Unlike the desktop version where opening the app initializes the
backend engine, a headless environment requires you to start the engine
manually. You must start the llmster daemon before
attempting to load models or start the API server.
With the daemon running, you can now spin up the REST API server to accept HTTP requests.
Because you do not have the GUI’s visual search tool, you will need to know the Hugging Face repository or the LM Studio catalog identifier for the model you want to use.
Allocate the model to your system’s memory (RAM/VRAM) so it is ready for inference.
Interact with the model exactly as you would in a desktop environment.
In a headless environment, managing your system resources is critical. When your script finishes, you should explicitly tear down the entire stack to free up memory and stop background processes.
If you are writing a script that just needs to run a quick job and
exit, managing the daemon state manually can be tedious. The
with_lms_daemon() wrapper handles the setup and guaranteed
teardown of the background engine automatically.