apache / tvm

Open deep learning compiler stack for cpu, gpu and specialized accelerators
https://tvm.apache.org/
Apache License 2.0
11.41k stars 3.4k forks source link

[Bug] TVM 0.13.0 version does not work with Python 3.8 - Error building tvm #16986

Open rishabhjainps opened 1 month ago

rishabhjainps commented 1 month ago

Thanks for participating in the TVM community! We use https://discuss.tvm.ai for any general usage questions and discussions. The issue tracker is used for actionable items such as feature proposals discussion, roadmaps, and bug tracking. You are always welcomed to post on the forum first :smile_cat:

Issues that are inactive for a period of time may get closed. We adopt this policy so that we won't lose track of actionable issues that may fall at the bottom of the pile. Feel free to reopen a new one if you feel there is an additional problem that needs attention when an old one gets closed.

Expected behavior

TVM 0.13.0 working with Python 3.8

Actual behavior

Build failed with

In file included from ml_dtypes/_src/dtypes.cc:33:0:
ml_dtypes/_src/custom_float.h: In function ‘bool ml_dtypes::RegisterFloatDtype(PyObject*)’:
ml_dtypes/_src/custom_float.h:942:3: error: there are no arguments to ‘Py_SET_TYPE’ that depend on a template parameter, so a declaration of ‘Py_SET_TYPE’ must be available [-fpermissive]
   Py_SET_TYPE(&descr_proto, &PyArrayDescr_Type);
   ^~~~~~~~~~~
ml_dtypes/_src/custom_float.h:942:3: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
In file included from ml_dtypes/_src/dtypes.cc:34:0:
ml_dtypes/_src/int4_numpy.h: In function ‘bool ml_dtypes::RegisterInt4Dtype(PyObject*)’:
ml_dtypes/_src/int4_numpy.h:842:3: error: there are no arguments to ‘Py_SET_TYPE’ that depend on a template parameter, so a declaration of ‘Py_SET_TYPE’ must be available [-fpermissive]
   Py_SET_TYPE(&descr_proto, &PyArrayDescr_Type);
   ^~~~~~~~~~~
In file included from ml_dtypes/_src/dtypes.cc:33:0:
ml_dtypes/_src/custom_float.h: In instantiation of ‘bool ml_dtypes::RegisterFloatDtype(PyObject*) [with T = Eigen::bfloat16; PyObject = _object]’:
ml_dtypes/_src/dtypes.cc:226:48:   required from here
ml_dtypes/_src/custom_float.h:942:14: error: ‘Py_SET_TYPE’ was not declared in this scope
   Py_SET_TYPE(&descr_proto, &PyArrayDescr_Type);
   ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ml_dtypes/_src/custom_float.h:942:14: note: suggested alternative: ‘__S16_TYPE’
   Py_SET_TYPE(&descr_proto, &PyArrayDescr_Type);
   ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   __S16_TYPE
ml_dtypes/_src/custom_float.h: In instantiation of ‘bool ml_dtypes::RegisterFloatDtype(PyObject*) [with T = ml_dtypes::float8_internal::float8_e4m3b11fnuz; PyObject = _object]’:
ml_dtypes/_src/dtypes.cc:229:58:   required from here
ml_dtypes/_src/custom_float.h:942:14: error: ‘Py_SET_TYPE’ was not declared in this scope
ml_dtypes/_src/custom_float.h:942:14: note: suggested alternative: ‘__S16_TYPE’
   Py_SET_TYPE(&descr_proto, &PyArrayDescr_Type);
   ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   __S16_TYPE
ml_dtypes/_src/custom_float.h: In instantiation of ‘bool ml_dtypes::RegisterFloatDtype(PyObject*) [with T = ml_dtypes::float8_internal::float8_e4m3fn; PyObject = _object]’:
ml_dtypes/_src/dtypes.cc:232:53:   required from here
ml_dtypes/_src/custom_float.h:942:14: error: ‘Py_SET_TYPE’ was not declared in this scope
ml_dtypes/_src/custom_float.h:942:14: note: suggested alternative: ‘__S16_TYPE’
   Py_SET_TYPE(&descr_proto, &PyArrayDescr_Type);
   ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   __S16_TYPE
ml_dtypes/_src/custom_float.h: In instantiation of ‘bool ml_dtypes::RegisterFloatDtype(PyObject*) [with T = ml_dtypes::float8_internal::float8_e4m3fnuz; PyObject = _object]’:
ml_dtypes/_src/dtypes.cc:235:55:   required from here
ml_dtypes/_src/custom_float.h:942:14: error: ‘Py_SET_TYPE’ was not declared in this scope
ml_dtypes/_src/custom_float.h:942:14: note: suggested alternative: ‘__S16_TYPE’
   Py_SET_TYPE(&descr_proto, &PyArrayDescr_Type);
   ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   __S16_TYPE
ml_dtypes/_src/custom_float.h: In instantiation of ‘bool ml_dtypes::RegisterFloatDtype(PyObject*) [with T = ml_dtypes::float8_internal::float8_e5m2; PyObject = _object]’:
ml_dtypes/_src/dtypes.cc:238:51:   required from here
ml_dtypes/_src/custom_float.h:942:14: error: ‘Py_SET_TYPE’ was not declared in this scope
ml_dtypes/_src/custom_float.h:942:14: note: suggested alternative: ‘__S16_TYPE’
   Py_SET_TYPE(&descr_proto, &PyArrayDescr_Type);
   ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   __S16_TYPE
ml_dtypes/_src/custom_float.h: In instantiation of ‘bool ml_dtypes::RegisterFloatDtype(PyObject*) [with T = ml_dtypes::float8_internal::float8_e5m2fnuz; PyObject = _object]’:
ml_dtypes/_src/dtypes.cc:241:55:   required from here
ml_dtypes/_src/custom_float.h:942:14: error: ‘Py_SET_TYPE’ was not declared in this scope
ml_dtypes/_src/custom_float.h:942:14: note: suggested alternative: ‘__S16_TYPE’
   Py_SET_TYPE(&descr_proto, &PyArrayDescr_Type);
   ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   __S16_TYPE
In file included from ml_dtypes/_src/dtypes.cc:34:0:
ml_dtypes/_src/int4_numpy.h: In instantiation of ‘bool ml_dtypes::RegisterInt4Dtype(PyObject*) [with T = ml_dtypes::intN<4, signed char>; PyObject = _object]’:
ml_dtypes/_src/dtypes.cc:245:43:   required from here
ml_dtypes/_src/int4_numpy.h:842:14: error: ‘Py_SET_TYPE’ was not declared in this scope
   Py_SET_TYPE(&descr_proto, &PyArrayDescr_Type);
   ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ml_dtypes/_src/int4_numpy.h:842:14: note: suggested alternative: ‘__S16_TYPE’
   Py_SET_TYPE(&descr_proto, &PyArrayDescr_Type);
   ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   __S16_TYPE
ml_dtypes/_src/int4_numpy.h: In instantiation of ‘bool ml_dtypes::RegisterInt4Dtype(PyObject*) [with T = ml_dtypes::intN<4, unsigned char>; PyObject = _object]’:
ml_dtypes/_src/dtypes.cc:248:44:   required from here
ml_dtypes/_src/int4_numpy.h:842:14: error: ‘Py_SET_TYPE’ was not declared in this scope
ml_dtypes/_src/int4_numpy.h:842:14: note: suggested alternative: ‘__S16_TYPE’
   Py_SET_TYPE(&descr_proto, &PyArrayDescr_Type);
   ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   __S16_TYPE
