Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add rocm builds and documentation #1012

Merged
merged 41 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
5b0816c
Added rocm builds and documentation
cromefire Dec 10, 2023
1be9c1e
Pulled build improvements from #902
cromefire Dec 10, 2023
8a21760
Fixed build container for rocm build
cromefire Dec 10, 2023
1e3fe32
Install git in rocm container
cromefire Dec 10, 2023
1a1d4da
Fixed github step
cromefire Dec 10, 2023
b701a63
Try to fix if statement
cromefire Dec 10, 2023
82bbf8d
Added more generic dependency installation
cromefire Dec 10, 2023
081a9f3
upgraded rustup action
cromefire Dec 10, 2023
5308d34
Update sccache
cromefire Dec 10, 2023
f50b5af
Try pytorch manylinux image
cromefire Dec 10, 2023
980f3ed
Switched location for toolchain parameter
cromefire Dec 10, 2023
42ad479
Downgraded to deprecated action again
cromefire Dec 10, 2023
a5e69ca
Readded set default step
cromefire Dec 10, 2023
d4d38d7
Merge branch 'main' into rocm-release
cromefire Dec 12, 2023
5be320a
Install minimal rocm on the fly
cromefire Dec 12, 2023
e89ca16
fixed typo in binary name
cromefire Dec 12, 2023
c96853a
Downgraded checkout action
cromefire Dec 12, 2023
97fef46
Use curl to download
cromefire Dec 12, 2023
022548c
Add -y flag to yum
cromefire Dec 12, 2023
f4e99e7
Also install rocblas
cromefire Dec 12, 2023
7ae9d1d
Update release.yml
wsxiaoys Dec 13, 2023
17cfd18
Update release.yml
wsxiaoys Dec 13, 2023
895a2a2
Update prepare_build_environment.sh
wsxiaoys Dec 13, 2023
5c1ea2f
Update prepare_build_environment.sh
wsxiaoys Dec 13, 2023
18df1ba
Update build.rs
wsxiaoys Dec 13, 2023
d17bee0
Update build.rs
wsxiaoys Dec 13, 2023
3113962
Update README.md
wsxiaoys Dec 13, 2023
81f138a
Update website/docs/faq.mdx
wsxiaoys Dec 13, 2023
ab80cda
Update index.md
wsxiaoys Dec 13, 2023
23f2054
Update and rename docker-cuda.yml to docker.yml
wsxiaoys Dec 13, 2023
5202dfe
Delete .github/workflows/docker-rocm.yml
wsxiaoys Dec 13, 2023
f3d793f
Delete rocm.Dockerfile
wsxiaoys Dec 13, 2023
15767a8
Rename cuda.Dockerfile to Dockerfile
wsxiaoys Dec 13, 2023
1ae3822
Update docker.yml
wsxiaoys Dec 13, 2023
e44f48d
Update website/docs/installation/docker.mdx
wsxiaoys Dec 13, 2023
6fc195e
Update website/docs/installation/docker-compose.mdx
wsxiaoys Dec 13, 2023
2c55ee4
Update docker-compose.mdx
wsxiaoys Dec 13, 2023
a1f9589
Update docker-compose.mdx
wsxiaoys Dec 13, 2023
1ed492b
Update docker.mdx
wsxiaoys Dec 13, 2023
f7fe002
Update docker.mdx
wsxiaoys Dec 13, 2023
39a640b
Update website/docs/faq.mdx
wsxiaoys Dec 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
.idea
ci
clients
.github
python
**/target
**/node_modules
website
17 changes: 11 additions & 6 deletions .github/workflows/docker.yml → .github/workflows/docker-cuda.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Create and publish docker image
name: Create and publish CUDA docker image

on:
workflow_dispatch:
Expand Down Expand Up @@ -50,7 +50,10 @@ jobs:

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/[email protected]
uses: docker/[email protected]
with:
# Needed to support OCI annotations
version: v0.12.0

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
Expand Down Expand Up @@ -78,12 +81,14 @@ jobs:

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5.0.0
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/${{ env.IMAGE_NAME }}
ghcr.io/${{ env.IMAGE_NAME }}/cuda
${{ env.IMAGE_NAME }}
${{ env.IMAGE_NAME }}-cuda
# generate Docker tags based on the following events/attributes
tags: |
type=raw,value={{branch}}-{{sha}},enable=${{ startsWith(github.ref, 'refs/heads') }}
Expand All @@ -95,13 +100,14 @@ jobs:
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v3.1.1
uses: docker/build-push-action@v5.1.0
with:
file: Dockerfile
file: cuda.Dockerfile
push: true
context: .
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.labels }}
cache-from: ${{ steps.cache.outputs.cache-from }}
cache-to: ${{ steps.cache.outputs.cache-to }}
build-args: RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}
Expand All @@ -112,4 +118,3 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: tabbyml/tabby

