開源通義萬相本地部署方案,文生視頻、圖生視頻、視頻生成大模型,支持消費級顯卡!
萬相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/
wan_2.1_vae.safetensors
地址: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 模型就相當不錯。
Json 格式的工作流
輸入圖像可以在通量頁面上找到。
以下是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 mainjson_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_wheelreturn 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_wheelreturn 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_requiresself.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_setupsuper().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_setupexec(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-errorGetting requirements to build wheel did not run successfully.
exit code: 1See 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_attnUsing cached https://mirrors.aliyun.com/pypi/packages/11/34/9bf60e736ed7bbe15055ac2dab48ec67d9dbd088d2b4ae318fd77190ab4e/flash_attn-2.7.4.post1.tar.gz (6.0 MB)Installing build dependencies ... doneGetting requirements to build wheel ... errorerror: 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 mainjson_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_wheelreturn 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_wheelreturn 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_requiresself.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_setupsuper().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_setupexec(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技術感興趣,那可千萬別錯過。
寫文不易,如果你都看到了這里,請點個贊和在看,分享給更多的朋友;也別忘了關注星哥玩云!這里有滿滿的干貨分享,還有輕松有趣的技術交流~點個贊、分享給身邊的小伙伴,一起成長,一起玩轉技術世界吧! 😊