ray-project / ray

Ray is an AI compute engine. Ray consists of a core distributed runtime and a set of AI Libraries for accelerating ML workloads.
https://ray.io
Apache License 2.0
34.05k stars 5.78k forks source link

[Core] ray Compilation error: non-constant condition for static assertion #48771

Open kadisi opened 2 days ago

kadisi commented 2 days ago

What happened + What you expected to happen

when i build ray from sourcecode , it output errror:


    Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
    In file included from bazel-out/k8-opt/bin/_virtual_includes/gcs_server_lib/ray/gcs/gcs_server/gcs_server.h:27,
                     from src/ray/gcs/gcs_server/gcs_server.cc:15:
    bazel-out/k8-opt/bin/src/ray/common/_virtual_includes/asio/ray/common/asio/asio_util.h: In instantiation of 'instrumented_io_context& IOContextProvider<Policy>::GetIOContext() const [with T = ray::gcs::GcsPublisher; Policy = ray::gcs::GcsServerIOContextPolicy]':
    src/ray/gcs/gcs_server/gcs_server.cc:68:81:   required from here
    bazel-out/k8-opt/bin/src/ray/common/_virtual_includes/asio/ray/common/asio/asio_util.h:146:73:   in 'constexpr' expansion of 'ray::gcs::GcsServerIOContextPolicy::GetDedicatedIOContextIndex<ray::gcs::GcsPublisher>()'
    bazel-out/k8-opt/bin/_virtual_includes/gcs_server_lib/ray/gcs/gcs_server/gcs_server_io_context_policy.h:40:21:   in 'constexpr' expansion of 'ray::gcs::GcsServerIOContextPolicy::IndexOf(std::basic_string_view<char>(((const char*)"pubsub_io_context")))'
    bazel-out/k8-opt/bin/_virtual_includes/gcs_server_lib/ray/gcs/gcs_server/gcs_server_io_context_policy.h:59:24: error: 'constexpr size_t ray::IndexOf(const std::array<_Tp, _Nm>&, const T&) [with T = std::basic_string_view<char>; long unsigned int N = 3; size_t = long unsigned int]' called in a constant expression
       59 |     return ray::IndexOf(kAllDedicatedIOContextNames, name);
          |            ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from bazel-out/k8-opt/bin/src/ray/common/_virtual_includes/asio/ray/common/asio/asio_util.h:25,
                     from bazel-out/k8-opt/bin/_virtual_includes/gcs_server_lib/ray/gcs/gcs_server/gcs_server.h:17,
                     from src/ray/gcs/gcs_server/gcs_server.cc:15:
    bazel-out/k8-opt/bin/src/ray/util/_virtual_includes/util/ray/util/array.h:39:18: note: 'constexpr size_t ray::IndexOf(const std::array<_Tp, _Nm>&, const T&) [with T = std::basic_string_view<char>; long unsigned int N = 3; size_t = long unsigned int]' is not usable as a 'constexpr' function because:
       39 | constexpr size_t IndexOf(const std::array<T, N> &arr, const T &value) {
          |                  ^~~~~~~
    bazel-out/k8-opt/bin/src/ray/util/_virtual_includes/util/ray/util/array.h:46:3: error: expression '<throw-expression>' is not a constant expression
       46 |   throw "Value not found in array";
          |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from bazel-out/k8-opt/bin/_virtual_includes/gcs_server_lib/ray/gcs/gcs_server/gcs_server.h:17,
                     from src/ray/gcs/gcs_server/gcs_server.cc:15:
    bazel-out/k8-opt/bin/src/ray/common/_virtual_includes/asio/ray/common/asio/asio_util.h:148:21: error: non-constant condition for static assertion
      148 |         index >= -1 &&
          |         ~~~~~~~~~~~~^~
      149 |         index < Policy::kAllDedicatedIOContextNames.size(),
          |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from bazel-out/k8-opt/bin/_virtual_includes/gcs_server_lib/ray/gcs/gcs_server/gcs_server.h:27,
                     from src/ray/gcs/gcs_server/gcs_server.cc:15:
    bazel-out/k8-opt/bin/src/ray/common/_virtual_includes/asio/ray/common/asio/asio_util.h: In instantiation of 'instrumented_io_context& IOContextProvider<Policy>::GetIOContext() const [with T = ray::syncer::RaySyncer; Policy = ray::gcs::GcsServerIOContextPolicy]':
    src/ray/gcs/gcs_server/gcs_server.cc:533:60:   required from here
    bazel-out/k8-opt/bin/src/ray/common/_virtual_includes/asio/ray/common/asio/asio_util.h:146:73:   in 'constexpr' expansion of 'ray::gcs::GcsServerIOContextPolicy::GetDedicatedIOContextIndex<ray::syncer::RaySyncer>()'
    bazel-out/k8-opt/bin/_virtual_includes/gcs_server_lib/ray/gcs/gcs_server/gcs_server_io_context_policy.h:42:21:   in 'constexpr' expansion of 'ray::gcs::GcsServerIOContextPolicy::IndexOf(std::basic_string_view<char>(((const char*)"ray_syncer_io_context")))'
    bazel-out/k8-opt/bin/_virtual_includes/gcs_server_lib/ray/gcs/gcs_server/gcs_server_io_context_policy.h:59:24: error: 'constexpr size_t ray::IndexOf(const std::array<_Tp, _Nm>&, const T&) [with T = std::basic_string_view<char>; long unsigned int N = 3; size_t = long unsigned int]' called in a constant expression
       59 |     return ray::IndexOf(kAllDedicatedIOContextNames, name);
          |            ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from bazel-out/k8-opt/bin/_virtual_includes/gcs_server_lib/ray/gcs/gcs_server/gcs_server.h:17,
                     from src/ray/gcs/gcs_server/gcs_server.cc:15:
    bazel-out/k8-opt/bin/src/ray/common/_virtual_includes/asio/ray/common/asio/asio_util.h:148:21: error: non-constant condition for static assertion
      148 |         index >= -1 &&
          |         ~~~~~~~~~~~~^~
      149 |         index < Policy::kAllDedicatedIOContextNames.size(),
          |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from bazel-out/k8-opt/bin/_virtual_includes/gcs_server_lib/ray/gcs/gcs_server/gcs_server.h:27,
                     from src/ray/gcs/gcs_server/gcs_server.cc:15:
    bazel-out/k8-opt/bin/src/ray/common/_virtual_includes/asio/ray/common/asio/asio_util.h: In instantiation of 'instrumented_io_context& IOContextProvider<Policy>::GetIOContext() const [with T = ray::gcs::GcsTaskManager; Policy = ray::gcs::GcsServerIOContextPolicy]':
    src/ray/gcs/gcs_server/gcs_server.cc:684:72:   required from here
    bazel-out/k8-opt/bin/src/ray/common/_virtual_includes/asio/ray/common/asio/asio_util.h:146:73:   in 'constexpr' expansion of 'ray::gcs::GcsServerIOContextPolicy::GetDedicatedIOContextIndex<ray::gcs::GcsTaskManager>()'
    bazel-out/k8-opt/bin/_virtual_includes/gcs_server_lib/ray/gcs/gcs_server/gcs_server_io_context_policy.h:38:21:   in 'constexpr' expansion of 'ray::gcs::GcsServerIOContextPolicy::IndexOf(std::basic_string_view<char>(((const char*)"task_io_context")))'
    bazel-out/k8-opt/bin/_virtual_includes/gcs_server_lib/ray/gcs/gcs_server/gcs_server_io_context_policy.h:59:24: error: 'constexpr size_t ray::IndexOf(const std::array<_Tp, _Nm>&, const T&) [with T = std::basic_string_view<char>; long unsigned int N = 3; size_t = long unsigned int]' called in a constant expression
       59 |     return ray::IndexOf(kAllDedicatedIOContextNames, name);
          |            ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from bazel-out/k8-opt/bin/_virtual_includes/gcs_server_lib/ray/gcs/gcs_server/gcs_server.h:17,
                     from src/ray/gcs/gcs_server/gcs_server.cc:15:
    bazel-out/k8-opt/bin/src/ray/common/_virtual_includes/asio/ray/common/asio/asio_util.h:148:21: error: non-constant condition for static assertion
      148 |         index >= -1 &&
          |         ~~~~~~~~~~~~^~
      149 |         index < Policy::kAllDedicatedIOContextNames.size(),
          |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    bazel-out/k8-opt/bin/src/ray/common/_virtual_includes/asio/ray/common/asio/asio_util.h: In member function 'instrumented_io_context& IOContextProvider<Policy>::GetIOContext() const [with T = ray::gcs::GcsPublisher; Policy = ray::gcs::GcsServerIOContextPolicy]':
    bazel-out/k8-opt/bin/src/ray/common/_virtual_includes/asio/ray/common/asio/asio_util.h:158:3: error: control reaches end of non-void function [-Werror=return-type]
      158 |   }
          |   ^
    bazel-out/k8-opt/bin/src/ray/common/_virtual_includes/asio/ray/common/asio/asio_util.h: In member function 'instrumented_io_context& IOContextProvider<Policy>::GetIOContext() const [with T = ray::syncer::RaySyncer; Policy = ray::gcs::GcsServerIOContextPolicy]':
    bazel-out/k8-opt/bin/src/ray/common/_virtual_includes/asio/ray/common/asio/asio_util.h:158:3: error: control reaches end of non-void function [-Werror=return-type]
    bazel-out/k8-opt/bin/src/ray/common/_virtual_includes/asio/ray/common/asio/asio_util.h: In member function 'instrumented_io_context& IOContextProvider<Policy>::GetIOContext() const [with T = ray::gcs::GcsTaskManager; Policy = ray::gcs::GcsServerIOContextPolicy]':
    bazel-out/k8-opt/bin/src/ray/common/_virtual_includes/asio/ray/common/asio/asio_util.h:158:3: error: control reaches end of non-void function [-Werror=return-type]
    cc1plus: all warnings being treated as errors
    [326 / 359] Compiling src/ray/core_worker/core_worker.cc; 95s remote-cache, linux-sandbox ... (50 actions running)
    INFO: Elapsed time: 159.114s, Critical Path: 112.54s
    INFO: 163 processes: 35 internal, 127 linux-sandbox, 1 local.
    FAILED: Build did NOT complete successfully
    Traceback (most recent call last):
      File "<string>", line 2, in <module>
      File "<pip-setuptools-caller>", line 34, in <module>
      File "/root/projects/ray/python/setup.py", line 784, in <module>
        setuptools.setup(
      File "/root/anaconda3/envs/develop/lib/python3.9/site-packages/setuptools/__init__.py", line 117, in setup
        return distutils.core.setup(**attrs)
      File "/root/anaconda3/envs/develop/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 183, in setup
        return run_commands(dist)
      File "/root/anaconda3/envs/develop/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 199, in run_commands
        dist.run_commands()
      File "/root/anaconda3/envs/develop/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 954, in run_commands
        self.run_command(cmd)
      File "/root/anaconda3/envs/develop/lib/python3.9/site-packages/setuptools/dist.py", line 994, in run_command
        super().run_command(command)
      File "/root/anaconda3/envs/develop/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 973, in run_command
        cmd_obj.run()
      File "/root/anaconda3/envs/develop/lib/python3.9/site-packages/setuptools/command/develop.py", line 35, in run
        self.install_for_development()
      File "/root/anaconda3/envs/develop/lib/python3.9/site-packages/setuptools/command/develop.py", line 112, in install_for_development
        self.run_command('build_ext')
      File "/root/anaconda3/envs/develop/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
        self.distribution.run_command(command)
      File "/root/anaconda3/envs/develop/lib/python3.9/site-packages/setuptools/dist.py", line 994, in run_command
        super().run_command(command)
      File "/root/anaconda3/envs/develop/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 973, in run_command
        cmd_obj.run()
      File "/root/projects/ray/python/setup.py", line 772, in run
        return pip_run(self)
      File "/root/projects/ray/python/setup.py", line 674, in pip_run
        build(True, BUILD_JAVA, True)
      File "/root/projects/ray/python/setup.py", line 617, in build
        return bazel_invoke(
      File "/root/projects/ray/python/setup.py", line 397, in bazel_invoke
        result = invoker([cmd] + cmdline, *args, **kwargs)
      File "/root/anaconda3/envs/develop/lib/python3.9/subprocess.py", line 373, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['bazel', 'build', '--verbose_failures', '--', '//:ray_pkg', '//cpp:ray_cpp_pkg']' returned non-zero exit status 1.
    error: subprocess-exited-with-error

    × python setup.py develop did not run successfully.
    │ exit code: 1
    ╰─> See above for output.

    note: This error originates from a subprocess, and is likely not a problem with pip.
    full command: /root/anaconda3/envs/develop/bin/python3.9 -c '
    exec(compile('"'"''"'"''"'"'
    # This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py
    #
    # - It imports setuptools before invoking setup.py, to enable projects that directly
    #   import from `distutils.core` to work with newer packaging standards.
    # - It provides a clear error message when setuptools is not installed.
    # - It sets `sys.argv[0]` to the underlying `setup.py`, when invoking `setup.py` so
    #   setuptools doesn'"'"'t think the script is `-c`. This avoids the following warning:
    #     manifest_maker: standard file '"'"'-c'"'"' not found".
    # - It generates a shim setup.py, for handling setup.cfg-only projects.
    import os, sys, tokenize

    try:
        import setuptools
    except ImportError as error:
        print(
            "ERROR: Can not execute `setup.py` since setuptools is not available in "
            "the build environment.",
            file=sys.stderr,
        )
        sys.exit(1)

    __file__ = %r
    sys.argv[0] = __file__

    if os.path.exists(__file__):
        filename = __file__
        with tokenize.open(__file__) as f:
            setup_py_code = f.read()
    else:
        filename = "<auto-generated setuptools caller>"
        setup_py_code = "from setuptools import setup; setup()"

    exec(compile(setup_py_code, filename, "exec"))
    '"'"''"'"''"'"' % ('"'"'/root/projects/ray/python/setup.py'"'"',), "<pip-setuptools-caller>", "exec"))' develop --no-deps
    cwd: /root/projects/ray/python/
error: subprocess-exited-with-error

× python setup.py develop did not run successfully.
│ exit code: 1
╰─> See above for output.

Versions / Dependencies

ray tag: 2.39.0

Reproduction script

pip install -e . --verbose

Issue Severity

High: It blocks me from completing my task.

shreyass-ranganatha commented 1 day ago

Try installing setuptools (pip install setuptools) before building Ray's source

kadisi commented 1 day ago

Try installing setuptools (pip install setuptools) before building Ray's source

hi @shreyass-ranganatha , before i exec pip install -e . --verbose , i have install setuptools and also exec pip install -c python/requirements_compiled.txt -r python/requirements/lint-requirements.txt command to install the requirements.

but i still error.

jjyao commented 13 hours ago

Hi @kadisi what's your compiler version?