119 changes: 119 additions & 0 deletions .github/workflows/docker-rocm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Create and publish ROCm docker image

on:
workflow_dispatch:
schedule:
- cron: '0 20 */1 * *'
push:
tags:
- 'v*'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}

# If this is enabled it will cancel current running and start latest
cancel-in-progress: true

env:
RUST_TOOLCHAIN: 1.73.0

jobs:
release-docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: true

# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: false
swap-storage: true

- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/[email protected]
with:
# Needed to support OCI annotations
version: v0.12.0

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into GitHub Container registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Log into Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Generate image name
run: |
echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}

- uses: int128/docker-build-cache-config-action@v1
id: cache
with:
image: ghcr.io/${{ env.IMAGE_NAME }}/cache

- name: Docker meta
id: meta
uses: docker/[email protected]
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/${{ env.IMAGE_NAME }}/rocm
${{ env.IMAGE_NAME }}-rocm
# generate Docker tags based on the following events/attributes
variant: rocm
tags: |
type=raw,value={{branch}}-{{sha}},enable=${{ startsWith(github.ref, 'refs/heads') }}
type=schedule,pattern=nightly
type=schedule,pattern={{date 'YYYYMMDD'}}
type=semver,pattern={{version}}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/[email protected]
with:
file: rocm.Dockerfile
push: true
context: .
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.labels }}
cache-from: ${{ steps.cache.outputs.cache-from }}
cache-to: ${{ steps.cache.outputs.cache-to }}
build-args: RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}

- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: tabbyml/tabby
23 changes: 16 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ concurrency:
cancel-in-progress: true

env:
RUST_TOOLCHAIN: 1.73.0
RUST_TOOLCHAIN: 1.80.0

jobs:
release-binary:
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
strategy:
matrix:
binary: [aarch64-apple-darwin, x86_64-manylinux2014, x86_64-manylinux2014-cuda117]
binary: [aarch64-apple-darwin, x86_64-manylinux2014, x86_64-manylinux2014-cuda117, x86_64-manylinux2014-rocm5.7]
include:
- os: macos-latest
target: aarch64-apple-darwin
Expand All @@ -40,27 +40,36 @@ jobs:
binary: x86_64-manylinux2014-cuda117
container: sameli/manylinux2014_x86_64_cuda_11.7
build_args: --features cuda
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
binary: x86_64-manylinux2014-rocm5.7
container: rocm/dev-ubuntu-22.04:5.7-complete
cromefire marked this conversation as resolved.
Show resolved Hide resolved
apt_dependencies: git pkg-config libssl-dev cmake
build_args: --features rocm

env:
SCCACHE_GHA_ENABLED: true
RUSTC_WRAPPER: sccache
CARGO_INCREMENTAL: 0

steps:
- name: Install dependencies
if: ${{ matrix.apt_dependencies }}
run: |
apt-get update
apt-get install -y ${{ matrix.apt_dependencies }}

- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@${{ env.RUST_TOOLCHAIN }}
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
target: ${{ matrix.target }}
targets: ${{ matrix.target }}
components: clippy

- run: rustup default ${{ env.RUST_TOOLCHAIN }}

