iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🦙

How to Easily Try Local LLM with llama.cpp (No CUDA Installation Required)

に公開

タイトル画像

Introduction

This article describes an easy way to try llama.cpp, a tool for running LLMs on a local PC. This procedure allows you to skip the following tasks:

  • No building of llama.cpp
  • No CUDA installation

Just download and extract to immediately try llama.cpp without CUDA installation or building.
This is especially recommended for those who are thinking, "I'd like to run an LLM on my local PC."

Requirements

To try the procedure in this article, you need at least the following:

  • NVIDIA graphics card
  • NVIDIA GPU driver version 551.61 or later

Procedure

1. Download llama.cpp

Download the binaries of llama.cpp from the GitHub repository.

https://github.com/ggml-org/llama.cpp/releases

Download the following two files:

  • cudart-llama-bin-win-cuda-12.4-x64.zip
  • llama-b6257-bin-win-cuda-12.4-x64.zip (b6257 is the version number)

After downloading, extract the contents of both ZIP files into the same folder.

2. Download a Model

The model we will use this time is based on Swallow (a Llama-3 family model with enhanced Japanese performance) developed by Tokyo Institute of Technology and the National Institute of Advanced Industrial Science and Technology (AIST).

  • Llama-3.1-Swallow-8B-Instruct-v0.5-Q4_K_M.gguf

This is an 8-billion-parameter Swallow Instruct model that has been 4-bit quantized (Q4_K_M method) and converted to GGUF format by a volunteer (TensorBlock).

You can download this file from the following Hugging Face page:

https://huggingface.co/tensorblock/tokyotech-llm_Llama-3.1-Swallow-8B-Instruct-v0.5-GGUF/blob/main/Llama-3.1-Swallow-8B-Instruct-v0.5-Q4_K_M.gguf

After downloading, save it into the folder where you extracted llama.cpp in step 1.

3. Execute

Open a command prompt, navigate to the folder where you extracted llama.cpp, and then execute the following command to launch the llama.cpp CLI. It will then wait for a prompt from the user.

llama-cli -m "Llama-3.1-Swallow-8B-Instruct-v0.5-Q4_K_M.gguf" -ngl 999 -c 4096

An example execution is shown below:

Execution example
Example screen when llama-cli starts

The meaning of each parameter is as follows:

  • -m
    → Specifies the model to use. Here, Swallow 8B (Q4_K_M, GGUF).
  • -ngl 999
    → Instructs to "offload as many layers as possible to the GPU."
    → With a GPU with 8GB VRAM, almost all of the Q4_K_M 8B model can be loaded onto the GPU.
    → If VRAM is limited, setting -ngl 20 or similar can make it more stable.
  • -c 4096
    → Sets the context length to 4096 tokens.
    → The KV cache is expected to consume approximately 0.5GB to 1GB of VRAM.

For details on the parameters, please refer to the official repository below:
https://github.com/ggml-org/llama.cpp/tree/master/tools/main

Summary

With the steps above, you can easily try llama.cpp in your local environment.
By skipping CUDA installation and build procedures and simply extracting the downloaded files, you can run it right away, making it a great option for those who want to try a local LLM for the first time.

  • What you need is an NVIDIA GPU and a compatible driver
  • Prepare the llama.cpp binaries and a model file
  • Execute the command to start interacting immediately

With local execution, you can experiment as much as you like without worrying about API fees, and your data stays on your machine for peace of mind. Give it a try on your own environment and enjoy experiencing a local LLM.

That's all for this time.
See you later, bye bye 😊

Discussion