fix: 修复 TensorRT bindings 问题
- tensorrt_engine.py 添加 pycuda 支持 - CUDA 上下文和流管理 - _is_in_working_hours 支持字符串格式
This commit is contained in:
69
test_inference.py
Normal file
69
test_inference.py
Normal file
@@ -0,0 +1,69 @@
|
||||
"""
|
||||
边缘端运行测试脚本 - 推理测试
|
||||
运行 main.py 并测试 30 秒
|
||||
"""
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
|
||||
def run_test():
|
||||
print("=" * 60)
|
||||
print("边缘端运行测试 - 推理测试")
|
||||
print("=" * 60)
|
||||
print(f"测试时长: 30 秒")
|
||||
print(f"测试时间: {time.strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
print("=" * 60)
|
||||
|
||||
env = os.environ.copy()
|
||||
env['PATH'] = r"C:\Users\16337\miniconda3\envs\yolo;" + env.get('PATH', '')
|
||||
|
||||
cmd = [
|
||||
sys.executable, "main.py"
|
||||
]
|
||||
|
||||
process = subprocess.Popen(
|
||||
cmd,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
text=True,
|
||||
bufsize=1,
|
||||
cwd=os.path.dirname(os.path.abspath(__file__)),
|
||||
env=env
|
||||
)
|
||||
|
||||
output_lines = []
|
||||
start_time = time.time()
|
||||
|
||||
try:
|
||||
while True:
|
||||
line = process.stdout.readline()
|
||||
if not line and process.poll() is not None:
|
||||
break
|
||||
|
||||
if line:
|
||||
output_lines.append(line.strip())
|
||||
print(line.strip())
|
||||
|
||||
elapsed = time.time() - start_time
|
||||
if elapsed >= 30:
|
||||
print(f"\n[INFO] 测试达到 30 秒,停止进程...")
|
||||
process.terminate()
|
||||
try:
|
||||
process.wait(timeout=5)
|
||||
except subprocess.TimeoutExpired:
|
||||
process.kill()
|
||||
break
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("\n[INFO] 用户中断测试")
|
||||
process.terminate()
|
||||
|
||||
return output_lines
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_test()
|
||||
print("\n" + "=" * 60)
|
||||
print("测试完成")
|
||||
print("=" * 60)
|
||||
Reference in New Issue
Block a user