# No response when tuning my network

**URL:** <https://discuss.tvm.apache.org/t/no-response-when-tuning-my-network/17686>\
**Category:** Troubleshooting\
**Created:** [September 6, 2024, 1:00pm UTC](https://discuss.tvm.apache.org/t/no-response-when-tuning-my-network/17686 "2024-09-06T13:00:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gaoren002](https://discuss.tvm.apache.org/letter_avatar_proxy/v4/letter/g/9de0a6/32.png) [@gaoren002](https://discuss.tvm.apache.org/u/gaoren002)\
**Post date:** [September 6, 2024, 1:00pm UTC](https://discuss.tvm.apache.org/t/no-response-when-tuning-my-network/17686/1 "2024-09-06T13:00:50Z")

</div>

This is my code，

import onnx

import tvm

from tvm import te

import tvm.relay as relay

from tvm.contrib.download import download\_testdata

from tvm.contrib import graph\_executor

import numpy as np

from tvm import rpc

import os

import torch

jit\_model = torch.jit.load(‘jit\_trace.pt’)

quantize = True

dummy\_input = torch.randn(1, 3, 224, 224).to(“cuda”)

torch.onnx.export(jit\_model, dummy\_input, “model.onnx”,

```
              input_names=['input'],

              output_names=['output'],

               dynamic_axes={'input': {0: 'batch_size'},

                            'output': {0: 'batch_size'}})

```

onnx\_model = onnx.load(“model.onnx”)

input\_name = “input”

input\_shape = (1, 3, 224, 224)

shape\_dict = {input\_name: input\_shape}

mod, params = relay.frontend.from\_onnx(onnx\_model, shape\_dict)

target = tvm.target.Target(“opencl -device=mali”, host=“llvm -mtriple=aarch64-linux-gnu”)

opencl\_device\_host = “192.168.1.115”

opencl\_device\_port = 9092

remote = rpc.connect(opencl\_device\_host, opencl\_device\_port,key=“your\_custom\_key”)

import tvm.autotvm as autotvm

from tvm.autotvm.tuner import XGBTuner

from tvm.autotvm.graph\_tuner import DPTuner, PBQPTuner

tasks = autotvm.task.extract\_from\_program(mod[“main”], target=target, params=params)

tuning\_option = {

```
'log_filename': 'tuning.log',

'tuner': 'xgb',

'n_trial': 5,

'early_stopping': 1,

'measure_option': autotvm.measure_option(

    builder=autotvm.LocalBuilder(timeout=10),

    runner=autotvm.RPCRunner(key="your_custom_key",

    host=opencl_device_host,

    port=opencl_device_port,

    number=20,

    repeat=3,

    timeout=4,

    min_repeat_ms=150

),

),

```

}

import logging

logging.basicConfig(level=logging.DEBUG)

tvm.autotvm.GLOBAL\_SCOPE.silent = False

ctx = remote.cl()

print(“Device initialized:”, ctx)

for i, task in enumerate(tasks):

```
prefix = "[Task %2d/%2d] " % (i+1, len(tasks))

tuner_obj = XGBTuner(task, loss_type="rank")

tuner_obj.tune(

    n_trial=tuning_option['n_trial'],

    early_stopping=tuning_option['early_stopping'],

    measure_option=tuning_option['measure_option'],

    callbacks=[

        autotvm.callback.progress_bar(tuning_option['n_trial'], prefix=prefix),

        autotvm.callback.log_to_file(tuning_option['log_filename']),

    ],

)

```

with autotvm.apply\_history\_best(tuning\_option[‘log\_filename’]):

```
with tvm.transform.PassContext(opt_level=3, config={}):

    lib = relay.build(mod, target=target, params=params)

```

lib.export\_library(“optimized\_model\_opencl.tar”)

remote.upload(“optimized\_model\_opencl.tar”)

lib = remote.load\_module(“optimized\_model\_opencl.tar”)

dev = remote.device(str(target), 0)

module = graph\_executor.GraphModule(lib"default")

input\_data = np.random.uniform(size=input\_shape).astype(“float32”)

module.set\_input(input\_name, input\_data)

module.run()

output = module.get\_output(0).asnumpy()

print(“Output shape:”, output.shape)

print(“Output:”, output)

autotvm.record.pick\_best(tuning\_option[‘log\_filename’], ‘best\_opencl.json’)

print(“Exported optimized model to optimized\_model\_opencl.so”)

print(“Saved best tuning configurations to best\_opencl.json”)

when I run Autotune， it just shows：Device initialized: remote[0]:opencl(0) [Task 1/47] Current/Best: 0.00/ 0.00 GFLOPS | Progress: (0/5) | 0.00 sDEBUG:autotvm:waiting for device… and then no response i could get even a day later. But everything works well if I remove Autotune,
