Mastodon
New gist
Recent
API
Trending
Blog
Guest
Sign Up or Login
Login
Sign Up
New Gist
Syntax Highlighting
# How to Install and Run [LM Studio](https://lmstudio.ai/) on Ubuntu as a Headless Server This guide explains how to install and run LM Studio in a headless Ubuntu environment. --- ## **Prerequisites** Ensure you have an Ubuntu 24.10 server with sufficient resources for the models you plan to use. For testing, a machine with **2 GB RAM, 2 CPUs, and 60 GB SSD** is sufficient for smaller models. --- ## **Step 1: Install Required Packages** Run the following command to install all necessary dependencies: ```bash sudo apt install -y npm fuse fuse3 libfuse2 libatk1.0-0 libatk-bridge2.0-0 libcairo2 libgdk-pixbuf2.0-0 libgtk-3-0 libx11-6 libnss3 libasound2 libasound2t64 libcups2 xauth xvfb xfce4 xfce4-goodies ``` --- ## **Step 2: Download LM Studio** Download the LM Studio AppImage from the official site (https://lmstudio.ai/): ```bash wget https://installers.lmstudio.ai/linux/x64/0.3.6-8/LM-Studio-0.3.6-8-x64.AppImage ``` Make the file executable: ```bash chmod +x LM-Studio-0.3.6-8-x64.AppImage ``` --- ## **Step 3: Run LM Studio with a Virtual Display** Run LM Studio using `xvfb` to simulate a graphical environment: ```bash xvfb-run ./LM-Studio-0.3.6-8-x64.AppImage --no-sandbox ``` This initializes LM Studio and prepares it for headless operation. --- ## **Step 4: Install the LM Studio CLI** Install the LM Studio CLI tool (`lms`) using: ```bash npx lmstudio install-cli ``` During installation, you’ll see the following prompt: ``` We are about to run the following commands to install the LM Studio CLI tool (lms): echo 'export PATH="$PATH:/root/.lmstudio/bin"' >> ~/.profile echo 'export PATH="$PATH:/root/.lmstudio/bin"' >> ~/.bashrc ``` Confirm by typing `Yes`. This will add the CLI tool to your PATH. Open a new terminal session or run: ```bash source ~/.bashrc ``` Verify the installation: ```bash lms --help ``` --- ## **Step 5: Start the LM Studio Server** Start the server to enable API access: ```bash lms server start ``` Check the server status: ```bash lms status ``` You should see output indicating the server is running on port **1234**. --- ## **Step 6: Download and Load a Model** List available models to download: ```bash lms get ``` Select a lightweight model such as **Qwen2.5 Coder 3B Instruct** and confirm the download. Once downloaded, load the model: ```bash lms load qwen2.5-coder-3b-instruct ``` Verify the loaded models: ```bash lms ps ``` --- ## **Step 7: Test the Model via API** Send a request to the running server to test the model: ```bash curl http://localhost:1234/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "qwen2.5-coder-3b-instruct", "messages": [ { "role": "user", "content": "Write a Python function to reverse a string." } ] }' ``` ### Example Response: ```json { "id": "chatcmpl-o2nubfsik7bykwbkdysbrd", "object": "chat.completion", "created": 1736694420, "model": "qwen2.5-coder-3b-instruct", "choices": [ { "index": 0, "logprobs": null, "finish_reason": "stop", "message": { "role": "assistant", "content": "Here's a simple Python function to reverse a given string:\n\n```python\ndef reverse_string(s):\n # Using slicing to reverse the string\n return s[::-1]\n\n# Example usage\nreversed_s = reverse_string(\"hello\")\nprint(reversed_s) # Output: \"olleh\"\n```" } } ], "usage": { "prompt_tokens": 38, "completion_tokens": 116, "total_tokens": 154 }, "system_fingerprint": "qwen2.5-coder-3b-instruct" } ``` --- ## **Step 8: Manage Models** ### List Installed Models: ```bash lms ls ``` ### Unload a Model: ```bash lms unload <model-identifier> ``` ### Stop the Server: ```bash lms server stop ``` --- ## **Conclusion** You have successfully installed and configured LM Studio on a headless Ubuntu server. You can now explore various models and use the API for your projects. If you encounter issues, refer to the LM Studio documentation or seek assistance. 😊
Optional Gist Settings
Gist Name/Title:
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Syntax Highlighting:
None
Bash
C
C++
C#
CSS
HTML
Java
JavaScript
Lua
Objective C
Perl
PHP
Python
Ruby
JSON
Swift
Markdown
ActionScript
Ada
Apache Log
AppleScript
ASM (NASM)
ASP
Bash
C
C for Macs
CAD DCL
CAD Lisp
C++
C#
ColdFusion
CSS
D
Delphi
Diff
Batch
Eiffel
Fortran
FreeBasic
Game Maker
HTML
INI file
Java
JavaScript
Lisp
Lua
MPASM
MySQL
NullSoft Installer
Objective C
OCaml
Openoffice BASIC
Oracle 8
Pascal
Perl
PHP
Python
QBasic
Robots
Ruby
Scheme
Smarty
SQL
VisualBasic
VB.NET
VisualFoxPro
XML
AutoIt
Blitz Basic
BNF
Erlang
Genero
Groovy
Haskell
Inno Script
Latex
Linden Scripting
MatLab
M68000 Assembler
mIRC
Rails
PL/SQL
Smalltalk
TCL
Z80 Assembler
ABAP
ActionScript 3
APT Sources
Avisynth
Basic4GL
BibTeX
BrainFuck
BOO
CFDG
C Intermediate Language
CMake
COBOL
DCS
DIV
DOT
Email
FO Language
GetText
OpenGL Shading
Ruby Gnuplot
HQ9 Plus
IDL
INTERCAL
IO
Java 5
KiXtart
Clone C
Clone C++
Loco Basic
LOL Code
Lotus Formulas
Lotus Script
LScript
Make
Modula 3
MXML
Oberon 2
OCaml Brief
Oracle 11
Per
PHP Brief
Pic 16
Pixel Bender
POV-Ray
PowerShell
Progress
Prolog
Properties
ProvideX
REBOL
REG
SAS
Scala
Scilab
SdlBasic
Tera Term
thinBasic
T-SQL
TypoScript
VeriLog
VHDL
VIM
Visual Pro Log
WhiteSpace
WHOIS
Winbatch
Xorg Config
XPP
Pawn
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
Motorola 68000 HiSoft Dev
ALGOL 68
autoconf
Autohotkey
Awk
Cuesheet
ChaiScript
Clojure
C++ (with Qt extensions)
E
ECMAScript
Formula One
F#
GAMBAS
GDB
Genie
Go
GwBasic
HicEst
Icon
J
jQuery
Liberty BASIC
Logtalk
MagikSF
MapBasic
MIX Assembler
Modula 2
newLISP
Objeck Programming Language
Oz
Delphi Prism (Oxygene)
Oz
PCRE
Perl 6
OpenBSD PACKET FILTER
Pike
PostgreSQL
PowerBuilder
PureBasic
q/kdb+
RPM Spec
R
SystemVerilog
Vala
Unicon
Vala
XBasic
ZXBasic
UnrealScript
HTML 5
ProFTPd
BASCOM AVR
C: Loadrunner
CoffeeScript
EPC
Falcon
LLVM
PyCon
YAML
FreeSWITCH
ARM
Asymptote
DCL
DCPU-16
Haxe
LDIF
Nagios
Octave
ParaSail
PARI/GP
Python for S60
Rexx
SPARK
SPARQL
StoneScript
UPC
Urbi
Vedit
AIMMS
Chapel
Dart
Easytrieve
ISPF Panel Definition
JCL
Nginx
Nim
PostScript
QML
Racket
RBScript
Rust
SCL
StandardML
VBScript
C (WinAPI)
C++ (WinAPI)
NetRexx
JSON
Swift
SuperCollider
Julia
Blitz3D
BlitzMax
SQF
Puppet
Filemaker
Euphoria
PL/I
Open Object Rexx
Markdown
Kotlin
Ceylon
Arduino
YARA
TypeScript
Mercury
MetaPost
MK-61/52
Phix
Roff Manpage
SSH Config
TeXgraph
Xojo
KSP (Kontakt Script)
GDScript
Godot GLSL
None
Tags:
Gist Exposure:
Public
Unlisted
Private
Gist Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Password
Enabled
Disabled
Folder:
(members only)
Burn after read
Create New Gist
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Gists
Building a Mortgage Document Classification Model using an LLM Library
Python | 8 hours ago | 17 Views
Reflected XSS and Server-Side Template Injection Found in HubSpot CMS
None | 1 day ago | 465 Views
Installing and Running LM Studio on Ubuntu as a Headless Server
Markdown | 3 days ago | 42 Views
Kaldığın Yerden: A Turkish Love Song
None | 3 days ago | 32 Views
Untitled
None | 3 days ago | 28 Views
oprendszerBashZH
None | 3 days ago | 33 Views
ESP8266 Wi-Fi Module to Control LED using Blynk App
C++ | 3 days ago | 35 Views
Not a member of GistPad yet?
Sign Up
, it unlocks many cool features!
We use cookies for various purposes including analytics. By continuing to use GistPad, you agree to our use of cookies as described in the
Privacy Policy
.
OK, I Understand