OpenSora 推理生成視頻
更新時間 2025-08-18 11:45:23
最近更新時間: 2025-08-18 11:45:23
分享文章
本節介紹了智算版集群部署OpenSora推理生成視頻的最佳實踐。
前提條件
已開通包含GPU/NPU的Kubernetes集群。
已安裝智算套件。
集群節點需要訪問公網(需通過公網下載模型)。
背景信息
本文演示如何使用和推理任務生成視頻。
操作步驟
進入云容器引擎控制臺。
點擊左側【集群】進入集群列表。
點擊使用的集群名稱,進入集群。
創建configmap 文本中填入視頻prompt描述(描述內容來自OpenSora官網)。
apiVersion: v1
kind: ConfigMap
metadata:
name: t2v-samples-configmap
namespace: default
data:
t2v_samples.txt: |
A soaring drone footage captures the majestic beauty of a coastal cliff, its red and yellow stratified rock faces rich in color and against the vibrant turquoise of the sea. Seabirds can be seen taking flight around the cliff's precipices. As the drone slowly moves from different angles, the changing sunlight casts shifting shadows that highlight the rugged textures of the cliff and the surrounding calm sea. The water gently laps at the rock base and the greenery that clings to the top of the cliff, and the scene gives a sense of peaceful isolation at the fringes of the ocean. The video captures the essence of pristine natural beauty untouched by human structures.
The video captures the majestic beauty of a waterfall cascading down a cliff into a serene lake. The waterfall, with its powerful flow, is the central focus of the video. The surrounding landscape is lush and green, with trees and foliage adding to the natural beauty of the scene. The camera angle provides a bird's eye view of the waterfall, allowing viewers to appreciate the full height and grandeur of the waterfall. The video is a stunning representation of nature's power and beauty.
A vibrant scene of a snowy mountain landscape. The sky is filled with a multitude of colorful hot air balloons, each floating at different heights, creating a dynamic and lively atmosphere. The balloons are scattered across the sky, some closer to the viewer, others further away, adding depth to the scene. Below, the mountainous terrain is blanketed in a thick layer of snow, with a few patches of bare earth visible here and there. The snow-covered mountains provide a stark contrast to the colorful balloons, enhancing the visual appeal of the scene. In the foreground, a few cars can be seen driving along a winding road that cuts through the mountains. The cars are small compared to the vastness of the landscape, emphasizing the grandeur of the surroundings. The overall style of the video is a mix of adventure and tranquility, with the hot air balloons adding a touch of whimsy to the otherwise serene mountain landscape. The video is likely shot during the day, as the lighting is bright and even, casting soft shadows on the snow-covered mountains.
The vibrant beauty of a sunflower field. The sunflowers, with their bright yellow petals and dark brown centers, are in full bloom, creating a stunning contrast against the green leaves and stems. The sunflowers are arranged in neat rows, creating a sense of order and symmetry. The sun is shining brightly, casting a warm glow on the flowers and highlighting their intricate details. The video is shot from a low angle, looking up at the sunflowers, which adds a sense of grandeur and awe to the scene. The sunflowers are the main focus of the video, with no other objects or people present. The video is a celebration of nature's beauty and the simple joy of a sunny day in the countryside.
A serene underwater scene featuring a sea turtle swimming through a coral reef. The turtle, with its greenish-brown shell, is the main focus of the video, swimming gracefully towards the right side of the frame. The coral reef, teeming with life, is visible in the background, providing a vibrant and colorful backdrop to the turtle's journey. Several small fish, darting around the turtle, add a sense of movement and dynamism to the scene. The video is shot from a slightly elevated angle, providing a comprehensive view of the turtle's surroundings. The overall style of the video is calm and peaceful, capturing the beauty and tranquility of the underwater world.
A vibrant underwater scene. A group of blue fish, with yellow fins, are swimming around a coral reef. The coral reef is a mix of brown and green, providing a natural habitat for the fish. The water is a deep blue, indicating a depth of around 30 feet. The fish are swimming in a circular pattern around the coral reef, indicating a sense of motion and activity. The overall scene is a beautiful representation of marine life.
A bustling city street at night, filled with the glow of car headlights and the ambient light of streetlights. The scene is a blur of motion, with cars speeding by and pedestrians navigating the crosswalks. The cityscape is a mix of towering buildings and illuminated signs, creating a vibrant and dynamic atmosphere. The perspective of the video is from a high angle, providing a bird's eye view of the street and its surroundings. The overall style of the video is dynamic and energetic, capturing the essence of urban life at night.
A snowy forest landscape with a dirt road running through it. The road is flanked by trees covered in snow, and the ground is also covered in snow. The sun is shining, creating a bright and serene atmosphere. The road appears to be empty, and there are no people or animals visible in the video. The style of the video is a natural landscape shot, with a focus on the beauty of the snowy forest and the peacefulness of the road.
The dynamic movement of tall, wispy grasses swaying in the wind. The sky above is filled with clouds, creating a dramatic backdrop. The sunlight pierces through the clouds, casting a warm glow on the scene. The grasses are a mix of green and brown, indicating a change in seasons. The overall style of the video is naturalistic, capturing the beauty of the landscape in a realistic manner. The focus is on the grasses and their movement, with the sky serving as a secondary element. The video does not contain any human or animal elements.
A serene night scene in a forested area. The first frame shows a tranquil lake reflecting the star-filled sky above. The second frame reveals a beautiful sunset, casting a warm glow over the landscape. The third frame showcases the night sky, filled with stars and a vibrant Milky Way galaxy. The video is a time-lapse, capturing the transition from day to night, with the lake and forest serving as a constant backdrop. The style of the video is naturalistic, emphasizing the beauty of the night sky and the peacefulness of the forest.創建pvc(用來存儲模型生成的視頻)
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: video-volume
namespace: default
labels:
app: video-volume
spec:
storageClassName: "cstor-csi-hpfs-perf-sc"
accessModes:
- ReadWriteMany
resources:
requests:
storage: 512Gi點擊左側【工作負載】->【自定義資源】,選擇資源瀏覽器,找到kubeflow.org/v1/PyTorchJob ,選擇命名空間,點擊新增。
在創建yaml中,填入以下信息后點擊【創建】。
注意
1.GPU和昇騰NPU申請資源類型不一樣,請使用對應的模板;
2.修改對應的鏡像倉庫地址前綴為對應資源池,可在容器鏡像控制臺查看,如武漢41,則修改{image_repo}為registry-vpc-crs-wuhan41.daliqc.cn;
3. namespace: 要和界面選擇的一致。
GPU模板
apiVersion: "kubeflow.org/v1"
kind: PyTorchJob
metadata:
name: pytorch-opensora-01
namespace: default
spec:
pytorchReplicaSpecs:
Master:
replicas: 1
restartPolicy: OnFailure
template:
spec:
containers:
- name: pytorch
image: {image_repo}/icce/open-sora:multi
imagePullPolicy: IfNotPresent
command: ["/bin/bash", "-c"]
args: ["torchrun --standalone --nproc_per_node 1 scripts/inference.py configs/opensora/inference/16x512x512.py --ckpt-path OpenSora-v1-HQ-16x512x512.pth --prompt-path /workspace/assets/texts/t2v_samples.txt --save-dir /outputs/samples"]
resources:
limits:
nvidia.com/gpu: 1
volumeMounts:
- name: t2v-sample
mountPath: "/workspace/assets/texts"
readOnly: true
- name: video-output
mountPath: /outputs/samples
volumes:
- name: t2v-sample
configMap:
name: t2v-samples-configmap
- name: video-output
persistentVolumeClaim:
claimName: video-volumeNPU模板
apiVersion: "kubeflow.org/v1"
kind: PyTorchJob
metadata:
name: pytorch-opensora-npu-01
namespace: default
spec:
pytorchReplicaSpecs:
Master:
replicas: 1
restartPolicy: OnFailure
template:
spec:
containers:
- name: pytorch
image: {image_repo}/icce/open-sora:multi
imagePullPolicy: IfNotPresent
command: ["/bin/bash", "-c"]
args: ["source /usr/local/Ascend/ascend-toolkit/set_env.sh && bash scripts/text_condition/npu/sample_t2v_v1_3.sh "]
resources:
limits:
huawei.com/Ascend910: 1
volumeMounts:
- name: ascend-driver
mountPath: /usr/local/Ascend/driver
- name: t2v-sample
mountPath: "/workspace/assets/texts"
readOnly: true
- name: video-output
mountPath: /outputs/samples
volumes:
- name: ascend-driver
hostPath:
path: /usr/local/Ascend/driver
- name: t2v-sample
configMap:
name: t2v-samples-configmap
- name: video-output
persistentVolumeClaim:
claimName: video-volume查看運行狀態:點擊左側【工作負載】->【容器組】,找到任務名為前綴的容器,點擊名稱,查看日志/監控等信息是否符合預期。
查看生成視頻:可自行創建pod,掛載上述的pvc,導出/查看生成視頻。
查看根據prompt生成的視頻效果。