Skip to content

Commit ab19801

Browse files
authored
Merge pull request #2 from LJ-Hao/main
update
2 parents 40dfb9a + 4390779 commit ab19801

18 files changed

+727
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/*.so filter=lfs diff=lfs merge=lfs -text

.github/workflow/.gitkeep

Whitespace-only changes.

.github/workflow/RK3576-Deepseek-R1-Distill-Qwen.yml

Whitespace-only changes.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Build and Push DeepSeek-R1-RK3576 Series
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
paths:
7+
- 'src/**'
8+
- 'docker/RK3576/LLM/DeepSeek-R1-Distill-Qwen.dockerfile'
9+
- '.github/workflows/RK3576-Deepseek-R1-Distill-Qwen.yml'
10+
workflow_dispatch:
11+
12+
env:
13+
REGISTRY: ghcr.io
14+
IMAGE_BASE_NAME: ${{ github.repository_owner }}/RK3576-Deepseek-R1-Distill-Qwen
15+
16+
jobs:
17+
build-and-push:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
packages: write
22+
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
include:
27+
- alias: "1.5b-fp16"
28+
file: "DeepSeek-R1-Distill-Qwen-1.5B_FP16_RK3576.rkllm"
29+
url: "https://huggingface.co/JiahaoLi/DeepSeek-R1-Distill-Qwen-RK3576/resolve/main/DeepSeek-R1-Distill-Qwen-1.5B_FP16_RK3576.rkllm"
30+
31+
- alias: "1.5b-w4a16"
32+
file: "DeepSeek-R1-Distill-Qwen-1.5B_W4A16_RK3576.rkllm"
33+
url: "https://huggingface.co/JiahaoLi/DeepSeek-R1-Distill-Qwen-RK3576/resolve/main/DeepSeek-R1-Distill-Qwen-1.5B_W4A16_RK3576.rkllm"
34+
35+
- alias: "1.5b-w4a16-g128"
36+
file: "DeepSeek-R1-Distill-Qwen-1.5B_W4A16_G128_RK3576.rkllm"
37+
url: "https://huggingface.co/JiahaoLi/DeepSeek-R1-Distill-Qwen-RK3576/resolve/main/DeepSeek-R1-Distill-Qwen-1.5B_W4A16_G128_RK3576.rkllm"
38+
39+
- alias: "7b-w4a16"
40+
file: "DeepSeek-R1-Distill-Qwen-7B_W4A16_RK3576.rkllm"
41+
url: "https://huggingface.co/JiahaoLi/DeepSeek-R1-Distill-Qwen-RK3576/resolve/main/DeepSeek-R1-Distill-Qwen-7B_W4A16_RK3576.rkllm"
42+
43+
- alias: "7b-w4a16-g128"
44+
file: "DeepSeek-R1-Distill-Qwen-7B_W4A16_G128_RK3576.rkllm"
45+
url: "https://huggingface.co/JiahaoLi/DeepSeek-R1-Distill-Qwen-RK3576/resolve/main/DeepSeek-R1-Distill-Qwen-7B_W4A16_G128_RK3576.rkllm"
46+
47+
steps:
48+
- name: Checkout repository
49+
uses: actions/checkout@v4
50+
with:
51+
lfs: true
52+
53+
- name: Force LFS Pull
54+
run: |
55+
git lfs install
56+
git lfs pull
57+
58+
- name: Free Disk Space
59+
uses: jlumbroso/free-disk-space@main
60+
with:
61+
tool-cache: true
62+
android: true
63+
dotnet: true
64+
large-packages: true
65+
docker-images: true
66+
67+
- name: Set up QEMU
68+
uses: docker/setup-qemu-action@v3
69+
with:
70+
platforms: arm64
71+
72+
- name: Set up Docker Buildx
73+
uses: docker/setup-buildx-action@v3
74+
75+
- name: Log in to GHCR
76+
uses: docker/login-action@v3
77+
with:
78+
registry: ${{ env.REGISTRY }}
79+
username: ${{ github.actor }}
80+
password: ${{ secrets.GITHUB_TOKEN }}
81+
82+
- name: Extract metadata
83+
id: meta
84+
uses: docker/metadata-action@v5
85+
with:
86+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_BASE_NAME }}
87+
tags: |
88+
type=raw,value=${{ matrix.alias }}-latest
89+
90+
- name: Build and push
91+
uses: docker/build-push-action@v5
92+
with:
93+
context: .
94+
file: ./docker/RK3576/LLM/DeepSeek-R1-Distill-Qwen.dockerfile
95+
# 重要:不指定 target,确保所有指令被执行
96+
push: true
97+
platforms: linux/arm64
98+
provenance: false
99+
build-args: |
100+
MODEL_URL=${{ matrix.url }}
101+
MODEL_FILE=${{ matrix.file }}
102+
tags: ${{ steps.meta.outputs.tags }}
103+
labels: ${{ steps.meta.outputs.labels }}
104+
cache-from: type=gha
105+
cache-to: type=gha,mode=max
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Build and Push DeepSeek-R1-RK3588 Series
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
paths:
7+
- 'src/**'
8+
- 'docker/RK3588/LLM/DeepSeek-R1-Distill-Qwen.dockerfile'
9+
- '.github/workflows/RK3588-Deepseek-R1-Distill-Qwen.yml'
10+
workflow_dispatch:
11+
12+
env:
13+
REGISTRY: ghcr.io
14+
IMAGE_BASE_NAME: ${{ github.repository_owner }}/RK3588-Deepseek-R1-Distill-Qwen
15+
16+
jobs:
17+
build-and-push:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
packages: write
22+
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
include:
27+
- alias: "1.5b-fp16"
28+
file: "DeepSeek-R1-Distill-Qwen-1.5B_FP16_RK3588.rkllm"
29+
url: "https://huggingface.co/JiahaoLi/DeepSeek-R1-Distill-Qwen-RK3588/resolve/main/DeepSeek-R1-Distill-Qwen-1.5B_FP16_RK3588.rkllm"
30+
31+
- alias: "1.5b-w8a8"
32+
file: "DeepSeek-R1-Distill-Qwen-1.5B_W8A8_RK3588.rkllm"
33+
url: "https://huggingface.co/JiahaoLi/DeepSeek-R1-Distill-Qwen-RK3588/resolve/main/DeepSeek-R1-Distill-Qwen-1.5B_W8A8_RK3588.rkllm"
34+
35+
- alias: "7b-w8a8"
36+
file: "DeepSeek-R1-Distill-Qwen-7B_W8A8_RK3588.rkllm"
37+
url: "https://huggingface.co/JiahaoLi/DeepSeek-R1-Distill-Qwen-RK3588/resolve/main/DeepSeek-R1-Distill-Qwen-7B_W8A8_RK3588.rkllm"
38+
39+
steps:
40+
- name: Checkout repository
41+
uses: actions/checkout@v4
42+
with:
43+
lfs: true
44+
45+
- name: Force LFS Pull
46+
run: |
47+
git lfs install
48+
git lfs pull
49+
50+
- name: Free Disk Space
51+
uses: jlumbroso/free-disk-space@main
52+
with:
53+
tool-cache: true
54+
android: true
55+
dotnet: true
56+
large-packages: true
57+
docker-images: true
58+
59+
- name: Set up QEMU
60+
uses: docker/setup-qemu-action@v3
61+
with:
62+
platforms: arm64
63+
64+
- name: Set up Docker Buildx
65+
uses: docker/setup-buildx-action@v3
66+
67+
- name: Log in to GHCR
68+
uses: docker/login-action@v3
69+
with:
70+
registry: ${{ env.REGISTRY }}
71+
username: ${{ github.actor }}
72+
password: ${{ secrets.GITHUB_TOKEN }}
73+
74+
- name: Extract metadata
75+
id: meta
76+
uses: docker/metadata-action@v5
77+
with:
78+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_BASE_NAME }}
79+
tags: |
80+
type=raw,value=${{ matrix.alias }}-latest
81+
82+
- name: Build and push
83+
uses: docker/build-push-action@v5
84+
with:
85+
context: .
86+
file: ./docker/RK3588/LLM/DeepSeek-R1-Distill-Qwen.dockerfile
87+
# 重要:不指定 target,确保所有指令被执行
88+
push: true
89+
platforms: linux/arm64
90+
provenance: false
91+
build-args: |
92+
MODEL_URL=${{ matrix.url }}
93+
MODEL_FILE=${{ matrix.file }}
94+
tags: ${{ steps.meta.outputs.tags }}
95+
labels: ${{ steps.meta.outputs.labels }}
96+
cache-from: type=gha
97+
cache-to: type=gha,mode=max

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
使用下面命令下载并运行推理服务
2+
3+
```
4+
docker pull ghcr.io/lj-hao/rk3588-deepseek-r1-distill-qwen:1.5b-w8a8-latest
5+
6+
docker run -it --name deepseek-r1-1.5b --privileged --net=host --device /dev/dri --device /dev/dma_heap --device /dev/rknpu --device /dev/mali0 -v /dev:/dev ghcr.io/lj-hao/rk3588-deepseek-r1-distill-qwen:1.5b-w8a8-latest
7+
8+
```
9+
10+
使用下面命令来测试:
11+
12+
```
13+
curl http://127.0.0.1:8080/v1/chat/completions -H "Content-Type: application/json" -d '{
14+
"messages": [
15+
{"role": "user", "content": "请解释一下相对论的基本概念。"}
16+
],
17+
"n_keep": 0,
18+
"cache_prompt": false,
19+
"id_slot": 0,
20+
"n_predict": 512,
21+
"stream": true
22+
}'
23+
```
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# 第一阶段:环境准备
2+
FROM python:3.10-slim AS base
3+
4+
RUN apt-get update && \
5+
apt-get install -y wget curl git sudo libgomp1 && \
6+
rm -rf /var/lib/apt/lists/*
7+
8+
WORKDIR /app
9+
RUN mkdir -p /app/models
10+
11+
# 安装依赖
12+
COPY ./src/flask_server_requirements_llm.txt /app/requirements.txt
13+
RUN pip install --no-cache-dir -r /app/requirements.txt
14+
15+
# 拷贝运行时库和工具
16+
COPY ./src/librkllmrt.so /usr/lib/librkllmrt.so
17+
COPY ./src/fix_freq_rk3576.sh /app/fix_freq_rk3576.sh
18+
RUN chmod +x /app/fix_freq_rk3576.sh
19+
20+
# --- 最终阶段 ---
21+
FROM base AS final
22+
ARG MODEL_URL
23+
ARG MODEL_FILE
24+
25+
# 必须在这里重新下载或声明,因为 ARG 在不同阶段不共享
26+
RUN if [ -n "${MODEL_URL}" ]; then \
27+
wget --progress=dot:giga "${MODEL_URL}" -O "/app/models/${MODEL_FILE}"; \
28+
fi
29+
30+
COPY ./src/flask_server_llm.py /app/
31+
32+
# 将 ARG 转为 ENV,这样 CMD 才能读取到
33+
ENV RKLLM_MODEL_PATH=/app/models/${MODEL_FILE}
34+
35+
EXPOSE 8080
36+
37+
CMD ["sh", "-c", "python3 /app/flask_server_llm.py --rkllm_model_path ${RKLLM_MODEL_PATH} --target_platform rk3576"]
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# 第一阶段:环境准备
2+
FROM python:3.10-slim AS base
3+
4+
RUN apt-get update && \
5+
apt-get install -y wget curl git sudo libgomp1 && \
6+
rm -rf /var/lib/apt/lists/*
7+
8+
WORKDIR /app
9+
RUN mkdir -p /app/models
10+
11+
# 安装依赖
12+
COPY ./src/flask_server_requirements_llm.txt /app/requirements.txt
13+
RUN pip install --no-cache-dir -r /app/requirements.txt
14+
15+
# 拷贝运行时库和工具
16+
COPY ./src/librkllmrt.so /usr/lib/librkllmrt.so
17+
COPY ./src/fix_freq_rk3588.sh /app/fix_freq_rk3588.sh
18+
RUN chmod +x /app/fix_freq_rk3588.sh
19+
20+
# --- 最终阶段 ---
21+
FROM base AS final
22+
ARG MODEL_URL
23+
ARG MODEL_FILE
24+
25+
# 必须在这里重新下载或声明,因为 ARG 在不同阶段不共享
26+
RUN if [ -n "${MODEL_URL}" ]; then \
27+
wget --progress=dot:giga "${MODEL_URL}" -O "/app/models/${MODEL_FILE}"; \
28+
fi
29+
30+
COPY ./src/flask_server_llm.py /app/
31+
32+
# 将 ARG 转为 ENV,这样 CMD 才能读取到
33+
ENV RKLLM_MODEL_PATH=/app/models/${MODEL_FILE}
34+
35+
EXPOSE 8080
36+
37+
CMD ["sh", "-c", "python3 /app/flask_server_llm.py --rkllm_model_path ${RKLLM_MODEL_PATH} --target_platform rk3588"]

models/RK3576/LLM/DeepSeek-R1-Distill-Qwen/DeepSeek-R1-Distill-Owen-1.5B_W4A16_G128_RK3576.sh

Whitespace-only changes.

models/RK3576/LLM/DeepSeek-R1-Distill-Qwen/DeepSeek-R1-Distill-Owen-7B_W4A16_G128_RK3576.sh

Whitespace-only changes.

0 commit comments

Comments
 (0)