conda-forge / libtvm-feedstock

A conda-smithy repository for libtvm.
BSD 3-Clause "New" or "Revised" License
0 stars 7 forks source link

compiling against apple metal #14

Closed ngam closed 2 years ago

ngam commented 2 years ago

Follow this to set metal correctly:

https://github.com/conda-forge/deno-feedstock/blob/49611827965b148b4e724b23d4077de17cf4f90b/recipe/meta.yaml#L13-L23

Originally posted by @ngam in https://github.com/conda-forge/libtvm-feedstock/issues/8#issuecomment-1064564774

ngam commented 2 years ago

Hi @isuruf, is the above an okay strategy? Is there a fundamental reason conda-forge's compilers don't have metal support? Thanks!

ngam commented 2 years ago

I obviously can see that it can work. Howeve,r I am not sure yet it actually works for cross-compiling ... I guess we can wait to see if the osx-arm binary of tvm-py works...

ngam commented 2 years ago

Yeeesh. It didn't work... :(

i>>> import tvm
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/ngam/.Mambaforge-MacOSX-arm64/envs/test/lib/python3.10/site-packages/tvm/__init__.py", line 26, in <module>
    from ._ffi.base import TVMError, __version__, _RUNTIME_ONLY
  File "/Users/ngam/.Mambaforge-MacOSX-arm64/envs/test/lib/python3.10/site-packages/tvm/_ffi/__init__.py", line 28, in <module>
    from .base import register_error
  File "/Users/ngam/.Mambaforge-MacOSX-arm64/envs/test/lib/python3.10/site-packages/tvm/_ffi/base.py", line 71, in <module>
    _LIB, _LIB_NAME = _load_lib()
  File "/Users/ngam/.Mambaforge-MacOSX-arm64/envs/test/lib/python3.10/site-packages/tvm/_ffi/base.py", line 57, in _load_lib
    lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_GLOBAL)
  File "/Users/ngam/.Mambaforge-MacOSX-arm64/envs/test/lib/python3.10/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Users/ngam/.Mambaforge-MacOSX-arm64/envs/test/lib/libtvm.dylib, 0x000A): tried: '/Users/ngam/.Mambaforge-MacOSX-arm64/envs/test/lib/libtvm.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/libtvm.dylib' (no such file), '/usr/lib/libtvm.dylib' (no such file)
ngam commented 2 years ago

I think we need to the arm64 tool-chain somehow (with the metal support). I will dig a little to see what apple docs have on this stuff...

ngam commented 2 years ago

Implementation done in: Reference messy implementation: https://github.com/conda-forge/libtvm-feedstock/pull/23 and https://github.com/conda-forge/tvm-py-feedstock/pull/22

Please refer back to issue linked above in conda-forge.github.io for more details.