Unverified Commit c47dc6e8 authored by Yang Yong (雍洋)'s avatar Yang Yong (雍洋) Committed by GitHub
Browse files

update docker (#369)

parent ee9d47b0
......@@ -22,7 +22,7 @@ RUN git clone https://github.com/sgl-project/sglang.git && cd sglang/sgl-kernel
&& make build && make clean
RUN pip install --no-cache-dir diffusers transformers tokenizers accelerate safetensors opencv-python numpy imageio \
imageio-ffmpeg einops loguru qtorch ftfy av
imageio-ffmpeg einops loguru qtorch ftfy av decord
RUN conda install conda-forge::ffmpeg=8.0.0 -y && ln -s /opt/conda/bin/ffmpeg /usr/bin/ffmpeg && conda clean -all -y
......
FROM pytorch/pytorch:2.5.1-cuda12.4-cudnn9-devel AS base
FROM pytorch/pytorch:2.6.0-cuda12.4-cudnn9-devel AS base
WORKDIR /app
ENV DEBIAN_FRONTEND=noninteractive
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8
ENV LD_LIBRARY_PATH=/usr/local/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
# use tsinghua source
RUN sed -i 's|http://archive.ubuntu.com/ubuntu/|https://mirrors.tuna.tsinghua.edu.cn/ubuntu/|g' /etc/apt/sources.list \
&& sed -i 's|http://security.ubuntu.com/ubuntu/|https://mirrors.tuna.tsinghua.edu.cn/ubuntu/|g' /etc/apt/sources.list
RUN apt-get update && apt-get install -y vim tmux zip unzip wget git git-lfs build-essential libibverbs-dev ca-certificates \
curl iproute2 libsm6 libxext6 kmod ccache libnuma-dev libssl-dev flex bison libgtk-3-dev libpango1.0-dev \
libsoup2.4-dev libnice-dev libopus-dev libvpx-dev libx264-dev libsrtp2-dev libglib2.0-dev libdrm-dev\
&& apt-get clean && rm -rf /var/lib/apt/lists/* && git lfs install
RUN apt-get update && apt-get install -y vim tmux zip unzip wget git build-essential libibverbs-dev ca-certificates \
curl iproute2 libsm6 libxext6 kmod ccache libnuma-dev \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
RUN pip install --no-cache-dir packaging ninja cmake scikit-build-core uv meson ruff pre-commit fastapi uvicorn requests -U
RUN pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
RUN pip install --no-cache-dir packaging ninja cmake scikit-build-core uv ruff pre-commit -U
RUN git clone https://github.com/vllm-project/vllm.git && cd vllm \
RUN git clone https://github.com/vllm-project/vllm.git -b v0.10.0 && cd vllm \
&& python use_existing_torch.py && pip install -r requirements/build.txt \
&& pip install --no-cache-dir --no-build-isolation -v -e .
RUN git clone https://github.com/sgl-project/sglang.git && cd sglang/sgl-kernel \
RUN git clone https://github.com/sgl-project/sglang.git -b v0.4.10 && cd sglang/sgl-kernel \
&& make build && make clean
RUN pip install --no-cache-dir diffusers transformers tokenizers accelerate safetensors opencv-python numpy imageio \
imageio-ffmpeg einops loguru qtorch ftfy
imageio-ffmpeg einops loguru qtorch ftfy av decord
RUN conda install conda-forge::ffmpeg=8.0.0 -y && ln -s /opt/conda/bin/ffmpeg /usr/bin/ffmpeg
RUN conda install conda-forge::ffmpeg=8.0.0 -y && ln -s /opt/conda/bin/ffmpeg /usr/bin/ffmpeg && conda clean -all -y
RUN git clone https://github.com/Dao-AILab/flash-attention.git --recursive
RUN git clone https://github.com/Dao-AILab/flash-attention.git -b v2.8.3 --recursive
RUN cd flash-attention && python setup.py install && rm -rf build
......@@ -44,4 +40,37 @@ RUN git clone https://github.com/KONAKONA666/q8_kernels.git
RUN cd q8_kernels && git submodule init && git submodule update && python setup.py install && rm -rf build
# cloud deploy
RUN pip install --no-cache-dir aio-pika asyncpg>=0.27.0 aioboto3>=12.0.0 PyJWT alibabacloud_dypnsapi20170525==1.2.2 redis==6.4.0 tos
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
ENV PATH=/root/.cargo/bin:$PATH
RUN cd /opt \
&& wget https://mirrors.tuna.tsinghua.edu.cn/gnu//libiconv/libiconv-1.15.tar.gz \
&& tar zxvf libiconv-1.15.tar.gz \
&& cd libiconv-1.15 \
&& ./configure \
&& make \
&& make install \
&& rm -rf /opt/libiconv-1.15
RUN cd /opt \
&& git clone https://github.com/GStreamer/gstreamer.git -b 1.24.12 --depth 1 \
&& cd gstreamer \
&& meson setup builddir \
&& meson compile -C builddir \
&& meson install -C builddir \
&& ldconfig \
&& rm -rf /opt/gstreamer
RUN cd /opt \
&& git clone https://github.com/GStreamer/gst-plugins-rs.git -b gstreamer-1.24.12 --depth 1 \
&& cd gst-plugins-rs \
&& cargo build --package gst-plugin-webrtchttp --release \
&& install -m 644 target/release/libgstwebrtchttp.so $(pkg-config --variable=pluginsdir gstreamer-1.0)/ \
&& rm -rf /opt/gst-plugins-rs
RUN ldconfig
WORKDIR /workspace
......@@ -5,7 +5,7 @@ RUN cd /opt/lightx2v/deploy/server/frontend \
&& npm install \
&& npm run build
FROM lightx2v/lightx2v:25092201-cu128 AS base
FROM lightx2v/lightx2v:25101501-cu128 AS base
RUN mkdir /workspace/LightX2V
WORKDIR /workspace/LightX2V
......
......@@ -27,16 +27,16 @@ We strongly recommend using the Docker environment, which is the simplest and fa
#### 1. Pull Image
Visit LightX2V's [Docker Hub](https://hub.docker.com/r/lightx2v/lightx2v/tags), select a tag with the latest date, such as `25092201-cu128`:
Visit LightX2V's [Docker Hub](https://hub.docker.com/r/lightx2v/lightx2v/tags), select a tag with the latest date, such as `25101501-cu128`:
```bash
docker pull lightx2v/lightx2v:25092201-cu128
docker pull lightx2v/lightx2v:25101501-cu128
```
We recommend using the `cuda128` environment for faster inference speed. If you need to use the `cuda124` environment, you can use image versions with the `-cu124` suffix:
```bash
docker pull lightx2v/lightx2v:25092201-cu124
docker pull lightx2v/lightx2v:25101501-cu124
```
#### 2. Run Container
......@@ -51,10 +51,10 @@ For mainland China, if the network is unstable when pulling images, you can pull
```bash
# cuda128
docker pull registry.cn-hangzhou.aliyuncs.com/yongyang/lightx2v:25092201-cu128
docker pull registry.cn-hangzhou.aliyuncs.com/yongyang/lightx2v:25101501-cu128
# cuda124
docker pull registry.cn-hangzhou.aliyuncs.com/yongyang/lightx2v:25092201-cu124
docker pull registry.cn-hangzhou.aliyuncs.com/yongyang/lightx2v:25101501-cu124
```
### 🐍 Conda Environment Setup
......
......@@ -27,16 +27,16 @@
#### 1. 拉取镜像
访问 LightX2V 的 [Docker Hub](https://hub.docker.com/r/lightx2v/lightx2v/tags),选择一个最新日期的 tag,比如 `25092201-cu128`
访问 LightX2V 的 [Docker Hub](https://hub.docker.com/r/lightx2v/lightx2v/tags),选择一个最新日期的 tag,比如 `25101501-cu128`
```bash
docker pull lightx2v/lightx2v:25092201-cu128
docker pull lightx2v/lightx2v:25101501-cu128
```
我们推荐使用`cuda128`环境,以获得更快的推理速度,若需要使用`cuda124`环境,可以使用带`-cu124`后缀的镜像版本:
```bash
docker pull lightx2v/lightx2v:25092201-cu124
docker pull lightx2v/lightx2v:25101501-cu124
```
#### 2. 运行容器
......@@ -51,10 +51,10 @@ docker run --gpus all -itd --ipc=host --name [容器名] -v [挂载设置] --ent
```bash
# cuda128
docker pull registry.cn-hangzhou.aliyuncs.com/yongyang/lightx2v:25092201-cu128
docker pull registry.cn-hangzhou.aliyuncs.com/yongyang/lightx2v:25101501-cu128
# cuda124
docker pull registry.cn-hangzhou.aliyuncs.com/yongyang/lightx2v:25092201-cu124
docker pull registry.cn-hangzhou.aliyuncs.com/yongyang/lightx2v:25101501-cu124
```
### 🐍 Conda 环境搭建
......
......@@ -2,6 +2,5 @@ from .flash_attn import *
from .radial_attn import *
from .ring_attn import *
from .sage_attn import *
from .sparge_attn import *
from .torch_sdpa import *
from .ulysses_attn import *
import torch.nn as nn
from loguru import logger
from lightx2v.utils.registry_factory import ATTN_WEIGHT_REGISTER
from .template import AttnWeightTemplate
try:
from spas_sage_attn.autotune import SparseAttentionMeansim
except ImportError:
logger.info("SparseAttentionMeansim not found, please install sparge first")
SparseAttentionMeansim = None
@ATTN_WEIGHT_REGISTER("Sparge")
class SpargeAttnWeight(AttnWeightTemplate):
def __init__(
self,
weight_name,
verbose=False,
l1=0.07,
pv_l1=0.08,
tune_pv=True,
inner_attn_type="flash_attn3",
):
self.verbose = (verbose,)
self.l1 = (l1,)
self.pv_l1 = (pv_l1,)
self.tune_pv = (tune_pv,)
self.inner_attn_type = inner_attn_type
self.inner_cls = SparseAttentionMeansim(l1=l1, pv_l1=pv_l1, tune_pv=tune_pv)
super().__init__(weight_name)
def load(self, weight_dict):
# match all key with prefix weight_name
for key in weight_dict.keys():
if key.startswith(self.weight_name):
sub_name = key.split(".")[-1]
setattr(
self.inner_cls,
sub_name,
nn.Parameter(weight_dict[key], requires_grad=False),
)
def apply(
self,
q,
k,
v,
cu_seqlens_q=None,
cu_seqlens_kv=None,
max_seqlen_q=None,
max_seqlen_kv=None,
model_cls=None,
):
if len(q.shape) == 3:
q = q.unsqueeze(0)
k = k.unsqueeze(0)
v = v.unsqueeze(0)
x = self.inner_cls(q, k, v, tensor_layout="NHD")
x = x.flatten(2)
x = x.squeeze(0)
return x
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment