From 4ed37d02c0079b509ce15b9ded51a1a4ab74334c Mon Sep 17 00:00:00 2001 From: thucpham Date: Tue, 29 Oct 2024 11:46:43 +0100 Subject: [PATCH 1/2] try to add rpath nvidia python --- python/setup.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/python/setup.py b/python/setup.py index 7f56d6074..be3b6a09f 100644 --- a/python/setup.py +++ b/python/setup.py @@ -1,6 +1,7 @@ import glob import os import sys +import site import pybind11 @@ -51,6 +52,14 @@ def _maybe_add_library_root(lib_name): elif sys.platform == "win32": cflags = ["/std:c++17", "/d2FH4-"] package_data["ctranslate2"] = ["*.dll"] +else: + CUDA_RPATHS=[ + '$ORIGIN/../nvidia/cublas/lib', + '$ORIGIN/../nvidia/cuda_runtime/lib', + '$ORIGIN/../nvidia/cudnn/lib', + ] + CUDA_RPATHS= ';'.join(map(str, CUDA_RPATHS)) + ldflags.append("-Wl,-rpath," + CUDA_RPATHS + "/lib") ctranslate2_module = Extension( "ctranslate2._ext", From 4e63ba6f68dc8cccc2c328603032602507c1f402 Mon Sep 17 00:00:00 2001 From: thucpham Date: Tue, 29 Oct 2024 14:57:12 +0100 Subject: [PATCH 2/2] try to add rpath nvidia python --- python/setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/setup.py b/python/setup.py index be3b6a09f..25387f2d8 100644 --- a/python/setup.py +++ b/python/setup.py @@ -44,6 +44,7 @@ def _maybe_add_library_root(lib_name): cflags = ["-std=c++17", "-fvisibility=hidden"] ldflags = [] +rpaths = [] package_data = {} if sys.platform == "darwin": # std::visit requires macOS 10.14 @@ -53,13 +54,11 @@ def _maybe_add_library_root(lib_name): cflags = ["/std:c++17", "/d2FH4-"] package_data["ctranslate2"] = ["*.dll"] else: - CUDA_RPATHS=[ + rpaths=[ '$ORIGIN/../nvidia/cublas/lib', '$ORIGIN/../nvidia/cuda_runtime/lib', '$ORIGIN/../nvidia/cudnn/lib', ] - CUDA_RPATHS= ';'.join(map(str, CUDA_RPATHS)) - ldflags.append("-Wl,-rpath," + CUDA_RPATHS + "/lib") ctranslate2_module = Extension( "ctranslate2._ext", @@ -69,6 +68,7 @@ def _maybe_add_library_root(lib_name): include_dirs=include_dirs, library_dirs=library_dirs, libraries=["ctranslate2"], + runtime_library_dirs=rpaths ) ParallelCompile("CMAKE_BUILD_PARALLEL_LEVEL").install()