- name: Sccache cache
uses: mozilla-actions/[email protected]
with:
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,25 @@ You can find our documentation [here](https://tabby.tabbyml.com/docs/getting-sta
- ⚙️ [Configuration](https://tabby.tabbyml.com/docs/configuration)

### Run Tabby in 1 Minute
The easiest way to start a Tabby server is by using the following Docker command:
The easiest way to start a Tabby server is by using the following Docker command...

...with cuda:
```bash
docker run -it \
--gpus all -p 8080:8080 -v $HOME/.tabby:/data \
tabbyml/tabby \
tabbyml/tabby-cuda \
serve --model TabbyML/StarCoder-1B --device cuda
```

...with ROCm (Linux only):
```bash
docker run -it \
--device /dev/dri --device /dev/kfd \
-p 8080:8080 -v $HOME/.tabby:/data \
tabbyml/tabby-rocm \
serve --model TabbyML/StarCoder-1B --device rocm
```

For additional options (e.g inference type, parallelism), please refer to the [documentation page](https://tabbyml.github.io/tabby).

## 🤝 Contributing
Expand Down
10 changes: 6 additions & 4 deletions crates/llama-cpp-bindings/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn main() {
println!("cargo:rustc-link-lib=cublasLt");
}
if cfg!(feature = "rocm") {
let amd_gpu_targets: Vec<&str> = vec![
let amd_gpu_default_targets: Vec<&str> = vec![
"gfx803",
"gfx900",
"gfx906:xnack-",
Expand All @@ -51,6 +51,8 @@ fn main() {
"gfx1102",
"gfx1103",
];
let amd_gpu_targets =
env::var("AMDGPU_TARGETS").unwrap_or(amd_gpu_default_targets.join(";"));

let rocm_root = env::var("ROCM_ROOT").unwrap_or("/opt/rocm".to_string());
config.define("LLAMA_HIPBLAS", "ON");
Expand All @@ -59,7 +61,7 @@ fn main() {
"CMAKE_CXX_COMPILER",
format!("{}/llvm/bin/clang++", rocm_root),
);
config.define("AMDGPU_TARGETS", amd_gpu_targets.join(";"));
config.define("AMDGPU_TARGETS", amd_gpu_targets);
println!("cargo:rustc-link-arg=-Wl,--copy-dt-needed-entries");
println!("cargo:rustc-link-search=native={}/hip/lib", rocm_root);
println!("cargo:rustc-link-search=native={}/rocblas/lib", rocm_root);
Expand All @@ -74,8 +76,8 @@ fn main() {

cxx_build::bridge("src/lib.rs")
.file("src/engine.cc")
.flag_if_supported("-Iinclude")
.flag_if_supported("-Illama.cpp")
.include("include")
.include("llama.cpp")
.flag_if_supported("-std=c++14")
.compile("cxxbridge");
}
2 changes: 1 addition & 1 deletion crates/llama-cpp-bindings/src/llama.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl LlamaServiceImpl {
};

for ffi::StepOutput { request_id, text } in result {
let mut stopped = false;
let mut stopped;
let LlamaRunningRequest { tx, stop_condition } =
self.requests.get_mut(&request_id).unwrap();

Expand Down
3 changes: 2 additions & 1 deletion Dockerfile → cuda.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ RUN curl https://sh.rustup.rs -sSf | bash -s -- --default-toolchain ${RUST_TOOLC
ENV PATH="/root/.cargo/bin:${PATH}"

WORKDIR /root/workspace
COPY . .

RUN mkdir -p /opt/tabby/bin
RUN mkdir -p /opt/tabby/lib
RUN mkdir -p target

COPY . .

RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/root/workspace/target \
cargo build --features cuda --release --package tabby && \
Expand Down
61 changes: 61 additions & 0 deletions rocm.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
ARG UBUNTU_VERSION=22.04
# This needs to generally match the container host's environment.
ARG ROCM_VERSION=5.7
# Target the CUDA build image
ARG BASE_ROCM_DEV_CONTAINER="rocm/dev-ubuntu-${UBUNTU_VERSION}:${ROCM_VERSION}-complete"
# Target the CUDA runtime image
ARG BASE_ROCM_RUN_CONTAINER="rocm/dev-ubuntu-${UBUNTU_VERSION}:${ROCM_VERSION}-complete"

FROM ${BASE_ROCM_DEV_CONTAINER} as build

# Rust toolchain version
ARG RUST_TOOLCHAIN=stable

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl \
pkg-config \
libssl-dev \
protobuf-compiler \
git \
cmake \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# setup rust.
RUN curl https://sh.rustup.rs -sSf | bash -s -- --default-toolchain ${RUST_TOOLCHAIN} -y
ENV PATH="/root/.cargo/bin:${PATH}"

WORKDIR /root/workspace

RUN mkdir -p /opt/tabby/bin
RUN mkdir -p /opt/tabby/lib
RUN mkdir -p target

COPY . .

RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/root/workspace/target \
cargo build --features rocm --release --package tabby && \
cp target/release/tabby /opt/tabby/bin/

FROM ${BASE_ROCM_RUN_CONTAINER} as runtime

RUN apt-get update && \
apt-get install -y --no-install-recommends \
git \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Disable safe directory in docker
# Context: https://github.com/git/git/commit/8959555cee7ec045958f9b6dd62e541affb7e7d9
RUN git config --system --add safe.directory "*"

COPY --from=build /opt/tabby /opt/tabby

ENV TABBY_ROOT=/data

ENTRYPOINT ["/opt/tabby/bin/tabby"]
Loading
Loading