Skip to content

[BUG] Failed to build mlx from sources with v0.10.0 version and below #2696

@hwhsu1231

Description

@hwhsu1231

Describe the bug

I attempted to build mlx from source with versions ranging from v0.29.3 down to v0.11.1, and all compiled and installed successfully. However, starting from version v0.10.0, the compilation fails with the following error message:

  [ 81%] Building CXX object python/src/CMakeFiles/core.dir/array.cpp.o
  In file included from /tmp/pip-build-env-4cotumu3/overlay/lib/python3.10/site-packages/nanobind/include/nanobind/nanobind.h:56,
                   from /tmp/pip-build-env-4cotumu3/overlay/lib/python3.10/site-packages/nanobind/include/nanobind/ndarray.h:16,
                   from /media/hwhsu1231/KubuntuData/Repo/testing/mlx-v0.10.0/python/src/array.cpp:6:
  /tmp/pip-build-env-4cotumu3/overlay/lib/python3.10/site-packages/nanobind/include/nanobind/nb_class.h: In instantiation of 'class nanobind::class_<mlx::core::Dtype::Category>':
  /media/hwhsu1231/KubuntuData/Repo/testing/mlx-v0.10.0/python/src/array.cpp:490:14:   required from here
  /tmp/pip-build-env-4cotumu3/overlay/lib/python3.10/site-packages/nanobind/include/nanobind/nb_class.h:548:17: error: static assertion failed: You attempted to bind a type that is already intercepted by a type caster. Having both at the same time is not allowed. Are you perhaps binding an STL type, while at the same time including a matching type caster from <nanobind/stl/*>? Or did you perhaps forget to declare NB_MAKE_OPAQUE(..) to specifically disable the type caster catch-all for a specific type? Please review the documentation to learn about the difference between bindings and type casters.
    548 |         detail::is_base_caster_v<detail::make_caster<Type>>,
        |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /tmp/pip-build-env-4cotumu3/overlay/lib/python3.10/site-packages/nanobind/include/nanobind/nb_class.h:548:17: note: 'nanobind::detail::is_base_caster_v<nanobind::detail::type_caster<mlx::core::Dtype::Category, int> >' evaluates to false
  /media/hwhsu1231/KubuntuData/Repo/testing/mlx-v0.10.0/python/src/array.cpp: In function 'auto to_scalar(mlx::core::array&)':
  /media/hwhsu1231/KubuntuData/Repo/testing/mlx-v0.10.0/python/src/array.cpp:81:1: warning: control reaches end of non-void function [-Wreturn-type]
     81 | }
        | ^
  /media/hwhsu1231/KubuntuData/Repo/testing/mlx-v0.10.0/python/src/array.cpp: In function 'nanobind::object tolist(mlx::core::array&)':
  /media/hwhsu1231/KubuntuData/Repo/testing/mlx-v0.10.0/python/src/array.cpp:119:1: warning: control reaches end of non-void function [-Wreturn-type]
    119 | }
        | ^
  gmake[2]: *** [python/src/CMakeFiles/core.dir/build.make:93: python/src/CMakeFiles/core.dir/array.cpp.o] Error 1
  gmake[1]: *** [CMakeFiles/Makefile2:319: python/src/CMakeFiles/core.dir/all] Error 2
  gmake: *** [Makefile:136: all] Error 2

To Reproduce

Below are the commands I used for testing:

MLX_VERSION="v0.10.0"
GCC_VERSION="13"
PY_VERSION="3.10"
git clone --depth=1 --branch=${MLX_VERSION} https://github.com/ml-explore/mlx mlx-${MLX_VERSION}
cd mlx-${MLX_VERSION}
conda create --prefix ./.conda --yes
conda activate ./.conda
conda install gcc=${GCC_VERSION} gxx=${GCC_VERSION} binutils openblas python=${PY_VERSION} --channel conda-forge --yes
export PYTHONNOUSERSITE=1
pip install . -v

Expected behavior

Build successfully.

Desktop (please complete the following information):

  • OS Version: Kubuntu 24.04
  • Version 0.10.0

Additional context

Below are the full logs of the above commands:

log-build-mlx-0.10.0-from-sources.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions