Tune a RISC-V model


I want to tune my model that should finally run on a RISC-V, but unfortunately it cannot find any valid schedule. I get always following output of the tuning process:

[[Task  3/ 3]  Current/Best:    0.00/   0.00 GFLOPS | Progress: (16/20) | 33.15 s[20:35:04]     /home/joschi/Documents/Repos/tvm/src/target/llvm/codegen_llvm.cc:168: Warning: Set native vector bits to be 128 for riscv64
[20:35:04] /home/joschi/Documents/Repos/tvm/src/target/llvm/codegen_llvm.cc:168: Warning: Set native vector bits to be 128 for riscv64
[20:35:04] /home/joschi/Documents/Repos/tvm/src/target/llvm/codegen_llvm.cc:168: Warning: Set native vector bits to be 128 for riscv64
[20:35:04] /home/joschi/Documents/Repos/tvm/src/target/llvm/codegen_llvm.cc:168: Warning: Set native vector bits to be 128 for riscv64
[Task  3/ 3]  Current/Best:    0.00/   0.00 GFLOPS | Progress: (20/20) | 42.36 s Done.

I have following setup:

On my risc-v the tvm_rpc server is running.

./tvm_rpc server --tracker= --key=nexys

On my host machine a rpc_tracker is running:

python -m tvm.exec.rpc_tracker --host= --port=9190

The tuning process is similar to the one in the documentation:

device_key ="nexys"
runner = autotvm.RPCRunner(
tuning_option = {
    "tuner": "xgb",
    "trials": 20,
    "early_stopping": None,
    "measure_option": autotvm.measure_option(
    "tuning_records": "autotuning.json",
tasks = autotvm.task.extract_from_program(mod["main"], target=target, params=params)
# Tune the extracted tasks sequentially.
for i, task in enumerate(tasks):
    prefix = "[Task %2d/%2d] " % (i + 1, len(tasks))
    tuner_obj = XGBTuner(task, loss_type="rank")
        n_trial=min(tuning_option["trials"], len(task.config_space)),
            autotvm.callback.progress_bar(tuning_option["trials"], prefix=prefix),
with autotvm.apply_history_best(tuning_option["tuning_records"]):
    with tvm.transform.PassContext(opt_level=3, config={}):
        lib = relay.build(mod, target=target, params=params)

It seems that something is happening between those three components. At least I am getting an output on the riscv (tvm_rpc server) image

I also notices that in /tmp an error log file was created. Maybe this will help you as well somehow.

Thank you very much.

BR Josef

Hey Josef,

It looks like from this error that g++ isn’t installed on the target device. Possible to install that there, or is the footprint too small?

You might also try changing build_func to cc.cross_compile or cc.create_shared if it’s not possible to add g++ to the target.


Yeah you were right, g++ was not installed. Took some time to install it on my slow platform :wink: It definitely helped, because I got now more useful output. Additionally the g++ error in the tvm_tuning_error file is gone.

But still there is an error in the tvm_tuning_errors file, but maybe I can fix this with your second approach. I didn’t had time yet to try this out. I will inform you if this will work or not.

Thanks BR Josef

PS: For your interests: This is the current issue, but as mentioned, maybe this will be gone when I try your approach.

I can’t quite tell what the error is you’re seeing, but since it’s inside RPCTimeEvaluator and then AsycCallFunc on the server, it’s likely that the operator implementation is throwing some kind of exception or causing a crash.