build/bdist.linux-x86_64/egg/tvm/3rdparty/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_device.py:85: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if mma_tp is 'hmma1688':
build/bdist.linux-x86_64/egg/tvm/3rdparty/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_device.py:88: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif mma_tp is 'imma8816':
build/bdist.linux-x86_64/egg/tvm/3rdparty/libflash_attn/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_sample.py:185: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.fuse_gemm_info[i]['A_format'] is 'Col':
build/bdist.linux-x86_64/egg/tvm/3rdparty/libflash_attn/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_sample.py:187: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.fuse_gemm_info[i]['B_format'] is 'Row':
build/bdist.linux-x86_64/egg/tvm/3rdparty/libflash_attn/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_sample.py:189: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.fuse_gemm_info[i]['C_format'] is 'Col':
build/bdist.linux-x86_64/egg/tvm/3rdparty/libflash_attn/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_turing_and_volta.py:84: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.fuse_gemm_info[i]['B_format'] is 'Row':
build/bdist.linux-x86_64/egg/tvm/3rdparty/libflash_attn/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_turing_and_volta.py:295: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.fuse_gemm_info[i]['A_format'] is 'Col':
build/bdist.linux-x86_64/egg/tvm/3rdparty/libflash_attn/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_turing_and_volta.py:297: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.fuse_gemm_info[i]['B_format'] is 'Row':
build/bdist.linux-x86_64/egg/tvm/3rdparty/libflash_attn/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_turing_and_volta.py:299: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.fuse_gemm_info[i]['C_format'] is 'Col':
build/bdist.linux-x86_64/egg/tvm/3rdparty/libflash_attn/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_device.py:85: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if mma_tp is 'hmma1688':
build/bdist.linux-x86_64/egg/tvm/3rdparty/libflash_attn/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_device.py:88: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif mma_tp is 'imma8816':
/usr/lib64/python3.8/site-packages/tvm-0.13.0-py3.8-linux-x86_64.egg/tvm/3rdparty/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_device.py:85: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if mma_tp is 'hmma1688':
/usr/lib64/python3.8/site-packages/tvm-0.13.0-py3.8-linux-x86_64.egg/tvm/3rdparty/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_device.py:88: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif mma_tp is 'imma8816':
/usr/lib64/python3.8/site-packages/tvm-0.13.0-py3.8-linux-x86_64.egg/tvm/3rdparty/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_sample.py:185: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.fuse_gemm_info[i]['A_format'] is 'Col':
/usr/lib64/python3.8/site-packages/tvm-0.13.0-py3.8-linux-x86_64.egg/tvm/3rdparty/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_sample.py:187: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.fuse_gemm_info[i]['B_format'] is 'Row':
/usr/lib64/python3.8/site-packages/tvm-0.13.0-py3.8-linux-x86_64.egg/tvm/3rdparty/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_sample.py:189: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.fuse_gemm_info[i]['C_format'] is 'Col':
/usr/lib64/python3.8/site-packages/tvm-0.13.0-py3.8-linux-x86_64.egg/tvm/3rdparty/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_turing_and_volta.py:84: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.fuse_gemm_info[i]['B_format'] is 'Row':
/usr/lib64/python3.8/site-packages/tvm-0.13.0-py3.8-linux-x86_64.egg/tvm/3rdparty/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_turing_and_volta.py:295: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.fuse_gemm_info[i]['A_format'] is 'Col':
/usr/lib64/python3.8/site-packages/tvm-0.13.0-py3.8-linux-x86_64.egg/tvm/3rdparty/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_turing_and_volta.py:297: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.fuse_gemm_info[i]['B_format'] is 'Row':
/usr/lib64/python3.8/site-packages/tvm-0.13.0-py3.8-linux-x86_64.egg/tvm/3rdparty/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_turing_and_volta.py:299: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.fuse_gemm_info[i]['C_format'] is 'Col':
/usr/lib64/python3.8/site-packages/tvm-0.13.0-py3.8-linux-x86_64.egg/tvm/3rdparty/libflash_attn/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_device.py:85: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if mma_tp is 'hmma1688':
/usr/lib64/python3.8/site-packages/tvm-0.13.0-py3.8-linux-x86_64.egg/tvm/3rdparty/libflash_attn/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_device.py:88: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif mma_tp is 'imma8816':
/usr/lib64/python3.8/site-packages/tvm-0.13.0-py3.8-linux-x86_64.egg/tvm/3rdparty/libflash_attn/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_sample.py:185: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.fuse_gemm_info[i]['A_format'] is 'Col':
/usr/lib64/python3.8/site-packages/tvm-0.13.0-py3.8-linux-x86_64.egg/tvm/3rdparty/libflash_attn/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_sample.py:187: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.fuse_gemm_info[i]['B_format'] is 'Row':
/usr/lib64/python3.8/site-packages/tvm-0.13.0-py3.8-linux-x86_64.egg/tvm/3rdparty/libflash_attn/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_sample.py:189: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.fuse_gemm_info[i]['C_format'] is 'Col':
/usr/lib64/python3.8/site-packages/tvm-0.13.0-py3.8-linux-x86_64.egg/tvm/3rdparty/libflash_attn/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_turing_and_volta.py:84: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.fuse_gemm_info[i]['B_format'] is 'Row':
/usr/lib64/python3.8/site-packages/tvm-0.13.0-py3.8-linux-x86_64.egg/tvm/3rdparty/libflash_attn/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_turing_and_volta.py:295: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.fuse_gemm_info[i]['A_format'] is 'Col':
/usr/lib64/python3.8/site-packages/tvm-0.13.0-py3.8-linux-x86_64.egg/tvm/3rdparty/libflash_attn/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_turing_and_volta.py:297: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.fuse_gemm_info[i]['B_format'] is 'Row':
/usr/lib64/python3.8/site-packages/tvm-0.13.0-py3.8-linux-x86_64.egg/tvm/3rdparty/libflash_attn/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_turing_and_volta.py:299: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.fuse_gemm_info[i]['C_format'] is 'Col':
/usr/local/lib/python3.8/site[[[###REDACTED_AWS_SECRET_KEY_REDACTED###]]]py:108: _BetaConfiguration: Support for `[tool.setuptools]` in `pyproject.toml` is still *beta*.
  warnings.warn(msg, _BetaConfiguration)
/usr/local/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
error: Setup script exited with error: command '/usr/bin/gcc' failed with exit code 1

Environment

Any environment details, such as: Operating System, TVM version, etc

Operating System: AL2 TVM version : Python 3.8 Cuda: 11.8

Steps to reproduce

Preferably a minimal script to cause the issue to occur.

Triage

Please refer to the list of label tags here to find the relevant tags and add them below in a bullet format (example below).

rishabhjainps commented 1 month ago

I had to update gen_requirements.py file to fix ml_dtypes version in https://github.com/apache/tvm/blob/main/python/gen_requirements.py

sed -i '/("matplotlib", None),/a\ ("ml_dtypes", "==0.2.0"),' gen_requirements.py

tqchen commented 1 month ago

this seems to be a ml_dtypes dependency issue rather than tvm

rishabhjainps commented 1 month ago

@tqchen Should tvm install process fix the version of ml_dtypes https://github.com/apache/tvm/blob/main/python/gen_requirements.py to avoid installing higher versions which don't support Python 3.8?

tqchen commented 1 month ago

In this case, we would likely want to depend on a higher level of python version instead

MatchX commented 1 month ago

make a new env by conda and install tvm before other pakages.