1,关于autodl
AutoDL的目标是为用户提供稳定可靠、价格公道的GPU算力,让GPU不再是您成为数据科学家道路上的拦路石。
网站地址:
https://www.autodl.com/home
1,关于Xinference
Xorbits Inference (Xinference) 是一个开源平台,用于简化各种 AI 模型的运行和集成。借助 Xinference,您可以使用任何开源 LLM、嵌入模型和多模态模型在云端或本地环境中运行推理,并创建强大的 AI 应用。
https://inference.readthedocs.io/zh-cn/latest/
最新版本已经支持了cogvideox-5b模型了:
https://www.modelscope.cn/models/zhipuai/cogvideox-5b
【xinference】(18):在4090设备上通过Xinference框架,快速部署CogVideoX-5b模型,可以生成6秒视频,效果还可以,只支持英文,

2,找一个4090D的容器
在autodl 上申请一个容器。需要注意的是使用 python的版本是
镜像

Miniconda conda3
Python 3.10(ubuntu22.04)
Cuda 11.8
然后安装并启动:
sudo apt install -y python3-pip
pip3 install xinference diffusers imageio imageio-ffmpeg
# 设置国内模型地址,下载速度快 10+MB/S
export XINFERENCE_MODEL_SRC=modelscope
export XINFERENCE_HOME=`pwd`/xinf-data
# 首先启动 xinference-local :
# CUDA_VISIBLE_DEVICES=0,1,2
xinference-local --host 0.0.0.0
3,可以通过界面启动CogVideoX-5b了
直接通过界面找到 video的模型:

然后使用默认参数启动就行:

因为24G显卡还是不够,所以要增加启动参数:cpu_offload
xinference launch --model-name CogVideoX-5b --model-type video --cpu_offload True
然后就是慢慢,等待模型下载了:
Downloading: 100%|███████████████████████████████████████████████| 2.53k/2.53k [00:00<00:00, 7.23kB/s]
Downloading: 100%|███████████████████████████████████████████████████| 757/757 [00:00<00:00, 3.09kB/s]
Downloading: 100%|███████████████████████████████████████████████████| 839/839 [00:00<00:00, 2.37kB/s]
Downloading: 100%|███████████████████████████████████████████████████| 782/782 [00:00<00:00, 2.28kB/s]
Downloading: 100%|███████████████████████████████████████████████████| 56.0/56.0 [00:00<00:00, 163B/s]
Downloading: 60%|████████████████████████████▎ | 5.58G/9.24G [06:53<02:57, 22.2MB/s]
模型大小:20G xinf-data/
4,下载完成就可以测试了,使用python代码
直接使用代码生成视频。
视频直接使用base64的文件格式,需要自己保存成 mp4.
目前看只支持英文
from xinference.client import Client
import base64
import time
client = Client("http://0.0.0.0:9997")
model = client.get_model("CogVideoX-5b")
input_text = "an apple"
out = model.text_to_video(input_text)
video_data = base64.b64decode(out['data'][0]['b64_json'])
with open('./'+str(time.time())+'.mp4', 'wb') as fout:
fout.write(video_data)
生成了一个 6 秒的视频,一个旋转的苹果:

5,总结
开源的模型发展的速度还是挺快的。
还是可以做制作一些有意思的视频的。

7857

被折叠的 条评论
为什么被折叠?



