Hello. I’m trying to use auto scheduling to tune the YOLOv11n model. (TVM version: v0.19.0)
When I start the auto scheduling process, it runs fine at first but eventually causes the system to freeze.
After rebooting the system, running the auto scheduler again allows it to pass the previous freeze point, but it eventually freezes again after a while.
Below is the script I used in this situation.
# ...
# ===== Get CUDA architecture =====
def get_cuda_target_config():
device = cuda.Device(0)
cc = device.compute_capability()
sm_arch = f"sm_{cc[0]}{cc[1]}"
print(f"Detected CUDA compute capability: {cc} → arch={sm_arch}")
attrs = {
"kind": "cuda",
"arch": sm_arch,
"max_threads_per_block": device.get_attribute(cuda.device_attribute.MAX_THREADS_PER_BLOCK),
"max_shared_memory_per_block": device.get_attribute(cuda.device_attribute.MAX_SHARED_MEMORY_PER_BLOCK),
"thread_warp_size": device.get_attribute(cuda.device_attribute.WARP_SIZE),
}
print("Auto-detected CUDA target config:", attrs)
return tvm.target.Target(attrs)
# TorchScript path
torchscript_path = "yolo11n.torchscript"
# Output path
relay_script_path = "result/auto_schedule/model_relay.txt"
cuda_kernel_path = "result/auto_schedule/model_kernel.cu"
graph_json_path = "result/auto_schedule/deploy_graph.json"
params_path = "result/auto_schedule/deploy_param.params"
shared_lib_path = "result/auto_schedule/deploy_lib.so"
# 1. Load TorchScript
loaded_scripted_model = torch.jit.load(torchscript_path)
# 2. Define input tensor
input_shape = (1, 3, 640, 640)
input_name = "input"
shape_list = [(input_name, input_shape)]
# 3. From TorchScript to Relay IR
mod, params = relay.frontend.from_pytorch(loaded_scripted_model, shape_list)
# Save Relay IR
with open(relay_script_path, "w") as f:
f.write(mod.astext(show_meta_data=False))
print(f"Relay IR is saved to '{relay_script_path}'.")
# 4. Set target
target = get_cuda_target_config()
# 5. Auto schedule
log_file = 'result/auto_schedule/auto_schedule_log.json'
tasks, task_weights = auto_scheduler.extract_tasks(mod['main'], params, target)
tuner = auto_scheduler.TaskScheduler(
tasks,
task_weights,
load_log_file=log_file,
)
tune_option = auto_scheduler.TuningOptions(
num_measure_trials=1000,
runner=auto_scheduler.measure.LocalRunner(timeout=5),
early_stopping=600,
measure_callbacks=[auto_scheduler.RecordToFile(log_file)],
)
tuner.tune(tune_option)
# ...
Does anyone know the reason why this situation occurs and how to solve it?
Also, I’m looking for examples or documentation on auto-scheduling and meta-scheduling. However, I haven’t found any good references yet, so I’m still relying on ChatGPT for guidance.
Any help or suggestions would be greatly appreciated. Thank you!