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

add one-key-start run.sh #18

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@

```bash
# 7B
bash scripts/make-7b.sh
bash run.sh 7b

# 13B
bash scripts/make-13b.sh
# 13B
bash run.sh 13b

# 7B Chinese
bash scripts/make-7b-cn.sh
# 7B Chinese
bash run.sh 7b-cn

# 7B Chinese 4bit
bash scripts/make-7b-cn-4bit.sh
# 7B Chinese 4bit
bash run.sh 7b-cn-4bit
```

2. 选择适合你的命令,从 HuggingFace 下载 LLaMA2 或中文模型:
Expand Down Expand Up @@ -127,13 +127,13 @@ meta-llama

```bash
# 7B
bash scripts/run-7b.sh
# 13B
bash scripts/run-13b.sh
# Chinese 7B
bash scripts/run-7b-cn.sh
# Chinese 7B 4BIT
bash scripts/run-7b-cn-4bit.sh
bash run.sh 7b
# 13B
bash run.sh 13b
# Chinese 7B
bash run.sh 7b-cn
# Chinese 7B 4BIT
bash run.sh 7b-cn-4bit
```

模型运行之后,在浏览器中访问 `http://localhost7860` 或者 `http://你的IP地址:7860` 就可以开始玩了。
Expand Down
28 changes: 14 additions & 14 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ Get started quickly, locally using the 7B or 13B models, using Docker.

```bash
# 7B
bash scripts/make-7b.sh
bash run.sh 7b

# OR 13B
bash scripts/make-13b.sh
# 13B
bash run.sh 13b

# OR 7B Chinese
bash scripts/make-7b-cn.sh
# 7B Chinese
bash run.sh 7b-cn

# OR 7B Chinese 4bit
bash scripts/make-7b-cn-4bit.sh
# 7B Chinese 4bit
bash run.sh 7b-cn-4bit
```

2. Download LLaMA2 Models from HuggingFace, or chinese models.
Expand Down Expand Up @@ -128,13 +128,13 @@ meta-llama

```bash
# 7B
bash scripts/run-7b.sh
# OR 13B
bash scripts/run-13b.sh
# OR Chinese 7B
bash scripts/run-7b-cn.sh
# OR Chinese 7B 4BIT
bash scripts/run-7b-cn-4bit.sh
bash run.sh 7b
# 13B
bash run.sh 13b
# Chinese 7B
bash run.sh 7b-cn
# Chinese 7B 4BIT
bash run.sh 7b-cn-4bit
```

enjoy, open `http://localhost7860` or `http://ip:7860` and play with the LLaMA2!
Expand Down
79 changes: 79 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash

me_path="$(dirname "$(readlink -f "$0")")"

case "$1" in
7b)
image_name=soulteary/llama2
tag_name=7b
docker_file=docker/Dockerfile.7b
# MetaAI LLaMA2 Models (10~14GB vRAM)
mod_url=https://huggingface.co/meta-llama/Llama-2-7b-chat-hf
mod_path=meta-llama
;;
13b)
image_name=soulteary/llama2
tag_name=13b
docker_file=docker/Dockerfile.13b
# MetaAI LLaMA2 Models (10~14GB vRAM)
mod_url=https://huggingface.co/meta-llama/Llama-2-13b-chat-hf
mod_path=meta-llama
;;
7b-cn)
image_name=soulteary/llama2
tag_name=7b-cn
docker_file=docker/Dockerfile.7b-cn
# 或 Chinese LLaMA2 (10~14GB vRAM)
mod_url=https://huggingface.co/LinkSoul/Chinese-Llama-2-7b
mod_path=LinkSoul
;;
7b-cn-4bit)
image_name=soulteary/llama2
tag_name=7b-cn-4bit
docker_file=docker/Dockerfile.7b-cn-4bit
# 或 Chinese LLaMA2 4BIT (5GB vRAM)
mod_url=https://huggingface.co/soulteary/Chinese-Llama-2-7b-4bit
mod_path=soulteary
;;
*)
cat <<EOF
Usage:

$0 7b
$0 7b-cn
$0 7b-cn-4bit
$0 13b

EOF
exit 1
;;
esac
## base image
if docker image ls | grep -q "soulteary/llama2.*base"; then
echo "Found docker image soulteary/llama2:base, skip build."
else
echo "Not found docker image soulteary/llama2:base, build..."
docker build -t soulteary/llama2:base "$me_path" -f docker/Dockerfile.base
fi
## run image
if docker image ls | grep -q "${image_name}.*${tag_name}"; then
echo "Found docker image ${image_name}:${tag_name}, skip build."
else
echo "Not found docker image ${image_name}:${tag_name}, build..."
docker build -t "${image_name}:${tag_name}" "$me_path" -f "$docker_file"
fi
## download model
if [ -d "$me_path/$mod_path" ]; then
echo "Found model path: $me_path/$mod_path, skip download."
else
echo "Not found model path: $me_path/$mod_path, download..."
mkdir -p "$me_path/$mod_path"
git lfs install
git clone "$mod_url" "$me_path/$mod_path/"
fi

## run
docker run --gpus all --rm -it --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 \
-p 7860:7860 \
-v "$me_path/$mod_path":"/app/$mod_path" \
"${image_name}:${tag_name}"
5 changes: 0 additions & 5 deletions scripts/make-13b.sh

This file was deleted.

5 changes: 0 additions & 5 deletions scripts/make-7b-cn-4bit.sh

This file was deleted.

5 changes: 0 additions & 5 deletions scripts/make-7b-cn.sh

This file was deleted.

5 changes: 0 additions & 5 deletions scripts/make-7b.sh

This file was deleted.

3 changes: 0 additions & 3 deletions scripts/run-13b.sh

This file was deleted.

3 changes: 0 additions & 3 deletions scripts/run-7b-cn-4bit.sh

This file was deleted.

3 changes: 0 additions & 3 deletions scripts/run-7b-cn.sh

This file was deleted.

3 changes: 0 additions & 3 deletions scripts/run-7b.sh

This file was deleted.