You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/08/10 04:15:33 UTC
[GitHub] [tvm] schell opened a new issue #8700: Metal device error on M1 MBP
schell opened a new issue #8700:
URL: https://github.com/apache/tvm/issues/8700
When loading metal models on my M1 Macbook Pro I see this line print:
```
[14:29:11] ~/tvm/src/runtime/metal/metal_device_api.mm:165: Intializing Metal device 0, name=Apple M1
```
and then quickly thereafter I get this failed check/error:
```
Check failed: (dev.device_id >= 0 && static_cast<size_t>(dev.device_id) < devices.size()) is false: Invalid Metal device_id=0
```
Looking at the code in tvm/src/runtime/metal/metal_device_api.mm it seems that this check should absolutely not fail if I have a device at all, which I know I do based on the line printed just before the check.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] echuraev commented on issue #8700: Metal device error on M1 MBP
Posted by GitBox <gi...@apache.org>.
echuraev commented on issue #8700:
URL: https://github.com/apache/tvm/issues/8700#issuecomment-904706891
Hello @schell!
I took a look at your problem and I'm not able to reproduce the issue. I tried on Apple M1 and x86. And on both machines everything works fine. Could you please provide more details about your problem? Maybe some simple scripts which reproduces the issue or something like that?
I used the following simple script for running some simple model on metal:
```python
import numpy as np
import math
import os
import tvm
from tvm import relay, auto_scheduler
from tvm import testing
from tvm.contrib import utils, xcode, coreml_runtime, graph_runtime
target = "metal"
target_host = "llvm -mtriple=arm64-apple-darwin20.5.0"
def _get_model(shape, dtype, var_names):
"""Return a model and any parameters it may have."""
a = relay.var(next(var_names), shape=shape, dtype=dtype)
out = relay.op.reduce.mean(a, 0)
params = {}
return out, params
def converter(shape):
print("Shape: {}".format(shape))
dtype = "float32"
# b, data
inputs = {"data": tvm.nd.array(np.random.uniform(-128, 127, shape).astype(dtype))}
mod, params = _get_model(shape, dtype, iter(inputs))
if isinstance(mod, tvm.relay.expr.Call):
mod = tvm.IRModule.from_expr(mod)
print('mod: ', mod)
with tvm.transform.PassContext(opt_level=3):
graph_module = relay.build(mod['main'], target=target, target_host=target_host, params=params)
#with auto_scheduler.ApplyHistoryBest("my_mean_model_metal"):
# with tvm.transform.PassContext(opt_level=3, config={"relay.backend.use_auto_scheduler": True}):
# graph_module = relay.build(mod['main'], target=target, target_host=target_host, params=params)
return graph_module
def run(graph_module):
ctx = tvm.metal(0)
m = graph_runtime.graph_executor.GraphModule(graph_module["default"](ctx))
m.run()
if __name__ == "__main__":
shape = (2, 1)
gm = converter(shape)
run(gm)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] masahi commented on issue #8700: Metal device error on M1 MBP
Posted by GitBox <gi...@apache.org>.
masahi commented on issue #8700:
URL: https://github.com/apache/tvm/issues/8700#issuecomment-895754460
cc @echuraev
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org