[C++ API][hotfix] fix C++ worker dynamic library loading issue on macOS (#18877)

* fix C++ worker in macox

* fix
This commit is contained in:
Guyang Song 2021-09-24 23:39:00 +08:00 committed by GitHub
parent e08d4253cf
commit 337005d5a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 6 deletions

View file

@ -213,7 +213,9 @@ test_cpp() {
--test_arg=--ray_redis_password="1234"
# run the cpp example
cd cpp/example && bash run.sh
rm -rf ray-template && mkdir ray-template
ray cpp --generate-bazel-project-template-to ray-template
pushd ray-template && bash run.sh
}
test_wheels() {

View file

@ -4,7 +4,10 @@ ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE:-$0}")" || exit; pwd)"
bazel --nosystem_rc --nohome_rc build //:example
if [[ "$OSTYPE" == "darwin"* ]]; then
DYLD_LIBRARY_PATH="$ROOT_DIR/thirdparty/lib" "${ROOT_DIR}"/bazel-bin/example
# TODO: We use `install_name_tool` to walk around the issue of dynamic libraries loading in macOS.
install_name_tool -change bazel-out/darwin-opt/bin/cpp/libray_api.so ./thirdparty/lib/libray_api.so ./bazel-bin/example.so
install_name_tool -change bazel-out/darwin-opt/bin/cpp/libray_api.so ./thirdparty/lib/libray_api.so ./bazel-bin/example
"${ROOT_DIR}"/bazel-bin/example
else
LD_LIBRARY_PATH="$ROOT_DIR/thirdparty/lib" "${ROOT_DIR}"/bazel-bin/example
fi

View file

@ -69,6 +69,7 @@ std::shared_ptr<AbstractRayRuntime> AbstractRayRuntime::GetInstance() {
}
void AbstractRayRuntime::DoShutdown() {
abstract_ray_runtime_ = nullptr;
if (ConfigInternal::Instance().run_mode == RunMode::CLUSTER) {
ProcessHelper::GetInstance().RayStop();
}

View file

@ -129,14 +129,14 @@ Ray provides Python, Java, and *EXPERIMENTAL* C++ API. And Ray uses Tasks (funct
.. code-block:: shell
cd ray-template && sh run.sh
cd ray-template && bash run.sh
| - 2. Connect the example application to an existing Ray cluster by specifying the RAY_ADDRESS env var.
.. code-block:: shell
ray start --head
RAY_ADDRESS=127.0.0.1:6379 sh run.sh
RAY_ADDRESS=127.0.0.1:6379 bash run.sh
| - Now you can build your own Ray C++ application based on this project template.

View file

@ -1922,7 +1922,7 @@ def cpp(show_library_path, generate_bazel_project_template_to, log_style,
cli_logger.print(
cf.bold(
f" cd {os.path.abspath(generate_bazel_project_template_to)}"
" && sh run.sh"))
" && bash run.sh"))
def add_command_alias(command, name, hidden):

View file

@ -4,4 +4,4 @@
set -e
rm -rf ray-template && mkdir ray-template
ray cpp --generate-bazel-project-template-to ray-template
pushd ray-template && sh run.sh
pushd ray-template && bash run.sh