File size: 1,447 Bytes
910e2ad
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash

# Usage:
# ./scripts/app_multigpu_engine.sh GPUS VARIANT MODEL_PATH TASK TEMP GUIDANCE_SCALE VIDEO_GUIDANCE_SCALE RESOLUTION OUTPUT_PATH [IMAGE_PATH] PROMPT

GPUS=$1
VARIANT=$2
MODEL_PATH=$3
TASK=$4
TEMP=$5
GUIDANCE_SCALE=$6
VIDEO_GUIDANCE_SCALE=$7
RESOLUTION=$8
OUTPUT_PATH=$9
shift 9
# Now the remaining arguments are $@

if [ "$TASK" == "t2v" ]; then
    PROMPT="$1"
    IMAGE_ARG=""
elif [ "$TASK" == "i2v" ]; then
    IMAGE_PATH="$1"
    PROMPT="$2"
    IMAGE_ARG="--image_path $IMAGE_PATH"
else
    echo "Invalid task: $TASK"
    exit 1
fi

# Get the directory where the script is located
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Get the project root directory (parent directory of scripts)
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"

# Set PYTHONPATH to include the project root directory
export PYTHONPATH="$PROJECT_ROOT:$PYTHONPATH"

# Adjust the path to app_multigpu_engine.py
PYTHON_SCRIPT="$SCRIPT_DIR/app_multigpu_engine.py"

torchrun --nproc_per_node="$GPUS" \
    "$PYTHON_SCRIPT" \
    --model_path "$MODEL_PATH" \
    --variant "$VARIANT" \
    --task "$TASK" \
    --model_dtype bf16 \
    --temp "$TEMP" \
    --sp_group_size "$GPUS" \
    --guidance_scale "$GUIDANCE_SCALE" \
    --video_guidance_scale "$VIDEO_GUIDANCE_SCALE" \
    --resolution "$RESOLUTION" \
    --output_path "$OUTPUT_PATH" \
    --prompt "$PROMPT" \
    $IMAGE_ARG