Skip to content

Base build instructions lead to import error in tests (_mlir_libs._torchMlir not found) #4135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
efric opened this issue Apr 15, 2025 · 2 comments

Comments

@efric
Copy link
Contributor

efric commented Apr 15, 2025

Hi folks,

When trying to build torch-mlir following the provided instructions , I ran into unit test failures, specifically

  TORCH_MLIR :: python/fx_importer/basic_test.py
  TORCH_MLIR :: python/fx_importer/custom_op_test.py
  TORCH_MLIR :: python/fx_importer/symbolic_shape_expr_test.py
  TORCH_MLIR :: python/fx_importer/v2.3/auto_functionalized.py
  TORCH_MLIR :: python/fx_importer/v2.3/mutation_import.py
  TORCH_MLIR :: python/fx_importer/v2.3/special_forms_test.py
  TORCH_MLIR :: python/fx_importer/v2.3/types_test.py
  TORCH_MLIR :: python/onnx_importer/BadName.runlit
  TORCH_MLIR :: python/onnx_importer/command_line_test.py
  TORCH_MLIR :: python/onnx_importer/constants.py
  TORCH_MLIR :: python/onnx_importer/function_expansion/GreaterOrEqual.runlit
  TORCH_MLIR :: python/onnx_importer/function_expansion/ReduceSumSquare_keepdims=0.runlit
  TORCH_MLIR :: python/onnx_importer/function_expansion/ReduceSumSquare_no_attrs.runlit
  TORCH_MLIR :: python/onnx_importer/import_onnx_tool.runlit
  TORCH_MLIR :: python/onnx_importer/import_smoke_test.py

All of which stem from

ModuleNotFoundError: No module named 'torch_mlir._mlir_libs._torchMlir'

This occurs with both the base and base + optimization instructions. The issue is resolved by explicitly adding

-DPython_FIND_VIRTUALENV=ONLY

to the CMake invocation (in addition to the existing -DPython3_FIND_VIRTUALENV=ONLY).

If it's helpful, I used Python 3.11 for the virtual environment.

@meesfrensel
Copy link

I just ran into this issue as well and can confirm it and the solution provided. Build process was generating _torchMlir.cpython-3xx-x86_64-linux-gnu.so using the 'global' available python instead of the virtual env python. Adding the -D does generate the correct lib. I am using 3.12 stock python and 3.10 in the venv.

@meesfrensel
Copy link

This is added to the development instructions in #4024 by the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants