You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by Heliqi via TVM Discuss <no...@discuss.tvm.ai> on 2020/06/07 13:37:10 UTC

[TVM Discuss] [Troubleshooting] Some questions about Windows


I recently spent two weeks debugging in the Windwos environment and found some problems about AutoTVM.

My env: windows10 intel-CPU ; TVM 0.7dev; python 3.6; LLVM 9.0;

1.On windows, 0.0.0.0 is a non-routable meta-address used to designate an invalid, unknown, or non-applicable target (a ‘no particular address’ place holder). So replace 0.0.0.0 with 127.0.0.1 .
[example](https://github.com/apache/incubator-tvm/blob/aa23e72651453617724412ee263999464031cc29/python/tvm/autotvm/measure/measure_methods.py#L337)

2.On windows,pickle function's closure seems problematic.
```
"..\multiprocessing\reduction.py", line 60, in dump
      ForkingPickler(file, protocol).dump(obj)
Can't pickle local object '_wrap_build_func.<locals>._wrapped'
```
I change the [code](https://github.com/apache/incubator-tvm/blob/aa23e72651453617724412ee263999464031cc29/python/tvm/autotvm/measure/measure_methods.py#L379) to this:
```
def _wrap_build_func(build_func,measure_input, tmp_dir, **kwargs):

    if not hasattr(build_func, "output_format"):
        raise AttributeError("Expect build_func to have the attribute output_format.")
    output_format = build_func.output_format

    tic = time.time()
    try:
            filename = os.path.join(tmp_dir, "tmp_func_%0x.%s" % (
                getrandbits(64), output_format))
            # TODO(tvm-team) consider linline _build_func_common
            func, arg_info = _build_func_common(measure_input, **kwargs)
            func.export_library(filename, build_func)
     except Exception as e:  # pylint: disable=broad-except
          return BuildResult(None, None, e, time.time() - tic)
     return BuildResult(filename, arg_info, None, time.time() - tic)
```
The use of  '_wrap_build_func'  function  also change, but the changes will be minimal.

3.If the windows10 version < 17063, no 'tar' command. My  method:
```
I download the Cygwin and  install tar from it. Then, add it to environment variable.You can use the 'tar' command on Windows Command Prompt.
```  

4.If path on the 'tar' command contain ':' (example 'D;\User\xxx'), need to add the '--force-local'. 
[tar code](https://github.com/apache/incubator-tvm/blob/aa23e72651453617724412ee263999464031cc29/python/tvm/contrib/tar.py#L48)
```
xxxxxxxx
md += [output]
cmd += ["--force-local"]
cmd += ["-C", temp.temp_dir]
cmd += temp.listdir()
xxxxxxxxxx
```

5.On the untar function ['code'](https://github.com/apache/incubator-tvm/blob/aa23e72651453617724412ee263999464031cc29/python/tvm/contrib/tar.py#L65), If the 'tar_file' and 'directory'  path is in 'xxx\\xxx\\xxx' format and '\\' needs to be replaced with '/'. Otherwise,Python failed to execute the tar command.
```
if platform.system() == "Windows":
     if tar_file.find('\\') != -1:
          tar_file = '/'.join(tar_file.split('\\'))
     if directory.find('\\') != -1:
          directory = '/'.join(directory.split('\\'))
```

6.The Windows Socket error 10048 , Address already in use.So add 10048 to the [list](https://github.com/apache/incubator-tvm/blob/aa23e72651453617724412ee263999464031cc29/python/tvm/rpc/server.py#L390)

7.Use the LocalRunner ,after starting the Tracker, server don't connect it.  You need to compile cpp_rpc and start the tvm_rpc.exe.  You also can use process-pool.

8.The basegraphtuner. benchmark_layout_transform is creating tracker and server in a loop,On windows this's a big price to pay.  [code 1](https://github.com/apache/incubator-tvm/blob/aa23e72651453617724412ee263999464031cc29/python/tvm/autotvm/graph_tuner/base_graph_tuner.py#L482) and [code 2](https://github.com/apache/incubator-tvm/blob/aa23e72651453617724412ee263999464031cc29/python/tvm/autotvm/measure/measure_methods.py#L331).

I think we can add some judgment reuse tracker and server.example:
```
def set_task(self, task):
        if self.tracker and server:

            self.task = task
            tracker = Tracker('0.0.0.0', port=9000, port_end=10000, silent=True)
            device_key = '$local$device$%d' % tracker.port
            server = Server('0.0.0.0', port=9000, port_end=10000,
                        key=device_key,
                        use_popen=True, silent=True,
                        tracker_addr=(tracker.host, tracker.port))
            self.key = device_key
            self.host = tracker.host
            self.port = tracker.port

            super(LocalRunner, self).set_task(task)
            self.server = server
            self.tracker = tracker
        return self.server, self.tracker
```

9." Compilation error: lld-link: error: : undefined symbol:  **tvm_main**"

This is a temporary fix, annotation “__tvm_main__”:
https://discuss.tvm.ai/t/make-error-on-windows-when-build-the-dll-json-params/6461/11





---
[Visit Topic](https://discuss.tvm.ai/t/some-questions-about-windows/6900/1) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/11c13342578ec577b834a4519854314f9619c38d9698e86f38106067f77f0bd1).