Skip to content

Instantly share code, notes, and snippets.

@mikebohdan
Created November 17, 2023 16:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikebohdan/73e64b27b9a1f04dad8bb4b8a471c124 to your computer and use it in GitHub Desktop.
Save mikebohdan/73e64b27b9a1f04dad8bb4b8a471c124 to your computer and use it in GitHub Desktop.
Setup Tabby on WSL with CUDA

Setup Tabby on WSL

What is tabby? Tabby is a free, locally running alternative for GitHub Copilot. If you have an Nvidia GPU, you can run it with significant acceleration. Currently, it supports only a few programming languages, but if you use one of these, you can use all the benefits of AI-assisted code completion for free. You can choose different models with different sizes to better fit your hardware.

Preparations

First of all, make sure that you are running Windows 10 or newer, have the latest drivers for your GPU, and have installed WSL 2. This tutorial uses Ubuntu 22.04.2 LTS as a guest OS. On guest OS, you need to install the following things:

NVidia toolkit

Make sure you pick the right version of the toolkit. Then follow the instructions. image

Building a local executable file

First, ensure all listed below are installed correctly and your system is ready.

  1. Rust is installed, and $HOME/.cargo/bin in your path
  2. Nvidia toolkit is installed, and you have a cuda compiler /usr/local/cuda/bin/nvcc

Getting Tabby's code

Follow the instructions in the Contributing section.

Building executable

Tabby is using the Cuda compiler to build a part requiring GPU acceleration so make sure you have the CUDACXX environment variable set before you start to compile.

export CUDACXX=/usr/local/cuda/bin/nvcc

Now, we can build an executable like this:

cargo build --features cuda --release --package tabby

After the build, you can copy your executable to your preferred location. For example:

cp target/release/tabby ~/.local/bin/

Make sure $HOME/.local/bin in your PATH.

Running

Now you can run the Tabby server.

tabby serve --model TabbyML/StarCoder-3B --device cuda

Other models

If this model is too big or your hardware can handle a larger one, go to the models registry tutorial to pick the right one.

Known issues

  • /usr/lib/wsl/lib/libcuda.so.1 is not a symbolic link - solution
@jhueg
Copy link

jhueg commented Jan 31, 2024

Hi,
first of all thank you for this guide!

Sadly the build fails because: Could NOT find CUDAToolkit (missing: CUDA_CUDART) (found version "12.3.107")

Full build error error: failed to run custom build command for `llama-cpp-bindings v0.7.0 (/home/jhueg/dev/tabby/crates/llama-cpp-bindings)`

Caused by:
process didn't exit successfully: /home/jhueg/dev/tabby/target/release/build/llama-cpp-bindings-5bc8af12f7cb8f57/build-script-build (exit status: 101)
--- stdout
cargo:rerun-if-changed=include/engine.h
cargo:rerun-if-changed=src/engine.cc
cargo:rustc-link-lib=llama
cargo:rustc-link-lib=ggml_static
cargo:rustc-link-search=native=/usr/local/cuda/lib64
cargo:rustc-link-lib=culibos
cargo:rustc-link-lib=cuda
cargo:rustc-link-lib=cudart
cargo:rustc-link-lib=cublas
cargo:rustc-link-lib=cublasLt
CMAKE_TOOLCHAIN_FILE_x86_64-unknown-linux-gnu = None
CMAKE_TOOLCHAIN_FILE_x86_64_unknown_linux_gnu = None
HOST_CMAKE_TOOLCHAIN_FILE = None
CMAKE_TOOLCHAIN_FILE = None
CMAKE_GENERATOR_x86_64-unknown-linux-gnu = None
CMAKE_GENERATOR_x86_64_unknown_linux_gnu = None
HOST_CMAKE_GENERATOR = None
CMAKE_GENERATOR = None
CMAKE_PREFIX_PATH_x86_64-unknown-linux-gnu = None
CMAKE_PREFIX_PATH_x86_64_unknown_linux_gnu = None
HOST_CMAKE_PREFIX_PATH = None
CMAKE_PREFIX_PATH = None
CMAKE_x86_64-unknown-linux-gnu = None
CMAKE_x86_64_unknown_linux_gnu = None
HOST_CMAKE = None
CMAKE = None
running: cd "/home/jhueg/dev/tabby/target/release/build/llama-cpp-bindings-f9fd9dfd839d346d/out/build" && CMAKE_PREFIX_PATH="" "cmake" "/home/jhueg/dev/tabby/crates/llama-cpp-bindings/llama.cpp" "-DLLAMA_CUBLAS=ON" "-DCMAKE_POSITION_INDEPENDENT_CODE=ON" "-DCMAKE_INSTALL_PREFIX=/home/jhueg/dev/tabby/target/release/build/llama-cpp-bindings-f9fd9dfd839d346d/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_ASM_COMPILER=/usr/bin/cc" "-DCMAKE_BUILD_TYPE=Release"
-- Unable to find cudart library.
-- Could NOT find CUDAToolkit (missing: CUDA_CUDART) (found version "12.3.107")
-- Using ccache
-- CMAKE_SYSTEM_PROCESSOR: x86_64
-- x86 detected
-- Configuring incomplete, errors occurred!
See also "/home/jhueg/dev/tabby/target/release/build/llama-cpp-bindings-f9fd9dfd839d346d/out/build/CMakeFiles/CMakeOutput.log".

It seems like it finds the CUDA installation, but not CUDA_CUDART. I tried different things i found online, but nothing worked for me.

Do you have an Idea whats wrong or how to fix it?

Many thanks in advance and best regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment