Closed Krovatkin closed 2 years ago
I am not sure what might be happening there, especially that osx
is not my cup of tea
I believe would be better to post that on the tvm repository, they might give you a better explanation and we can recreate the package for osx following their instructions
You can try to workaround it installing llvm
conda install llvm
hi Marcelo, i meet the same issue. It seems not work for
thanks, -chayi
Details about conda and system ( conda info ):
active environment : tvm active env location : /home/chayi/miniconda3/envs/tvm shell level : 1 user config file : /home/chayi/.condarc populated config files : /home/chayi/.condarc conda version : 4.9.2 conda-build version : not installed python version : 3.8.5.final.0 virtual packages : glibc=2.12=0 unix=0=0 __archspec=1=x86_64 base environment : /home/chayi/miniconda3 (writable) channel URLs : https://conda.anaconda.org/conda-forge/linux-64 https://conda.anaconda.org/conda-forge/noarch https://repo.anaconda.com/pkgs/main/linux-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/r/linux-64 https://repo.anaconda.com/pkgs/r/noarch package cache : /home/chayi/miniconda3/pkgs /home/chayi/.conda/pkgs envs directories : /home/chayi/miniconda3/envs /home/chayi/.conda/envs platform : linux-64 user-agent : conda/4.9.2 requests/2.25.1 CPython/3.8.5 Linux/2.6.32-754.35.1.el6.x86_64 centos/6.10 glibc/2.12 UID:GID : 1013:1013 netrc file : None offline mode : False
Environment (conda list):
#
_libgcc_mutex 0.1 conda_forge conda-forge _openmp_mutex 4.5 1_gnu conda-forge attrs 20.3.0 pyhd3deb0d_0 conda-forge backtrace 20210212 h27826a3_0 conda-forge binutils_impl_linux-64 2.31.1 h7fc9f1b_5 conda-forge binutils_linux-64 2.31.1 h6176602_9 conda-forge bzip2 1.0.8 h7f98852_4 conda-forge c-ares 1.17.1 h7f98852_1 conda-forge ca-certificates 2020.12.5 ha878542_0 conda-forge certifi 2020.12.5 py36h5fab9bb_1 conda-forge cmake 3.18.2 ha30ef3c_0 anaconda curl 7.75.0 h979ede3_0 conda-forge decorator 4.4.2 py_0 conda-forge dlpack 0.3 he1b5a44_1 conda-forge dmlc 0.4 h7fccf02_1 conda-forge expat 2.2.9 he1b5a44_2 conda-forge gcc_impl_linux-64 7.3.0 habb00fd_1 gcc_linux-64 7.3.0 h553295d_9 importlib-metadata 3.7.2 pypi_0 pypi iniconfig 1.1.1 pypi_0 pypi krb5 1.17.2 h926e7f8_0 conda-forge ld_impl_linux-64 2.34 h53a641e_7 conda-forge libblas 3.9.0 8_openblas conda-forge libcblas 3.9.0 8_openblas conda-forge libcurl 7.75.0 hc4aaa36_0 conda-forge libedit 3.1.20191231 he28a2e2_2 conda-forge libev 4.33 h516909a_1 conda-forge libffi 3.3 h58526e2_2 conda-forge libgcc 7.2.0 h69d50b8_2 libgcc-ng 9.3.0 h2828fa1_18 conda-forge libgfortran-ng 9.3.0 hff62375_18 conda-forge libgfortran5 9.3.0 hff62375_18 conda-forge libgomp 9.3.0 h2828fa1_18 conda-forge liblapack 3.9.0 8_openblas conda-forge libllvm10 10.0.1 hbcb73fb_5 libnghttp2 1.43.0 h812cca2_0 conda-forge libopenblas 0.3.12 pthreads_h4812303_1 conda-forge libssh2 1.9.0 ha56f1ee_6 conda-forge libstdcxx-ng 9.3.0 h6de172a_18 conda-forge libtvm 0.7.0 he1b5a44_0 conda-forge libuv 1.41.0 h7f98852_0 conda-forge llvm 10.0.1 h21ff451_5 lz4-c 1.9.2 he1b5a44_3 conda-forge ncurses 6.2 h58526e2_4 conda-forge numpy 1.19.5 py36h2aa4a07_1 conda-forge openssl 1.1.1j h7f98852_0 conda-forge packaging 20.9 pypi_0 pypi pip 21.0.1 pyhd8ed1ab_0 conda-forge pluggy 0.13.1 pypi_0 pypi psutil 5.8.0 py36h8f6f2f9_1 conda-forge py 1.10.0 pypi_0 pypi pyparsing 2.4.7 pypi_0 pypi pytest 6.2.2 pypi_0 pypi python 3.6.13 hdb3f193_0 python_abi 3.6 1_cp36m conda-forge rang 3.1.0 0 conda-forge readline 8.0 he28a2e2_2 conda-forge rhash 1.4.1 h7f98852_0 conda-forge scipy 1.5.3 py36h9e8f40b_0 conda-forge setuptools 49.6.0 py36h5fab9bb_3 conda-forge sqlite 3.34.0 h74cdb3f_0 conda-forge tk 8.6.10 h21135ba_1 conda-forge toml 0.10.2 pypi_0 pypi tvm-py 0.7.0 py36hd87012b_1 conda-forge typed-ast 1.4.2 py36h8f6f2f9_0 conda-forge typing-extensions 3.7.4.3 pypi_0 pypi wheel 0.36.2 pyhd3deb0d_0 conda-forge xz 5.2.5 h516909a_1 conda-forge zipp 3.4.1 pypi_0 pypi zlib 1.2.11 h516909a_1010 conda-forge zstd 1.4.5 h6597ccf_2 conda-forge
I will enable llvm here soon. It is strongly recommended to enable it anyway... stay tuned for that in the next few days
@ngam amazing!!! thank you very much!! so if I do conda install tvm-py
I should be able to actually run kernels on CPU?
@ngam amazing!!! thank you very much!! so if I do
conda install tvm-py
I should be able to actually run kernels on CPU?
I think so. Also, I am enabling metal for osx and cuda as well. Follow this PR #8 (currently messy as I am picking things to add and testing). Once this is done, I will move to the tvm-py to update it. I believe it should be done by the weekend...
@Krovatkin what's in your example.py?
should be done now, I ran their basic unit testing. If you let me know more about your use case, I can probably improve the recipe more. I want to add #15 for example
@ngam
It's been awhile. I think I was simply following this tutorial : https://tvm.apache.org/docs/how_to/optimize_operators/opt_gemm.html
import tvm
import tvm.testing
from tvm import te
import numpy
import timeit
# The size of the matrix
# (M, K) x (K, N)
# You are free to try out different shapes, sometimes TVM optimization outperforms numpy with MKL.
M = 1024
K = 1024
N = 1024
# The default tensor type in tvm
dtype = "float32"
# using Intel AVX2(Advanced Vector Extensions) ISA for SIMD
# To get the best performance, please change the following line
# to llvm -mcpu=core-avx2, or specific type of CPU you use
target = "llvm"
dev = tvm.device(target, 0)
# Random generated tensor for testing
a = [tvm.nd.array](https://tvm.apache.org/docs/reference/api/python/ndarray.html#tvm.nd.array)([numpy.random.rand](https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html#numpy.random.rand)(M, K).astype(dtype), dev)
b = [tvm.nd.array](https://tvm.apache.org/docs/reference/api/python/ndarray.html#tvm.nd.array)([numpy.random.rand](https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html#numpy.random.rand)(K, N).astype(dtype), dev)
np_repeat = 100
np_runing_time = timeit.timeit(
setup="import numpy\n"
"M = " + str(M) + "\n"
"K = " + str(K) + "\n"
"N = " + str(N) + "\n"
'dtype = "float32"\n'
"a = numpy.random.rand(M, K).astype(dtype)\n"
"b = numpy.random.rand(K, N).astype(dtype)\n",
stmt="answer = [numpy.dot](https://numpy.org/doc/stable/reference/generated/numpy.dot.html#numpy.dot)(a, b)",
number=np_repeat,
)
print("Numpy running time: %f" % (np_runing_time / np_repeat))
answer = numpy.dot(a.numpy(), b.numpy())
# Algorithm
k = [te.reduce_axis](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.reduce_axis)((0, K), "k")
A = [te.placeholder](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.placeholder)((M, K), name="A")
B = [te.placeholder](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.placeholder)((K, N), name="B")
C = [te.compute](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.compute)((M, N), lambda m, n: [te.sum](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.sum)(A[m, k] * B[k, n], axis=k), name="C")
# Default schedule
s = [te.create_schedule](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.create_schedule)(C.op)
func = [tvm.build](https://tvm.apache.org/docs/reference/api/python/driver.html#tvm.build)(s, [A, B, C], target=target, name="mmult")
assert func
c = [tvm.nd.array](https://tvm.apache.org/docs/reference/api/python/ndarray.html#tvm.nd.array)([numpy.zeros](https://numpy.org/doc/stable/reference/generated/numpy.zeros.html#numpy.zeros)((M, N), dtype=dtype), dev)
func(a, b, c)
tvm.testing.assert_allclose(c.numpy(), answer, rtol=1e-5)
evaluator = func.time_evaluator(func.entry_name, dev, number=1)
print("Baseline: %f" % evaluator(a, b, c).mean)
Thanks, this works completely fine now: mamba install tvm-py pytest
should run it without errors. Closing, but feel free to reopen or open a new issue :)
Issue:
First of all, thank you very much for this work! I love the idea of being able to just install python bindings for tvm with conda and experiment with schedules. Unfortunately, I can't seem to run it.
Hi, I was wondering if there are tvm packages that also bundle llvm?
Environment (
conda list
):Details about
conda
and system (conda info
):