This guide walks you through setting up and running DeepSeek-R1 locally on Windows 10/11 using LM Studio and Python. No expensive cloud APIs required!
LM Studio allows you to run LLM models locally on your computer.
π Download LM Studio: π https://lmstudio.ai/
β Installation Steps:
- Download and install LM Studio for Windows. (Currently available version: 0.3.9 as of 31 Jan, 2025)
- Open LM Studio and go to the Discover tab.
- Search for DeepSeek-R1-Distill-Qwen-7B-GGUF or DeepSeek-R1-Distill-Llama-8B-GGUF and download the model.
- Load up the model from "Select a model to load" tab or press Ctrl+L and then load the downloaded model.
- Go to the Developer tab and start the local API server (default: http://localhost:1234/v1).
(In LM Studio 0.3.8 it appears as a Status button. Change it from "Stopped" to "Running")
-
Check if you have Python installed by running following in Command Prompt (cmd):
python --version
(The version of Python I ran this program on is 3.10.11)
-
If you don't have python installed in your system, download from Python.org and check "Add Python to PATH" during installation. Verify installation by following previous step and then proceed to next step.
-
Once you have python installed. Write this in Command Prompt (cmd):
pip install openai
(We install the OpenAI package to communicate with LM Studio's local API, allowing us to send prompts and receive responses from offline LLM models using Python.)
-
Verify OpenAI package installation by writing this in Command Prompt (cmd):
pip show openai
If installed, you'll see Name: openai and a version number along with some more details. (The version of OpenAI I ran this program on is 0.28.0)
Ensuring the packages from Step 2 are installed while DeepSeek-R1 model is loaded with the local API server in "running" status in LM Studio, proceed to run the deepseekpython.py in your preffered code development environment.
π You can run deepseekpython.py using Visual Studio Code π https://code.visualstudio.com/
If you are using Visual Studio Code, press Ctrl+F5 to run the script. You will get a prompt like this upon execution in output console:
Write anything you want in the prompt and wait a while for the model to answer back. It took me on average around 30 seconds to 1 minute for basic questions (NVIDIA GeForce RTX 2060 with 16 GB RAM)
πΉ Issue: "openai.ChatCompletion.create is not supported"
β Fix: Use the new openai.chat.completions.create() method.
πΉ Issue: "No module named openai"
β Fix: Run pip install openai to install the package.
πΉ Issue: "Could not connect to http://localhost:1234/v1"
β Fix: Ensure LM Studio API server is running under the Server tab.
If you liked this project, please leave a star! π

