加速中国大陆地区 docker 镜像 (#575)
* 中国大陆地址镜像适配 * update * 更多说明 * more comments * update docker run cmd * Update README-zh.md * change portpull/586/head
parent
1df9685d09
commit
9e89bd2edb
|
|
@ -0,0 +1,39 @@
|
|||
FROM nvcr.io/nvidia/pytorch:24.07-py3
|
||||
|
||||
EXPOSE 28000
|
||||
|
||||
ENV TZ=Asia/Shanghai
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && apt update && apt install python3-tk -y
|
||||
|
||||
RUN mkdir /app
|
||||
|
||||
WORKDIR /app
|
||||
RUN git clone --recurse-submodules https://github.com/Akegarasu/lora-scripts
|
||||
|
||||
WORKDIR /app/lora-scripts
|
||||
|
||||
# 设置 Python pip 软件包国内镜像代理
|
||||
RUN pip config set global.index-url 'https://pypi.tuna.tsinghua.edu.cn/simple' && \
|
||||
pip config set install.trusted-host 'pypi.tuna.tsinghua.edu.cn'
|
||||
|
||||
# 初次安装依赖
|
||||
RUN pip install xformers==0.0.27.post2 --no-deps && pip install -r requirements.txt
|
||||
|
||||
# 更新 训练程序 stable 版本依赖
|
||||
WORKDIR /app/lora-scripts/scripts/stable
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
# 更新 训练程序 dev 版本依赖
|
||||
WORKDIR /app/lora-scripts/scripts/dev
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
WORKDIR /app/lora-scripts
|
||||
|
||||
# 修正运行报错以及底包缺失的依赖
|
||||
# ref
|
||||
# - https://soulteary.com/2024/01/07/fix-opencv-dependency-errors-opencv-fixer.html
|
||||
# - https://blog.csdn.net/qq_50195602/article/details/124188467
|
||||
RUN pip install opencv-fixer==0.2.5 && python -c "from opencv_fixer import AutoFix; AutoFix()" \
|
||||
pip install opencv-python-headless && apt install ffmpeg libsm6 libxext6 libgl1 -y
|
||||
|
||||
CMD ["python", "gui.py", "--listen"]
|
||||
56
README-zh.md
56
README-zh.md
|
|
@ -82,6 +82,62 @@ git clone --recurse-submodules https://github.com/Akegarasu/lora-scripts
|
|||
|
||||
运行 `bash run_gui.bash`,程序将自动打开 [http://127.0.0.1:28000](http://127.0.0.1:28000)
|
||||
|
||||
### Docker
|
||||
|
||||
#### 编译镜像
|
||||
|
||||
```bash
|
||||
# 国内镜像优化版本
|
||||
# 其中 akegarasu_lora-scripts:latest 为镜像及其 tag 名,根据镜像托管服务商实际进行修改
|
||||
docker build -t akegarasu_lora-scripts:latest -f Dockfile-for-Mainland-China .
|
||||
docker push akegarasu_lora-scripts:latest
|
||||
```
|
||||
|
||||
#### 使用镜像
|
||||
|
||||
> 提供一个本人已打包好并推送到 `aliyuncs` 上的镜像,此镜像压缩归档大小约 `10G` 左右,请耐心等待拉取。
|
||||
|
||||
```bash
|
||||
docker run --gpus all -p 28000:28000 -p 6006:6006 registry.cn-hangzhou.aliyuncs.com/go-to-mirror/akegarasu_lora-scripts:latest
|
||||
```
|
||||
|
||||
或者使用 `docker-compose.yaml` 。
|
||||
|
||||
```yaml
|
||||
services:
|
||||
lora-scripts:
|
||||
container_name: lora-scripts
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile-for-Mainland-China
|
||||
image: "registry.cn-hangzhou.aliyuncs.com/go-to-mirror/akegarasu_lora-scripts:latest"
|
||||
ports:
|
||||
- "28000:28000"
|
||||
- "6006:6006"
|
||||
# 共享本地文件夹(请根据实际修改)
|
||||
#volumes:
|
||||
# - "/data/srv/lora-scripts:/app/lora-scripts"
|
||||
# 共享 comfyui 大模型
|
||||
# - "/data/srv/comfyui/models/checkpoints:/app/lora-scripts/sd-models/comfyui"
|
||||
# 共享 sd-webui 大模型
|
||||
# - "/data/srv/stable-diffusion-webui/models/Stable-diffusion:/app/lora-scripts/sd-models/sd-webui"
|
||||
environment:
|
||||
- HF_HOME=huggingface
|
||||
- PYTHONUTF8=1
|
||||
security_opt:
|
||||
- "label=type:nvidia_container_t"
|
||||
runtime: nvidia
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- driver: nvidia
|
||||
device_ids: ['0']
|
||||
capabilities: [gpu]
|
||||
```
|
||||
|
||||
关于容器使用 GPU 相关依赖安装问题,请自行搜索查阅资料解决。
|
||||
|
||||
## 通过手动运行脚本的传统训练方式
|
||||
|
||||
### Windows
|
||||
|
|
|
|||
Loading…
Reference in New Issue