Commit 746d7ec0 authored by jerrrrry's avatar jerrrrry
Browse files

Update .gitlab-ci.yml

parent 20752c87
Pipeline #3301 canceled with stage
in 35 seconds
......@@ -14,8 +14,11 @@ benchmark_wan2.1:
- echo "========================================="
- echo "Step 1 Setting up the environment from /workspace/packages/wan2.1"
- echo "========================================="
# 定义预置文件的根目录
- export PACKAGE_DIR="/workspace/packages/wan2.1"
# 从预置目录解压库文件
- tar -xzf "$PACKAGE_DIR/rocblas-install-0910-bug.tar.gz"
# 设置环境变量,模型路径指向预置目录
- export LD_LIBRARY_PATH="$CI_PROJECT_DIR/rocblas-install/lib/:$LD_LIBRARY_PATH"
- pip install -r requirements.txt -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
- ln -s /workspace/packages/wan2.1/Wan_2.1/models/ ./models
......@@ -23,6 +26,7 @@ benchmark_wan2.1:
- echo "========================================="
- echo "Step 2 Setting up ComfyUI directories"
- echo "========================================="
# 创建ComfyUI需要的目录结构
- mkdir -p custom_nodes
- mkdir -p input
- mkdir -p output
......@@ -33,90 +37,227 @@ benchmark_wan2.1:
- echo "========================================="
- echo "Step 3 Starting ComfyUI server"
- echo "========================================="
# 创建日志目录
- mkdir -p logs
# 后台启动ComfyUI服务器并记录日志
- bash run-main.sh > logs/comfyui.log 2>&1 &
# 获取ComfyUI进程ID
- export COMFYUI_PID=$!
- echo "ComfyUI server started with PID $COMFYUI_PID"
- echo "========================================="
- echo "Step 4 Waiting for ComfyUI server to be ready"
- echo "========================================="
- timeout=300
- count=0
- while [ $count -lt $timeout ]; do if grep -q "http://127.0.0.1:8188" logs/comfyui.log; then echo "ComfyUI server is ready!"; break; fi; sleep 1; count=$((count+1)); done
- if [ $count -eq $timeout ]; then echo "Timeout waiting for ComfyUI server to start"; exit 1; fi
# 等待服务器启动,最多等待5分钟
- |
timeout=300
count=0
while [ $count -lt $timeout ]; do
if grep -q "http://127.0.0.1:8188" logs/comfyui.log; then
echo "ComfyUI server is ready!"
break
fi
sleep 1
count=$((count+1))
done
if [ $count -eq $timeout ]; then
echo "Timeout waiting for ComfyUI server to start"
exit 1
fi
- echo "========================================="
- echo "Step 5 Running benchmark tests with precise seed replacement"
- echo "========================================="
# 创建结果目录
- mkdir -p results
# 创建性能日志文件
- touch results/performance.log
# 运行第一次测试(seed=2675441231)
- echo "Running first test with seed=2675441231"
- cp wan_t2v_14B_1_gpu.py temp_test1.py
- sed -i 's/"seed": [0-9]\+,/"seed": 2675441231,/' temp_test1.py
- echo "=== Verifying temp_test1.py seed modification ==="
- if grep -q '"seed": 2675441231,' temp_test1.py; then echo "SUCCESS: Seed 2675441231 set"; grep -n '"seed": 2675441231,' temp_test1.py; else echo "ERROR: Failed to set seed 2675441231"; grep -n "seed" temp_test1.py; exit 1; fi
- start_time=$(date +%s)
- python temp_test1.py > results/test1_output.log 2>&1 &
- export TEST1_PID=$!
- echo "Waiting for first webp file..."
- timeout=600
- count=0
- while [ $count -lt $timeout ]; do webp_count=$(find output -name "*.webp" -type f | wc -l); if [ $webp_count -gt 0 ]; then echo "First webp detected! Count: $webp_count"; break; fi; sleep 2; count=$((count+2)); echo "Waiting... ${count}s elapsed, webp count: $webp_count"; done
- if [ $count -eq $timeout ]; then echo "Timeout waiting for first webp file"; exit 1; fi
- end_time=$(date +%s)
- duration=$((end_time - start_time))
- echo "Test 1 execution time: $duration seconds" >> results/performance.log
- echo "Test 1 completed in $duration seconds"
- |
# 创建第一个测试文件
cp wan_t2v_14B_1_gpu.py temp_test1.py
# 精确替换JSON中的seed值
sed -i 's/"seed": [0-9]\+,/"seed": 2675441231,/' temp_test1.py
# 验证修改是否成功
echo "=== Verifying temp_test1.py seed modification ==="
if grep -q '"seed": 2675441231,' temp_test1.py; then
echo "✓ Seed 2675441231 successfully set in temp_test1.py"
grep -n '"seed": 2675441231,' temp_test1.py
else
echo "✗ Failed to set seed 2675441231 in temp_test1.py"
echo "Current seed lines:"
grep -n "seed" temp_test1.py
exit 1
fi
# 记录开始时间
start_time=$(date +%s)
# 运行测试
python temp_test1.py > results/test1_output.log 2>&1 &
export TEST1_PID=$!
echo "Waiting for first webp file to be generated..."
# 等待第一个webp文件生成,最多等待10分钟
timeout=600
count=0
while [ $count -lt $timeout ]; do
webp_count=$(find output -name "*.webp" -type f | wc -l)
if [ $webp_count -gt 0 ]; then
echo "First webp file detected! Count: $webp_count"
break
fi
sleep 2
count=$((count+2))
echo "Waiting... ${count}s elapsed, webp count: $webp_count"
done
if [ $count -eq $timeout ]; then
echo "Timeout waiting for first webp file"
exit 1
fi
# 记录结束时间和计算执行时间
end_time=$(date +%s)
duration=$((end_time - start_time))
echo "Test 1 execution time $duration seconds" >> results/performance.log
echo "Test 1 completed in $duration seconds"
# 运行第二次测试(seed=1234567890)
- echo "Running second test with seed=1234567890"
- cp wan_t2v_14B_1_gpu.py temp_test2.py
- sed -i 's/"seed": [0-9]\+,/"seed": 1234567890,/' temp_test2.py
- echo "=== Verifying temp_test2.py seed modification ==="
- if grep -q '"seed": 1234567890,' temp_test2.py; then echo "SUCCESS: Seed 1234567890 set"; grep -n '"seed": 1234567890,' temp_test2.py; else echo "ERROR: Failed to set seed 1234567890"; echo "Using Python fallback method"; python3 -c "import re; content=open('temp_test2.py').read(); content=re.sub(r'(\\\"seed\\\":\\s*)\\d+', r'\\g<1>1234567890', content); open('temp_test2.py','w').write(content)"; if grep -q '"seed": 1234567890,' temp_test2.py; then echo "SUCCESS: Seed set using Python method"; grep -n '"seed": 1234567890,' temp_test2.py; else echo "ERROR: All methods failed"; cat temp_test2.py; exit 1; fi; fi
- start_time=$(date +%s)
- python temp_test2.py > results/test2_output.log 2>&1 &
- export TEST2_PID=$!
- echo "Waiting for second webp file..."
- timeout=600
- count=0
- while [ $count -lt $timeout ]; do webp_count=$(find output -name "*.webp" -type f | wc -l); if [ $webp_count -gt 1 ]; then echo "Second webp detected! Total count: $webp_count"; break; fi; sleep 2; count=$((count+2)); echo "Waiting... ${count}s elapsed, webp count: $webp_count"; done
- if [ $count -eq $timeout ]; then echo "Timeout waiting for second webp file"; exit 1; fi
- end_time=$(date +%s)
- duration=$((end_time - start_time))
- echo "Test 2 execution time: $duration seconds" >> results/performance.log
- echo "Test 2 completed in $duration seconds"
- |
# 创建第二个测试文件
cp wan_t2v_14B_1_gpu.py temp_test2.py
# 精确替换JSON中的seed值
sed -i 's/"seed": [0-9]\+,/"seed": 1234567890,/' temp_test2.py
# 验证修改是否成功
echo "=== Verifying temp_test2.py seed modification ==="
if grep -q '"seed": 1234567890,' temp_test2.py; then
echo "✓ Seed 1234567890 successfully set in temp_test2.py"
grep -n '"seed": 1234567890,' temp_test2.py
else
echo "✗ Failed to set seed 1234567890 in temp_test2.py"
echo "Current seed lines:"
grep -n "seed" temp_test2.py
echo "Attempting alternative replacement method..."
# 备用方法:使用Python直接修改
python3 -c "
import re
with open('temp_test2.py', 'r') as f:
content = f.read()
# 使用正则表达式替换seed值
content = re.sub(r'(\"seed\":\s*)\d+', r'\g<1>1234567890', content)
with open('temp_test2.py', 'w') as f:
f.write(content)
"
# 再次验证
if grep -q '"seed": 1234567890,' temp_test2.py; then
echo "✓ Seed 1234567890 successfully set using Python method"
grep -n '"seed": 1234567890,' temp_test2.py
else
echo "✗ All methods failed to set seed 1234567890"
echo "Full file content for debugging:"
cat temp_test2.py
exit 1
fi
fi
# 记录开始时间
start_time=$(date +%s)
# 运行测试
python temp_test2.py > results/test2_output.log 2>&1 &
export TEST2_PID=$!
echo "Waiting for second webp file to be generated..."
# 等待第二个webp文件生成,最多等待10分钟
timeout=600
count=0
while [ $count -lt $timeout ]; do
webp_count=$(find output -name "*.webp" -type f | wc -l)
if [ $webp_count -gt 1 ]; then
echo "Second webp file detected! Total count: $webp_count"
break
fi
sleep 2
count=$((count+2))
echo "Waiting... ${count}s elapsed, webp count: $webp_count"
done
if [ $count -eq $timeout ]; then
echo "Timeout waiting for second webp file"
exit 1
fi
# 记录结束时间和计算执行时间
end_time=$(date +%s)
duration=$((end_time - start_time))
echo "Test 2 execution time $duration seconds" >> results/performance.log
echo "Test 2 completed in $duration seconds"
- echo "========================================="
- echo "Step 6 Verifying and collecting results"
- echo "========================================="
- webp_count=$(find output -name "*.webp" -type f | wc -l)
- echo "Total webp files found: $webp_count"
- if [ $webp_count -lt 2 ]; then echo "ERROR: Expected 2 webp files, but found $webp_count"; find output -name "*.webp" -type f -ls; exit 1; fi
- find output -name "*.webp" -type f -exec ls -lt {} + | head -n 2 > results/latest_files.txt
- cat results/latest_files.txt | awk '{print $NF}' | while read filepath; do cp "$filepath" results/ && echo "Copied: $filepath"; done
- echo "=== Test Results Summary ===" > results/summary.txt
- echo "Test 1 (seed=2675441231):" >> results/summary.txt
- grep "Prompt executed in" results/test1_output.log >> results/summary.txt || echo "No execution time found in test1" >> results/summary.txt
- echo "" >> results/summary.txt
- echo "Test 2 (seed=1234567890):" >> results/summary.txt
- grep "Prompt executed in" results/test2_output.log >> results/summary.txt || echo "No execution time found in test2" >> results/summary.txt
- echo "" >> results/summary.txt
- echo "Generated files:" >> results/summary.txt
- ls results/*.webp >> results/summary.txt || echo "No webp files found in results" >> results/summary.txt
- echo "All tests completed successfully!"
- |
# 验证两个webp文件都已生成
webp_count=$(find output -name "*.webp" -type f | wc -l)
echo "Total webp files found: $webp_count"
if [ $webp_count -lt 2 ]; then
echo "ERROR: Expected 2 webp files, but found $webp_count"
find output -name "*.webp" -type f -ls
exit 1
fi
# 查找并复制最新的两个webp文件
find output -name "*.webp" -type f -exec ls -lt {} + | head -n 2 > results/latest_files.txt
# 复制文件到结果目录
while read line; do
filepath=$(echo "$line" | awk '{print $NF}')
cp "$filepath" results/
echo "Copied: $filepath"
done < results/latest_files.txt
# 创建结果摘要
echo "=== Test Results Summary ===" > results/summary.txt
echo "Test 1 (seed=2675441231):" >> results/summary.txt
grep "Prompt executed in" results/test1_output.log >> results/summary.txt
echo "" >> results/summary.txt
echo "Test 2 (seed=1234567890):" >> results/summary.txt
grep "Prompt executed in" results/test2_output.log >> results/summary.txt
echo "" >> results/summary.txt
echo "Generated files:" >> results/summary.txt
ls results/*.webp >> results/summary.txt
echo "All tests completed successfully!"
- echo "========================================="
- echo "Step 7 Cleaning up"
- echo "========================================="
# 停止ComfyUI服务器
- kill $COMFYUI_PID || true
# 清理临时文件
- rm -f temp_test1.py temp_test2.py
- echo "Cleanup completed"
# 定义产物,保留测试生成的文件
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
paths:
- "results/"
- "logs/"
- "results/*.webp"
- "results/*.log"
- "results/*.txt"
- "logs/comfyui.log"
expire_in: 1 week
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment