开源通义万相本地部署方案,文生视频、图生视频、视频生成大模型,支持消费级显卡!
万相2.1开源
近日,大模型万相2.1(Wan)重磅开源,此次开源采用Apache2.0协议,14B和1.3B两个参数规格的全部推理代码和权重全部开源,同时支持文生视频和图生视频任务,全球开发者可在Github、HuggingFace、魔搭社区下载体验。
此次开源的两个参数版本模型:
14B版本万相模型
14B版本万相模型在指令遵循、复杂运动生成、物理建模、文字视频生成等方面表现突出,在权威评测集Vbench中,万相2.1以总分86.22%大幅超越Sora、Luma、Pika等国内外模型,稳居榜首位置。
1.3B版本
1.3B版本万相模型不仅超过了更大尺寸的开源模型,甚至还和一些闭源的模型结果接近,同时能在消费级显卡运行,仅需8.2GB显存就可以生成480P视频,适用于二次模型开发和学术研究。
开源社区链接
Github: https://github.com/Wan-Video/Wan2.1
HuggingFace: https://huggingface.co/Wan-AI
魔搭社区:https://modelscope.cn/organization/Wan-AI
通义万相:https://tongyi.aliyun.com/wanxiang/videoCreation
本地搭建
硬件介绍
本测试的硬件
系统:Windows11专业版
CPU: 英特尔I7-13700KF
内存: 32G
硬盘:1T nvme +4T 机械
显卡:RTX 4070 Ti
搭建说明
起初按照官方推荐的方案搭建
搭建方案一
1.下载安装ComfyUI
一键安装包 :
【点击前往 】https://www.comfy.org/ 支持 Windows 和 mac 系统,我这里下载Windows系统的
选择GPU
安装位置,一般默认,如果C盘空间不够,可以改成其他位置
我这里改成D盘,D:\AI\ComfyUI
其他默认
点击安装即可
安装完成之后,点击下载模型。
2.下载文本编码器和 VAE
下载umt5_xxl_fp8_e4m3fn_scaled.safetensors ,
地址:https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/tree/main/split_files/text_encoders
如果显卡显存低于8G选择下载:“umt5_xxl_fp8_e4m3fn_scaled.safetensors”,如果你的显卡显存大于12G可以选择“umt5_xxl_fp16.safetensors”。
我这演示下载,umt5_xxl_fp8_e4m3fn_scaled.safetensors
将下载好的文件放入:ComfyUI/models/text_encoders/
地址:https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/blob/main/split_files/vae/wan_2.1_vae.safetensors
放入:ComfyUI/models/vae/
**3、**下载视频生成模型
【点击下载】地址:https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/tree/main/split_files/diffusion_models
注意:建议使用 fp16 版本而不是 bf16 版本,因为它们会产生更好的结果。
质量等级(从高到低):fp16 > bf16 > fp8_scaled > fp8_e4m3fn
根据你自己的电脑配置选择。
我这里演示下载“wan2.1_t2v_1.3B_fp16.safetensors”
这些文件位于:ComfyUI/models/diffusion_models/
这些示例使用 16 位文件,但如果内存不足,则可以使用 fp8 文件。
4、文字转视频工作流
下载 Json 格式的工作流,地址:https://comfyanonymous.github.io/ComfyUI_examples/wan/text_to_video_wan.json
5.导入工作流
重启 ComfyUI
默认的提示词,点击执行按钮。
修改提示词,生成视频,以下图片为wan2.1生成的。
关键字
一位时尚的女士在充满温暖发光的霓虹灯和动画城市标志的东京街道上行走。她穿着黑色皮夹克,一条长红裙和黑色靴子,背着黑色手提包。她戴着太阳镜和红色口红。她走路自信而随意。街道潮湿而具有反射性,营造出五光十色灯光的镜面效果。许多行人在四处走动。
再让deepseek生成一些提示词
美女滑雪
场景:雪山、滑雪道
主角:一位年轻女性,穿着时尚的滑雪服
动作:她快速下坡、做出流畅的转弯动作,偶尔做一些高难度的跳跃或花式动作
环境:阳光明媚,雪地反射出耀眼的光芒,远处是白雪覆盖的山脉,滑雪道上还有其他滑雪者
情感:展现出她的自信、优雅和速度感,镜头捕捉她兴奋和专注的表情
音乐:动感的电子音乐或极限运动风格的背景音乐
细节:镜头可以聚焦她的滑雪装备,或者快速转场展示她与雪地环境的互动。
小猫跳舞
场景:温馨的家中环境,阳光透过窗户照进房间,地板干净整洁
主角:一只可爱的小猫,毛茸茸的,颜色可以是橙色、黑白相间或其他可爱配色
动作:小猫随着音乐的节奏轻巧地跳舞,做出小范围的旋转、摆动或是可爱的舞步,甚至可能用爪子打节奏
环境:房间里可能有玩具球、毯子等小猫常见的物品,增添趣味性
音乐:欢快的、轻松的背景音乐,适合小猫的动作和气氛,可以是一些童趣或电子风格的旋律
情感:表现出小猫调皮、活泼的一面,配合镜头捕捉它快乐、专注、或者搞怪的表情
细节:可以特写小猫的脚步或尾巴的摆动,展示其动作的协调性和可爱程度,偶尔做些搞笑或意外的动作来增加趣味性。
图生视频
下载wan2.1_i2v_480p_14B_fp16.safetensors文件
地址: https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/tree/main/split_files/diffusion_models
根据自己的显存大小选择,我这里选择小一点的 wan2.1_t2v_1.3B_bf16.safetensors
将其放入:ComfyUI/models/diffusion_models/
下载 clip_vision_h.safetensors 文件
地址:https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/blob/main/split_files/clip_vision/clip_vision_h.safetensors
放入:ComfyUI/models/clip_vision/
请注意,此示例仅生成 512×512 的 33 帧,因为我希望它易于访问,但模型可以做的不止这些。如果您有硬件/耐心运行它,720p 模型就相当不错。
输入图像可以在通量页面上找到。
以下是720p 型号的相同示例:
山羊打架
原图:
生成之后的视频(截图)
搭建方案二
由于方案二搭建方案一直报错,这种方法不推荐,仅作为笔者记录采坑!
1.安装Python
去python官网下载:
https://www.python.org/downloads/
我这边下载的是 python-3.13.2-amd64.exe
安装python
勾选下面两项,再点击 install now,安装软件。
2.Python换成国内源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/
在命令行中执行:
3.克隆项目Wan2.1
克隆项目
git clone https://github.com/Wan-Video/Wan2.1.git
cd Wan2.1
安装依赖
Install dependencies:
查看版本:
pip --version
pip 24.3.1
# Ensure torch >= 2.4.0
pip install -r requirements.txt
报错1:
---------------------------------------- 1.3/1.3 MB 506.7 kB/s eta 0:00:00
Collecting imageio-ffmpeg (from -r requirements.txt (line 13))
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/2c/c6/fa760e12a2483469e2bf5058c5faff664acf66cadb4df2ad6205b016a73d/imageio_ffmpeg-0.6.0-py3-none-win_amd64.whl (31.2 MB)
-------------------------------------- 31.2/31.2 MB 565.4 kB/s eta 0:00:00
Collecting flash_attn (from -r requirements.txt (line 14))
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/11/34/9bf60e736ed7bbe15055ac2dab48ec67d9dbd088d2b4ae318fd77190ab4e/flash_attn-2.7.4.post1.tar.gz (6.0 MB)
---------------------------------------- 6.0/6.0 MB 872.1 kB/s eta 0:00:00
ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-8t1fvex0\\flash-attn_355b4bf0645846d5946da128691050af\\csrc\\composable_kernel\\client_example\\24_grouped_conv_activation\\grouped_convnd_fwd_scaleadd_scaleadd_relu\\grouped_conv_fwd_scaleadd_scaleadd_relu_bf16.cpp'
HINT: This error might have occurred since this system does not have Windows Long Path support enabled. You can find information on how to enable this at https://pip.pypa.io/warnings/enable-long-paths
[notice] A new release of pip is available: 24.3.1 -> 25.0.1
[notice] To update, run: python.exe -m pip install --upgrade pip
解决:
python.exe -m pip install --upgrade pip
pip --version
pip 25.0.1
报错2:
Collecting flash_attn (from -r requirements.txt (line 14))
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/11/34/9bf60e736ed7bbe15055ac2dab48ec67d9dbd088d2b4ae318fd77190ab4e/flash_attn-2.7.4.post1.tar.gz (6.0 MB)
ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-kgnff0x2\\flash-attn_f6b86d432d5f493d9ccd50fb1e950e0e\\csrc\\composable_kernel\\client_example\\24_grouped_conv_activation\\grouped_convnd_fwd_scaleadd_scaleadd_relu\\grouped_conv_fwd_scaleadd_scaleadd_relu_bf16.cpp'
HINT: This error might have occurred since this system does not have Windows Long Path support enabled. You can find information on how to enable this at https://pip.pypa.io/warnings/enable-long-paths
启用Windows长路径支持
从Windows 10版本1607开始,Microsoft引入了对长路径的支持,但需要手动启用。
通过注册表启用长路径支持
按下
Win + R
,打开运行对话框,输入regedit
并回车,打开注册表编辑器。导航到以下路径:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
在右侧窗格中找到名为
LongPathsEnabled
的DWORD值。如果没有,右键单击空白处,选择新建 -> DWORD(32位)值,并命名为LongPathsEnabled
。双击
LongPathsEnabled
,将其值设置为1
。关闭注册表编辑器。
或者,你可以使用以下PowerShell命令(需要管理员权限):
powershell
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
报错3
Getting requirements to build wheel did not run successfully.
exit code: 1
[23 lines of output]
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python313\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 389, in <module>
main()
~~~~^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python313\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 373, in main
json_out["return_val"] = hook(**hook_input["kwargs"])
~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python313\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 143, in get_requires_for_build_wheel
return hook(config_settings)
File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-jbn4g9x9\overlay\Lib\site-packages\setuptools\build_meta.py", line 334, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=[])
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-jbn4g9x9\overlay\Lib\site-packages\setuptools\build_meta.py", line 304, in _get_build_requires
self.run_setup()
~~~~~~~~~~~~~~^^
File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-jbn4g9x9\overlay\Lib\site-packages\setuptools\build_meta.py", line 522, in run_setup
super().run_setup(setup_script=setup_script)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-jbn4g9x9\overlay\Lib\site-packages\setuptools\build_meta.py", line 320, in run_setup
exec(code, locals())
~~~~^^^^^^^^^^^^^^^^
File "<string>", line 22, in <module>
ModuleNotFoundError: No module named 'torch'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
Getting requirements to build wheel did not run successfully.
exit code: 1
See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
查看NVIDIA的版本
下载CUDA Toolkit
https://developer.nvidia.com/cuda-toolkit-archive
安装软件
验证
nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Wed_Oct_30_01:18:48_Pacific_Daylight_Time_2024
Cuda compilation tools, release 12.6, V12.6.85
Build cuda_12.6.r12.6/compiler.35059454_0
安装flash_attn
pip install flash_attn -i https://mirrors.aliyun.com/pypi/simple/
遇到报错:
pip install flash_attn -i https://mirrors.aliyun.com/pypi/simple/
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting flash_attn
Using cached https://mirrors.aliyun.com/pypi/packages/11/34/9bf60e736ed7bbe15055ac2dab48ec67d9dbd088d2b4ae318fd77190ab4e/flash_attn-2.7.4.post1.tar.gz (6.0 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [23 lines of output]
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python313\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 389, in <module>
main()
~~~~^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python313\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 373, in main
json_out["return_val"] = hook(**hook_input["kwargs"])
~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python313\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 143, in get_requires_for_build_wheel
return hook(config_settings)
File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-1qn6p69k\overlay\Lib\site-packages\setuptools\build_meta.py", line 334, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=[])
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-1qn6p69k\overlay\Lib\site-packages\setuptools\build_meta.py", line 304, in _get_build_requires
self.run_setup()
~~~~~~~~~~~~~~^^
File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-1qn6p69k\overlay\Lib\site-packages\setuptools\build_meta.py", line 522, in run_setup
super().run_setup(setup_script=setup_script)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-1qn6p69k\overlay\Lib\site-packages\setuptools\build_meta.py", line 320, in run_setup
exec(code, locals())
~~~~^^^^^^^^^^^^^^^^
File "<string>", line 22, in <module>
ModuleNotFoundError: No module named 'torch'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
试了很多方法一直报错,放弃了
结束
这就是部署开源通义万相本地部署方案,简直是视频生成领域的一大福音。它降低了使用门槛,让更多人能体验到AI视频生成的乐趣。如果你对视频创作、AI技术感兴趣,那可千万别错过。
写文不易,如果你都看到了这里,请点个赞和在看,分享给更多的朋友;也别忘了关注星哥玩云!这里有满满的干货分享,还有轻松有趣的技术交流~点个赞、分享给身边的小伙伴,一起成长,一起玩转技术世界吧! 😊