diff --git a/conda/environments/all_cuda-129_arch-aarch64.yaml b/conda/environments/all_cuda-129_arch-aarch64.yaml index 83c46e3bb..d27ba356f 100644 --- a/conda/environments/all_cuda-129_arch-aarch64.yaml +++ b/conda/environments/all_cuda-129_arch-aarch64.yaml @@ -18,7 +18,6 @@ dependencies: - ipython - lazy-loader>=0.4 - libnvjpeg-dev -- libnvjpeg-static - matplotlib-base>=3.7 - nbsphinx - ninja diff --git a/conda/environments/all_cuda-129_arch-x86_64.yaml b/conda/environments/all_cuda-129_arch-x86_64.yaml index 45c9a205a..16203ae1c 100644 --- a/conda/environments/all_cuda-129_arch-x86_64.yaml +++ b/conda/environments/all_cuda-129_arch-x86_64.yaml @@ -19,7 +19,6 @@ dependencies: - lazy-loader>=0.4 - libcufile-dev - libnvjpeg-dev -- libnvjpeg-static - matplotlib-base>=3.7 - nbsphinx - ninja diff --git a/conda/recipes/libcucim/conda_build_config.yaml b/conda/recipes/libcucim/conda_build_config.yaml index f7372d75d..caf5489e1 100644 --- a/conda/recipes/libcucim/conda_build_config.yaml +++ b/conda/recipes/libcucim/conda_build_config.yaml @@ -1,14 +1,11 @@ c_compiler_version: - - 13 # [not os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] - - 11 # [os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] + - 13 cxx_compiler_version: - - 13 # [not os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] - - 11 # [os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] + - 13 cuda_compiler: - - cuda-nvcc # [not os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] - - nvcc # [os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] + - cuda-nvcc c_stdlib: - sysroot @@ -18,16 +15,3 @@ c_stdlib_version: cmake_version: - ">=3.30.4" - -# The CTK libraries below are missing from the conda-forge::cudatoolkit package -# for CUDA 11. The "*_host_*" version specifiers correspond to `11.8` packages -# and the "*_run_*" version specifiers correspond to `11.x` packages. - -cuda11_libcufile_host_version: - - "1.4.0.31" - -cuda11_libcufile_run_version: - - ">=1.0.0.82,<=1.4.0.31" - -cuda11_libnvjpeg_host_version: - - "11.6.0.55" diff --git a/conda/recipes/libcucim/meta.yaml b/conda/recipes/libcucim/meta.yaml index 73a4bfe73..1462dcb69 100644 --- a/conda/recipes/libcucim/meta.yaml +++ b/conda/recipes/libcucim/meta.yaml @@ -55,15 +55,14 @@ requirements: host: - cuda-version ={{ cuda_version }} - cuda-cudart-dev - - libcufile-dev # [linux64] + - libcufile-dev - libnvjpeg-dev - - libnvjpeg-static - nvtx-c >=3.1.0 - openslide run: - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} - cuda-cudart - - libcufile # [linux64] + - libcufile - libnvjpeg run_constrained: - {{ pin_compatible('openslide') }} diff --git a/cpp/plugins/cucim.kit.cuslide/CMakeLists.txt b/cpp/plugins/cucim.kit.cuslide/CMakeLists.txt index 32f19a09b..31d084aa1 100644 --- a/cpp/plugins/cucim.kit.cuslide/CMakeLists.txt +++ b/cpp/plugins/cucim.kit.cuslide/CMakeLists.txt @@ -125,8 +125,6 @@ superbuild_depend(cli11) superbuild_depend(pugixml) superbuild_depend(json) superbuild_depend(libdeflate) -superbuild_depend(nvjpeg) -superbuild_depend(libculibos) ################################################################################ # Find cucim package @@ -216,11 +214,6 @@ target_compile_options(${CUCIM_PLUGIN_NAME} PRIVATE $<$:-W # Link libraries target_link_libraries(${CUCIM_PLUGIN_NAME} PRIVATE - # Use custom nvjpeg_static that supports GPU input (>= CUDA 11.6) - deps::nvjpeg_static # add this before cudart so that nvjpeg.h in static library takes precedence. - # Add CUDA::culibos to link necessary methods for 'deps::nvjpeg_static' - CUDA::culibos # for nvjpeg - CUDA::cudart deps::fmt cucim::cucim deps::libtiff @@ -231,6 +224,22 @@ target_link_libraries(${CUCIM_PLUGIN_NAME} deps::json deps::libdeflate ) +if (TARGET CUDA::nvjpeg_static) + target_link_libraries(${CUCIM_PLUGIN_NAME} + PRIVATE + # Add nvjpeg before cudart so that nvjpeg.h in static library takes precedence. + CUDA::nvjpeg_static + # Add CUDA::culibos to link necessary methods for 'deps::nvjpeg_static' + CUDA::culibos + CUDA::cudart + ) +else() + target_link_libraries(${CUCIM_PLUGIN_NAME} + PRIVATE + CUDA::nvjpeg + CUDA::cudart + ) +endif() target_include_directories(${CUCIM_PLUGIN_NAME} PUBLIC diff --git a/cpp/plugins/cucim.kit.cuslide/cmake/deps/libculibos.cmake b/cpp/plugins/cucim.kit.cuslide/cmake/deps/libculibos.cmake deleted file mode 100644 index 3ebffeb84..000000000 --- a/cpp/plugins/cucim.kit.cuslide/cmake/deps/libculibos.cmake +++ /dev/null @@ -1,42 +0,0 @@ -# -# Copyright (c) 2022-2025, NVIDIA CORPORATION. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# This module tries to find libculibos.a from /usr/local/cuda if -# CUDA::culibos is not available through `find_package(CUDAToolkit REQUIRED)`. -if (NOT TARGET CUDA::culibos) - - find_package(CUDAToolkit REQUIRED) - - if(NOT TARGET CUDA::culibos) - find_library(CUDA_culibos_LIBRARY - NAMES culibos - HINTS /usr/local/cuda - ENV CUDA_PATH - PATH_SUFFIXES nvidia/current lib64 lib/x64 lib - ) - - mark_as_advanced(CUDA_culibos_LIBRARY) - - if (NOT TARGET CUDA::culibos AND CUDA_culibos_LIBRARY) - add_library(CUDA::culibos STATIC IMPORTED GLOBAL) - target_include_directories(CUDA::culibos SYSTEM INTERFACE "${CUDAToolkit_INCLUDE_DIRS}") - set_property(TARGET CUDA::culibos PROPERTY IMPORTED_LOCATION "${CUDA_culibos_LIBRARY}") - message("Set CUDA_culibos_LIBRARY to '${CUDA_culibos_LIBRARY}'.") - else () - message(FATAL_ERROR "Could not find CUDA::culibos.") - endif() - endif () - -endif () diff --git a/cpp/plugins/cucim.kit.cuslide/cmake/deps/nvjpeg.cmake b/cpp/plugins/cucim.kit.cuslide/cmake/deps/nvjpeg.cmake deleted file mode 100644 index 26ac14cb7..000000000 --- a/cpp/plugins/cucim.kit.cuslide/cmake/deps/nvjpeg.cmake +++ /dev/null @@ -1,41 +0,0 @@ -# -# Copyright (c) 2021-2025, NVIDIA CORPORATION. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -if (NOT TARGET deps::nvjpeg_static) - - add_library(deps::nvjpeg_static STATIC IMPORTED GLOBAL) - - if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../../../temp/cuda/include/nvjpeg.h) - set(NVJPEG_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../temp/cuda/include) - else () - message(FATAL_ERROR "nvjpeg.h not found") - endif () - - message("Set NVJPEG_INCLUDE_PATH to '${NVJPEG_INCLUDE_PATH}'.") - - if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../../../temp/cuda/lib64/libnvjpeg_static.a) - set(NVJPEG_STATIC_LIB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../temp/cuda/lib64/libnvjpeg_static.a) - else () - message(FATAL_ERROR "libnvjpeg_static.a not found") - endif () - - message("Set NVJPEG_STATIC_LIB_PATH to '${NVJPEG_STATIC_LIB_PATH}'.") - - set_target_properties(deps::nvjpeg_static PROPERTIES - IMPORTED_LOCATION "${NVJPEG_STATIC_LIB_PATH}" - INTERFACE_INCLUDE_DIRECTORIES "${NVJPEG_INCLUDE_PATH}" - ) - -endif () diff --git a/dependencies.yaml b/dependencies.yaml index 876e45475..5819db32e 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -173,7 +173,6 @@ dependencies: cuda: "12.*" packages: - libnvjpeg-dev - - libnvjpeg-static - output_types: conda matrices: - matrix: diff --git a/gds/CMakeLists.txt b/gds/CMakeLists.txt index 019f9f891..d8248130a 100644 --- a/gds/CMakeLists.txt +++ b/gds/CMakeLists.txt @@ -24,6 +24,9 @@ if (NOT APPLE) set(CMAKE_INSTALL_RPATH $ORIGIN) endif () +# Find CUDA Toolkit for cudart and cufile. +find_package(CUDAToolkit REQUIRED) + ################################################################################ # Add library: cufile_stub ################################################################################ @@ -52,52 +55,19 @@ target_compile_options(cufile_stub ) ## Link libraries -target_link_libraries(cufile_stub +if (CUCIM_STATIC_GDS) + # Enabling CUCIM_STATIC_GDS statically links cuFile + target_link_libraries(cufile_stub PUBLIC ${CMAKE_DL_LIBS} PRIVATE - CUDA::cudart - ) - -# Set GDS include path (cufile.h) -if (DEFINED ENV{CONDA_BUILD} AND EXISTS $ENV{PREFIX}/include/cufile.h) - set(GDS_INCLUDE_PATH "$ENV{PREFIX}/include") -elseif (DEFINED ENV{CONDA_PREFIX} AND EXISTS $ENV{CONDA_PREFIX}/include/cufile.h) - set(GDS_INCLUDE_PATH "$ENV{CONDA_PREFIX}/include") -elseif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../temp/cuda/include/cufile.h) - set(GDS_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../temp/cuda/include) -else () - set(GDS_INCLUDE_PATH /usr/local/cuda/include) -endif () - -message("Set GDS_INCLUDE_PATH to '${GDS_INCLUDE_PATH}'.") - -# Enabling CUCIM_STATIC_GDS assumes that lib/libcufile_static.a and include/cufile.h is available -# under ../temp/cuda folder. -if (CUCIM_STATIC_GDS) - add_library(deps::gds_static STATIC IMPORTED GLOBAL) - - if (DEFINED ENV{CONDA_BUILD}) - set(GDS_STATIC_LIB_PATH "$ENV{PREFIX}/lib/libcufile_static.a") - elseif (DEFINED ENV{CONDA_PREFIX}) - set(GDS_STATIC_LIB_PATH "$ENV{CONDA_PREFIX}/lib/libcufile_static.a") - elseif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../temp/cuda/lib64/libcufile_static.a) - set(GDS_STATIC_LIB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../temp/cuda/lib64/libcufile_static.a) - else () - set(GDS_STATIC_LIB_PATH /usr/local/cuda/lib64/libcufile_static.a) - endif () - - message("Set GDS_STATIC_LIB_PATH to '${GDS_STATIC_LIB_PATH}'.") - - set_target_properties(deps::gds_static PROPERTIES - IMPORTED_LOCATION "${GDS_STATIC_LIB_PATH}" - INTERFACE_INCLUDE_DIRECTORIES "${GDS_INCLUDE_PATH}" + CUDA::cuFile_static ) +else() + # Use `dlopen` to load cuFile at runtime target_link_libraries(cufile_stub PUBLIC ${CMAKE_DL_LIBS} - PRIVATE - deps::gds_static ) endif() @@ -110,9 +80,8 @@ PUBLIC target_include_directories(cufile_stub PUBLIC $ - $ + ${CUDAToolkit_INCLUDE_DIRS} PRIVATE - # Add path to cufile.h explicitly. ${TOP}/temp/cuda would be available by `./run copy_gds_files_` ${CMAKE_CURRENT_SOURCE_DIR}/../cpp/include # for including helper.h in cucim/dynlib ) diff --git a/gds/include/cufile_stub.h b/gds/include/cufile_stub.h index e7e948557..cb90e60a0 100644 --- a/gds/include/cufile_stub.h +++ b/gds/include/cufile_stub.h @@ -16,7 +16,12 @@ #ifndef CUCIM_CUFILE_STUB_H #define CUCIM_CUFILE_STUB_H -#include "cufile.h" +// Try to include the real cufile.h, fall back to minimal types if not available +#if __has_include() + #include +#else + #include "cufile_stub_types.h" +#endif #include "cucim/dynlib/helper.h" diff --git a/gds/src/cufile_stub.cpp b/gds/src/cufile_stub.cpp index cc417bb69..dd6d2e6d1 100644 --- a/gds/src/cufile_stub.cpp +++ b/gds/src/cufile_stub.cpp @@ -61,19 +61,9 @@ void CuFileStub::load() { // Note: Load the dynamic library with RTLD_NODELETE flag because libcufile.so uses thread_local which can // cause a segmentation fault if the library is dynamically loaded/unloaded. (See #158) - // CUDA versions before CUDA 11.7.1 did not ship libcufile.so.0, so this is - // a workaround that adds support for all prior versions of libcufile. handle_ = cucim::dynlib::load_library( { "libcufile.so.0", - "libcufile.so.1.3.0" /* 11.7.0 */, - "libcufile.so.1.2.1" /* 11.6.2, 11.6.1 */, - "libcufile.so.1.2.0" /* 11.6.0 */, - "libcufile.so.1.1.1" /* 11.5.1 */, - "libcufile.so.1.1.0" /* 11.5.0 */, - "libcufile.so.1.0.2" /* 11.4.4, 11.4.3, 11.4.2 */, - "libcufile.so.1.0.1" /* 11.4.1 */, - "libcufile.so.1.0.0" /* 11.4.0 */ }, RTLD_LAZY | RTLD_LOCAL | RTLD_NODELETE); if (handle_ == nullptr) diff --git a/notebooks/Accessing_File_with_GDS.ipynb b/notebooks/Accessing_File_with_GDS.ipynb index 77953c5e2..e90ba33be 100644 --- a/notebooks/Accessing_File_with_GDS.ipynb +++ b/notebooks/Accessing_File_with_GDS.ipynb @@ -34,7 +34,7 @@ "\n", "or\n", "```\n", - "!pip install cupy-cuda110\n", + "!pip install cupy-cuda12x\n", "!pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html\n", "```" ] @@ -49,7 +49,7 @@ "\n", "# or\n", "\n", - "#!pip install cupy-cuda110\n", + "#!pip install cupy-cuda12x\n", "#!pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html" ] }, diff --git a/notebooks/Basic_Usage.ipynb b/notebooks/Basic_Usage.ipynb index 40ef59ebe..9cb6b507c 100644 --- a/notebooks/Basic_Usage.ipynb +++ b/notebooks/Basic_Usage.ipynb @@ -22,7 +22,7 @@ "or\n", "```\n", "!pip install pillow\n", - "!pip install numpy scipy scikit-image cupy-cuda110 # for cucim dependency (assuming that CUDA 11.0 is used for CuPy)\n", + "!pip install numpy scipy scikit-image cupy-cuda12x # for cucim dependency (assuming that CUDA 12.x is used for CuPy)\n", "```" ] }, @@ -32,12 +32,12 @@ "metadata": {}, "outputs": [], "source": [ - "#!conda install -c conda-forge pillow\n", + "# !conda install -c conda-forge pillow\n", "\n", "# or\n", "\n", "# !pip install pillow\n", - "# !pip install numpy scipy scikit-image cupy-cuda110 # for cucim dependency (assuming that CUDA 11.0 is used for CuPy)" + "# !pip install numpy scipy scikit-image cupy-cuda12x # for cucim dependency (assuming that CUDA 12.x is used for CuPy)" ] }, { diff --git a/notebooks/Working_with_DALI.ipynb b/notebooks/Working_with_DALI.ipynb index 000f66556..2f70a2c79 100644 --- a/notebooks/Working_with_DALI.ipynb +++ b/notebooks/Working_with_DALI.ipynb @@ -24,7 +24,7 @@ "```\n", "or\n", "```\n", - "!pip install cucim scipy scikit-image cupy-cuda110 matplotlib\n", + "!pip install cucim scipy scikit-image cupy-cuda12x matplotlib\n", "!pip install --extra-index-url https://developer.download.nvidia.com/compute/redist --upgrade nvidia-dali-cuda110\n", "```" ] @@ -40,7 +40,7 @@ "\n", "# or\n", "\n", - "#!pip install cucim scipy scikit-image cupy-cuda110 matplotlib\n", + "#!pip install cucim scipy scikit-image cupy-cuda12x matplotlib\n", "# Assume that CUDA Toolkit 11.0 is available on the systsem.\n", "#!pip install --extra-index-url https://developer.download.nvidia.com/compute/redist --upgrade nvidia-dali-cuda110" ] diff --git a/run b/run index 94124df3a..4a53d6ee4 100755 --- a/run +++ b/run @@ -281,11 +281,6 @@ build_local_libcucim_() { pushd "${source_folder}" > /dev/null - # Copy cufile SDK from host system to temp/cuda - copy_gds_files_ "$source_folder" - # Copy libjpeg SDK from host system to temp/cuda - copy_nvjpeg_files_ "$source_folder" - ${CMAKE_CMD} -S "${source_folder}" -B "${build_folder}" -G "Unix Makefiles" \ -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE \ -DCMAKE_PREFIX_PATH="${prefix}" \ @@ -450,68 +445,6 @@ build_local() { eval "${old_opt}" # restore old shopts } -copy_gds_files_() { - local root_folder=${1:-${TOP}} - local cufile_search="${root_folder}/temp/cuda/include:${root_folder}/temp/cuda/lib64" - local targets_dir="" - if is_x86_64; then - targets_dir="targets/x86_64-linux" - elif is_aarch64; then - targets_dir="targets/sbsa-linux" - else - echo "Unknown architecture" - exit 1 - fi - if [ -n "${CONDA_PREFIX+x}" ]; then - cufile_search="${CONDA_PREFIX:-}/include:${CONDA_PREFIX:-}/lib ${CONDA_PREFIX:-}/${targets_dir}/include:${CONDA_PREFIX:-}/${targets_dir}/lib ${cufile_search}" - fi - if [ -n "${PREFIX+x}" ]; then - cufile_search="${PREFIX:-}/include:${PREFIX:-}/lib ${PREFIX:-}/${targets_dir}/include:${PREFIX:-}/${targets_dir}/lib ${cufile_search}" - fi - local gds_version=1.0.0 - local candidate - local cufile_include - local cufile_lib - - for candidate in ${cufile_search}; do - cufile_include="$(echo "$candidate" | cut -d: -f1)" - cufile_lib="$(echo "$candidate" | cut -d: -f2)" - if [ -f "${cufile_include}/cufile.h" ] && [ -f "${cufile_lib}/libcufile.so" ]; then - c_echo W "GDS client library is available at '${cufile_include}/cufile.h' and '${cufile_lib}/libcufile.so'" - break - fi - cufile_include="" - cufile_lib="" - done - - if [ ! -f "${cufile_include}/cufile.h" ]; then - c_echo_err Y "GDS client library is not available! Downloading the redistributable package to get cufile.h and libraries." - - run_command rm -rf "${root_folder}/temp/cuda" - run_command mkdir -p "${root_folder}/temp/cuda/include" "${root_folder}/temp/cuda/lib64" - - local temp_tgz_dir - temp_tgz_dir=$(mktemp -d) - pushd "${temp_tgz_dir}" - run_command wget https://developer.download.nvidia.com/gds/redist/rel-${gds_version}/gds-redistrib-${gds_version}.tgz - run_command tar xzvf gds-redistrib-${gds_version}.tgz - # There are no GDS binaries for aarch64 SBSA yet, but we need cufile.h for building cufile_stub - run_command cp -P gds-redistrib-${gds_version}/targets/x86_64-linux/include/cufile.h "${root_folder}/temp/cuda/include/" - if is_x86_64; then - run_command cp -P gds-redistrib-${gds_version}/targets/x86_64-linux/lib/* "${root_folder}/temp/cuda/lib64/" - fi - popd > /dev/null - run_command rm -r "${temp_tgz_dir}" - else - run_command mkdir -p "${root_folder}/temp/cuda/include" "${root_folder}/temp/cuda/lib64" - - if [ "${cufile_include}" != "${root_folder}/temp/cuda/include" ]; then - run_command cp -Pf "${cufile_include}"/cufile.h "${root_folder}"/temp/cuda/include/ || true - run_command cp -Pf "${cufile_lib}"/libcufile* "${root_folder}"/temp/cuda/lib64/ || true - fi - fi -} - get_arch_name_() { architecture="unknown" case $(uname -m) in @@ -521,82 +454,6 @@ get_arch_name_() { echo "${architecture}" } -copy_nvjpeg_files_() { - local root_folder=${1:-${TOP}} - local arch_name - arch_name="$(get_arch_name_)" - local nvjpeg_search="${root_folder}/temp/cuda/include:${root_folder}/temp/cuda/lib64" - local targets_dir="" - if is_x86_64; then - targets_dir="targets/x86_64-linux" - elif is_aarch64; then - targets_dir="targets/sbsa-linux" - else - echo "Unknown architecture" - exit 1 - fi - if [ -n "${CONDA_PREFIX+x}" ]; then - nvjpeg_search="${CONDA_PREFIX:-}/include:${CONDA_PREFIX:-}/lib ${CONDA_PREFIX:-}/${targets_dir}/include:${CONDA_PREFIX:-}/${targets_dir}/lib ${nvjpeg_search}" - fi - if [ -n "${PREFIX+x}" ]; then - nvjpeg_search="${PREFIX:-}/include:${PREFIX:-}/lib ${PREFIX:-}/${targets_dir}/include:${PREFIX:-}/${targets_dir}/lib ${nvjpeg_search}" - fi - local cuda_version="11.6" - local nvjpeg_version="11-6_11.6.0.55-1" - local candidate - local nvjpeg_include - local nvjpeg_lib - - for candidate in ${nvjpeg_search}; do - nvjpeg_include="$(echo "$candidate" | cut -d: -f1)" - nvjpeg_lib="$(echo "$candidate" | cut -d: -f2)" - if [ -f "${nvjpeg_include}/nvjpeg.h" ] && [ -f "${nvjpeg_lib}/libnvjpeg_static.a" ]; then - c_echo W "nvJPEG client library is available at '${nvjpeg_include}/nvjpeg.h' and '${nvjpeg_lib}/libnvjpeg_static.a'" - break - fi - nvjpeg_include="" - nvjpeg_lib="" - done - - if [ ! -f "${nvjpeg_include}/nvjpeg.h" ]; then - c_echo_err Y "nvJPEG library is not available! Downloading the redistributable package to get nvjpeg.h and libraries." - - run_command rm -rf "${root_folder}"/temp/cuda/include/*nvjpeg* - run_command rm -rf "${root_folder}"/temp/cuda/lib64/*nvjpeg* - run_command mkdir -p "${root_folder}"/temp/cuda/include "${root_folder}"/temp/cuda/lib64 - - local temp_tgz_dir - temp_tgz_dir=$(mktemp -d) - pushd "${temp_tgz_dir}" - c_echo W "Arch name: " G "${arch_name}" - if [ "${arch_name}" = "sbsa" ]; then - run_command wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/"${arch_name}"/libnvjpeg-dev-${nvjpeg_version}_arm64.deb - else - run_command wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/"${arch_name}"/libnvjpeg-dev-${nvjpeg_version}_amd64.deb - fi - - mkdir -p libnvjpeg-dev - mv libnvjpeg-dev-${nvjpeg_version}*.deb libnvjpeg-dev/ - pushd libnvjpeg-dev > /dev/null - run_command ar x libnvjpeg-dev-${nvjpeg_version}*.deb - run_command xz --decompress data.tar.xz - run_command tar xvf data.tar - popd > /dev/null - - run_command cp libnvjpeg-dev/usr/local/cuda-${cuda_version}/include/nvjpeg.h "${root_folder}"/temp/cuda/include/ - run_command cp libnvjpeg-dev/usr/local/cuda-${cuda_version}/lib64/libnvjpeg_static.a "${root_folder}"/temp/cuda/lib64/ - popd > /dev/null - run_command rm -r "${temp_tgz_dir}" - else - run_command mkdir -p "${root_folder}"/temp/cuda/include "${root_folder}"/temp/cuda/lib64 - - if [ "${nvjpeg_include}" != "${root_folder}/temp/cuda/include" ]; then - run_command cp -Pf "${nvjpeg_include}"/*nvjpeg* "${root_folder}"/temp/cuda/include/ || true - run_command cp -Pf "${nvjpeg_lib}"/*nvjpeg* "${root_folder}"/temp/cuda/lib64/ || true - fi - fi -} - #================================================================================== # Section: Test #==================================================================================