From 05d4af6ead9ca85e0f5512ee0f8cd9a167084209 Mon Sep 17 00:00:00 2001 From: Gigon Bae Date: Sun, 11 Apr 2021 23:53:12 -0700 Subject: [PATCH] Update run script for local builds --- 3rdparty/LICENSE.cuda | 96 ++++++++++--------- CMakeLists.txt | 4 +- LICENSE-3rdparty.md | 7 +- README.md | 2 +- conda/environments/env.yml | 1 + conda/recipes/libcucim/meta.yaml | 1 + cpp/CMakeLists.txt | 8 +- cpp/cmake/deps/gds.cmake | 39 -------- cpp/include/cucim/filesystem/cufile_driver.h | 14 ++- .../cucim.kit.cuslide/.vscode/settings.json | 4 + cpp/plugins/cucim.kit.cuslide/CMakeLists.txt | 3 +- .../cucim.kit.cuslide/cmake/deps/gds.cmake | 39 -------- .../deps/libjpeg-turbo-policies-fix.cmake | 3 +- .../cmake/deps/libjpeg-turbo.cmake | 8 +- cpp/src/cuimage.cpp | 8 +- cpp/src/filesystem/cufile_driver.cpp | 7 +- cucim.code-workspace | 7 +- gds/CMakeLists.txt | 83 ++++++++++------ python/.vscode/settings.json | 4 + python/cucim/CHANGELOG.md | 5 +- python/cucim/docs/release_notes/index.md | 2 + python/cucim/docs/release_notes/v0.18.3.md | 5 + python/cucim/docs/release_notes/v0.19.0.md | 6 +- python/cucim/src/localtest.py | 5 +- python/pybind11/filesystem/filesystem_py.cpp | 13 +-- python/pybind11/filesystem/filesystem_pydoc.h | 12 ++- run | 90 +++++++++++++---- 27 files changed, 257 insertions(+), 219 deletions(-) delete mode 100644 cpp/cmake/deps/gds.cmake create mode 100644 cpp/plugins/cucim.kit.cuslide/.vscode/settings.json delete mode 100644 cpp/plugins/cucim.kit.cuslide/cmake/deps/gds.cmake create mode 100644 python/.vscode/settings.json create mode 100644 python/cucim/docs/release_notes/v0.18.3.md diff --git a/3rdparty/LICENSE.cuda b/3rdparty/LICENSE.cuda index 57888aca3..ef38a253c 100644 --- a/3rdparty/LICENSE.cuda +++ b/3rdparty/LICENSE.cuda @@ -1,6 +1,16 @@ End User License Agreement -------------------------- +The CUDA Toolkit End User License Agreement applies to the +NVIDIA CUDA Toolkit, the NVIDIA CUDA Samples, the NVIDIA +Display Driver, NVIDIA Nsight tools (Visual Studio Edition), +and the associated documentation on CUDA APIs, programming +model and development tools. If you do not agree with the +terms and conditions of the license agreement, then do not +download or use the software. + +Last updated: Mar 24, 2021. + Preface ------- @@ -99,10 +109,6 @@ Windows platform: --------------------------------------------------------- -Release Date: May 21, 2019 --------------------------- - - Important Notice—Read before downloading, installing, copying or using the licensed software: ------------------------------------------------------- @@ -257,6 +263,11 @@ terms, the terms of this Agreement. Copyright to third party software is held by the copyright holders indicated in the third-party software or license. +Subject to the other terms of this Agreement, you may use the +SDK to develop and test applications released under Open +Source Initiative (OSI) approved open source software +licenses. + 1.1.7. Reservation of Rights @@ -304,12 +315,12 @@ SDK: application where the use or failure of the system or application can reasonably be expected to threaten or result in personal injury, death, or catastrophic loss. - Examples include use in nuclear, avionics, navigation, - military, medical, life support or other life critical - applications. NVIDIA does not design, test or manufacture - the SDK for these critical uses and NVIDIA shall not be - liable to you or any third party, in whole or in part, for - any claims or damages arising from such uses. + Examples include use in avionics, navigation, military, + medical, life support or other life critical applications. + NVIDIA does not design, test or manufacture the SDK for + these critical uses and NVIDIA shall not be liable to you + or any third party, in whole or in part, for any claims or + damages arising from such uses. 7. You agree to defend, indemnify and hold harmless NVIDIA and its affiliates, and their respective employees, @@ -328,8 +339,8 @@ SDK: 1. NVIDIA or its licensors hold all rights, title and interest in and to the SDK and its modifications and derivative works, including their respective intellectual - property rights, subject to your rights described here . - This SDK may include software and materials from + property rights, subject to your rights under Section + 1.3.2. This SDK may include software and materials from NVIDIA’s licensors, and these licensors are intended third party beneficiaries that may enforce this Agreement with respect to their intellectual property rights. @@ -338,7 +349,7 @@ SDK: applications and your derivative works of the sample source code delivered in the SDK, including their respective intellectual property rights, subject to - NVIDIA’s rights described here . + NVIDIA’s rights under Section 1.3.1. 3. You may, but don’t have to, provide to NVIDIA suggestions, feature requests or other feedback regarding @@ -519,10 +530,6 @@ parties. NVIDIA Software Development Kits ------------------------------------------------------------ - -Release date: August 16, 2018 ------------------------------ - The terms in this supplement govern your use of the NVIDIA CUDA Toolkit SDK under the terms of your license agreement (“Agreement”) as modified by this supplement. Capitalized @@ -582,8 +589,12 @@ nvidia-compute-license-questions@nvidia.com. 2.6. Attachment A -The following portions of the SDK are distributable under the -Agreement: +The following CUDA Toolkit files may be distributed with +Licensee Applications developed by you, including certain +variations of these files that have version number or +architecture specific information embedded in the file name - +as an example only, for release version 9.0 of the 64-bit +Windows software, the file cudart64_90.dll is redistributable. Component @@ -729,26 +740,6 @@ libcurand.so, libcurand_static.a Component -CUDA Accelerated Graph Library - -Windows - -nvgraph.dll, nvgraph.lib - -Mac OSX - -libnvgraph.dylib, libnvgraph_static.a - -Linux - -libnvgraph.so, libnvgraph_static.a - -Android - -libnvgraph.so, libnvgraph_static.a - -Component - NVIDIA Performance Primitives Library Windows @@ -814,7 +805,11 @@ libculibos.a Component -NVIDIA Runtime Compilation Library +NVIDIA Runtime Compilation Library and Header + +All + +nvrtc.h Windows @@ -914,8 +909,20 @@ NVIDIA CUDA Driver Libraries Linux -libcuda.so, libnvidia-fatbinaryloader.so, -libnvidia-ptxjitcompiler.so +libcuda.so, libnvidia-ptxjitcompiler.so + +Component + +NVIDIA CUDA File IO Libraries and Header + +All + +cufile.h + +Linux + +libcufile.so, libcufile_rdma.so, libcufile_static.a, +libcufile_rdma_static.a The NVIDIA CUDA Driver Libraries are only distributable in applications that meet this criteria: @@ -1062,8 +1069,9 @@ conditions: ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. - 5. Licensee's use of the PCRE third party component is - subject to the following terms and conditions: + 5. Licensee's use (e.g. nvprof) of the PCRE third party + component is subject to the following terms and + conditions: ------------ PCRE LICENCE diff --git a/CMakeLists.txt b/CMakeLists.txt index 478024852..06ac08c85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2021, 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 @@ -120,11 +120,9 @@ superbuild_depend(abseil) superbuild_depend(rmm) # this imports googletest internally #superbuild_depend(googletest) superbuild_depend(googlebenchmark) -#superbuild_depend(gds) superbuild_depend(openslide) superbuild_depend(catch2) superbuild_depend(cli11) -superbuild_depend(pybind11) superbuild_depend(json) ################################################################################ diff --git a/LICENSE-3rdparty.md b/LICENSE-3rdparty.md index 49c07d323..fc899b5be 100644 --- a/LICENSE-3rdparty.md +++ b/LICENSE-3rdparty.md @@ -83,16 +83,11 @@ DLPack - https://github.com/dmlc/dlpack/blob/main/LICENSE - Copyright: DLPack Contributors -NVIDIA CUDA TOOLKIT +NVIDIA CUDA TOOLKIT (including libcufile) - License: NVIDIA License - https://docs.nvidia.com/cuda/pdf/EULA.pdf - Copyright: NVIDIA Corporation -NVIDIA cufile (GDS) -- License: NVIDIA License - - TBD -- Copyright: NVIDIA Corporation - RAPIDS RMM - License: Apache-2.0 License - https://github.com/rapidsai/rmm/blob/branch-0.17/LICENSE diff --git a/README.md b/README.md index e810a29d5..ac0e70447 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ `` should be 11.0+ (e.g., `11.0`, `11.2`, etc.) -**NOTE:** The first cuCIM conda package (v0.19.0) would be available on 4/15/2021. +**NOTE:** The first cuCIM conda package (v0.19.0) would be available on 4/19/2021. #### Conda (nightlies) diff --git a/conda/environments/env.yml b/conda/environments/env.yml index 6dbe3a0c1..1d461f3ed 100644 --- a/conda/environments/env.yml +++ b/conda/environments/env.yml @@ -23,3 +23,4 @@ dependencies: - gcc_linux-64=9 - compilers - click + - yasm # [x86_64] diff --git a/conda/recipes/libcucim/meta.yaml b/conda/recipes/libcucim/meta.yaml index 0ec27f133..a23cdd882 100644 --- a/conda/recipes/libcucim/meta.yaml +++ b/conda/recipes/libcucim/meta.yaml @@ -20,6 +20,7 @@ requirements: build: - cmake >=3.18.0 - {{ compiler("cxx") }} + - yasm # [x86_64] host: - cudatoolkit {{ cuda_version }}.* - openslide diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index c24172f69..c09127c51 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2021, 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 @@ -28,8 +28,6 @@ if(NOT BUILD_SHARED_LIBS) set(BUILD_SHARED_LIBS ON) endif() -set(CMAKE_C_FLAGS "-O2") - ################################################################################ # Set definitions ################################################################################ @@ -110,6 +108,7 @@ target_compile_definitions(${CUCIM_PACKAGE_NAME} CUCIM_VERSION_PATCH=${PROJECT_VERSION_PATCH} CUCIM_VERSION_BUILD=${PROJECT_VERSION_BUILD} CUCIM_SUPPORT_GDS=$ + CUCIM_STATIC_GDS=$ _GLIBCXX_USE_CXX11_ABI=0 # TODO: create two library, one with CXX11 ABI and one without it. ) @@ -118,7 +117,6 @@ target_link_libraries(${CUCIM_PACKAGE_NAME} PUBLIC ${CMAKE_DL_LIBS} $ - $ # $ # $ # $ @@ -128,6 +126,7 @@ target_link_libraries(${CUCIM_PACKAGE_NAME} ## $ PRIVATE deps::abseil + deps::gds ) if (CUCIM_STATIC_GDS) @@ -164,6 +163,7 @@ target_compile_definitions(${CUCIM_PACKAGE_NAME}-header-only CUCIM_VERSION_PATCH=${PROJECT_VERSION_PATCH} CUCIM_VERSION_BUILD=${PROJECT_VERSION_BUILD} CUCIM_SUPPORT_GDS=$ + CUCIM_STATIC_GDS=$ CUCIM_HEADER_ONLY=1 ) target_compile_features(${CUCIM_PACKAGE_NAME}-header-only INTERFACE ${CUCIM_REQUIRED_FEATURES}) diff --git a/cpp/cmake/deps/gds.cmake b/cpp/cmake/deps/gds.cmake deleted file mode 100644 index 57685840a..000000000 --- a/cpp/cmake/deps/gds.cmake +++ /dev/null @@ -1,39 +0,0 @@ -# -# Copyright (c) 2020-2021, 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::gds) - if(NOT GDS_SDK_PATH) - get_filename_component(GDS_SDK_PATH "${CMAKE_SOURCE_DIR}/gds" ABSOLUTE) - message("GDS_SDK_PATH is not set. Using '${GDS_SDK_PATH}'") - else() - message("GDS_SDK_PATH is set to ${GDS_SDK_PATH}") - endif() - - if(EXISTS "${GDS_SDK_PATH}/lib64/libcufile.so") - add_library(deps::gds SHARED IMPORTED GLOBAL) - set_target_properties(deps::gds PROPERTIES - IMPORTED_LOCATION "${GDS_SDK_PATH}/lib64/libcufile.so" - INTERFACE_INCLUDE_DIRECTORIES "${GDS_SDK_PATH}/lib64/" - ) - else() - message("'${GDS_SDK_PATH}/lib64/libcufile.so' is not available. Set CUCIM_SUPPORT_GDS to OFF and import cufile.h only.") - # Do not support GDS - set(CUCIM_SUPPORT_GDS OFF PARENT_SCOPE) - add_library(deps::gds INTERFACE IMPORTED GLOBAL) - set_target_properties(deps::gds PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${GDS_SDK_PATH}/lib64/" - ) - endif() -endif() \ No newline at end of file diff --git a/cpp/include/cucim/filesystem/cufile_driver.h b/cpp/include/cucim/filesystem/cufile_driver.h index c5d9f5d9a..f2ec749cd 100644 --- a/cpp/include/cucim/filesystem/cufile_driver.h +++ b/cpp/include/cucim/filesystem/cufile_driver.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +31,14 @@ using ScopedLock = std::scoped_lock; // Forward declaration. class CuFileDriver; + +/** + * @brief Check if the GDS is available in the system. + * + * @return true if libcufile.so is loaded and cuFileDriverOpen() API call succeeds. + */ +bool EXPORT_VISIBLE is_gds_available(); + /** * Open file with specific flags and mode. * @@ -116,11 +124,11 @@ class CuFileDriverInitializer { return is_available_; } - inline uint64_t max_device_cache_size() + inline uint64_t max_device_cache_size() const { return max_device_cache_size_; } - inline uint64_t max_host_cache_size() + inline uint64_t max_host_cache_size() const { return max_host_cache_size_; } diff --git a/cpp/plugins/cucim.kit.cuslide/.vscode/settings.json b/cpp/plugins/cucim.kit.cuslide/.vscode/settings.json new file mode 100644 index 000000000..e774417ea --- /dev/null +++ b/cpp/plugins/cucim.kit.cuslide/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "cmake.sourceDirectory": "${workspaceFolder}/.", + "cmake.buildDirectory": "${workspaceFolder}/build-debug" +} \ No newline at end of file diff --git a/cpp/plugins/cucim.kit.cuslide/CMakeLists.txt b/cpp/plugins/cucim.kit.cuslide/CMakeLists.txt index a642e177d..75ee847f0 100644 --- a/cpp/plugins/cucim.kit.cuslide/CMakeLists.txt +++ b/cpp/plugins/cucim.kit.cuslide/CMakeLists.txt @@ -1,5 +1,5 @@ # Apache License, Version 2.0 -# Copyright 2020 NVIDIA Corporation +# Copyright 2020-2021 NVIDIA Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -127,7 +127,6 @@ add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0) # TODO: create two library, one with superbuild_depend(fmt) superbuild_depend(libjpeg-turbo) # libjpeg-turbo should be located before libtiff as libtiff depends on libjpeg-turbo superbuild_depend(libtiff) -superbuild_depend(gds) superbuild_depend(catch2) superbuild_depend(openslide) superbuild_depend(googletest) diff --git a/cpp/plugins/cucim.kit.cuslide/cmake/deps/gds.cmake b/cpp/plugins/cucim.kit.cuslide/cmake/deps/gds.cmake deleted file mode 100644 index 57685840a..000000000 --- a/cpp/plugins/cucim.kit.cuslide/cmake/deps/gds.cmake +++ /dev/null @@ -1,39 +0,0 @@ -# -# Copyright (c) 2020-2021, 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::gds) - if(NOT GDS_SDK_PATH) - get_filename_component(GDS_SDK_PATH "${CMAKE_SOURCE_DIR}/gds" ABSOLUTE) - message("GDS_SDK_PATH is not set. Using '${GDS_SDK_PATH}'") - else() - message("GDS_SDK_PATH is set to ${GDS_SDK_PATH}") - endif() - - if(EXISTS "${GDS_SDK_PATH}/lib64/libcufile.so") - add_library(deps::gds SHARED IMPORTED GLOBAL) - set_target_properties(deps::gds PROPERTIES - IMPORTED_LOCATION "${GDS_SDK_PATH}/lib64/libcufile.so" - INTERFACE_INCLUDE_DIRECTORIES "${GDS_SDK_PATH}/lib64/" - ) - else() - message("'${GDS_SDK_PATH}/lib64/libcufile.so' is not available. Set CUCIM_SUPPORT_GDS to OFF and import cufile.h only.") - # Do not support GDS - set(CUCIM_SUPPORT_GDS OFF PARENT_SCOPE) - add_library(deps::gds INTERFACE IMPORTED GLOBAL) - set_target_properties(deps::gds PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${GDS_SDK_PATH}/lib64/" - ) - endif() -endif() \ No newline at end of file diff --git a/cpp/plugins/cucim.kit.cuslide/cmake/deps/libjpeg-turbo-policies-fix.cmake b/cpp/plugins/cucim.kit.cuslide/cmake/deps/libjpeg-turbo-policies-fix.cmake index a95016b9e..ea52c108a 100644 --- a/cpp/plugins/cucim.kit.cuslide/cmake/deps/libjpeg-turbo-policies-fix.cmake +++ b/cpp/plugins/cucim.kit.cuslide/cmake/deps/libjpeg-turbo-policies-fix.cmake @@ -1,5 +1,5 @@ # Apache License, Version 2.0 -# Copyright 2020 NVIDIA Corporation +# Copyright 2020-2021 NVIDIA Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,5 +18,6 @@ cmake_policy(SET CMP0048 NEW) # project() command manages VERSION variables. for libjpeg-turbo cmake_policy(SET CMP0054 NEW) # cmake-build-debug/_deps/deps-libjpeg-turbo-src/cmakescripts/GNUInstallDirs.cmake:174 (elseif): cmake_policy(SET CMP0063 NEW) # Honor the visibility properties for all target types including static library. +cmake_policy(SET CMP0077 NEW) # Use normal variable that is injected, instead of ignoring/clearing normal variable: REQUIRE_SIMD/CMAKE_ASM_NASM_COMPILER. # https://cmake.org/cmake/help/v3.18/policy/CMP0065.html : Do not add flags to export symbols from executables without the ENABLE_EXPORTS target property. # : this policy is not handled yet so always enable exports. \ No newline at end of file diff --git a/cpp/plugins/cucim.kit.cuslide/cmake/deps/libjpeg-turbo.cmake b/cpp/plugins/cucim.kit.cuslide/cmake/deps/libjpeg-turbo.cmake index faf4d0ea7..2d4dbe3e8 100644 --- a/cpp/plugins/cucim.kit.cuslide/cmake/deps/libjpeg-turbo.cmake +++ b/cpp/plugins/cucim.kit.cuslide/cmake/deps/libjpeg-turbo.cmake @@ -1,5 +1,5 @@ # Apache License, Version 2.0 -# Copyright 2020 NVIDIA Corporation +# Copyright 2020-2021 NVIDIA Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -43,8 +43,10 @@ if (NOT TARGET deps::libjpeg-turbo) # Tell CMake where to find the compiler by setting either the environment # variable "ASM_NASM" or the CMake cache entry CMAKE_ASM_NASM_COMPILER to the # full path to the compiler, or to the compiler name if it is in the PATH. - # nasm is available through `sudo apt-get install nasm` on Debian Linux. - set(REQUIRE_SIMD 1) + # yasm is available through `sudo apt-get install yasm` on Debian Linux. + # See _deps/deps-libjpeg-turbo-src/simd/CMakeLists.txt:25. + set(CMAKE_ASM_NASM_COMPILER yasm) + set(REQUIRE_SIMD 1) # CMP0077 add_subdirectory(${deps-libjpeg-turbo_SOURCE_DIR} ${deps-libjpeg-turbo_BINARY_DIR} EXCLUDE_FROM_ALL) diff --git a/cpp/src/cuimage.cpp b/cpp/src/cuimage.cpp index 537009990..eb2df85dc 100644 --- a/cpp/src/cuimage.cpp +++ b/cpp/src/cuimage.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -313,7 +313,7 @@ std::vector CuImage::size(std::string dim_order) const { if (dim_order.empty()) { - dim_order = std::move(std::string(image_metadata_->dims)); + dim_order = std::string(image_metadata_->dims); } result_size.reserve(dim_order.size()); @@ -359,7 +359,7 @@ std::vector CuImage::spacing(std::string dim_order) const { if (dim_order.empty()) { - dim_order = std::move(std::string(image_metadata_->dims)); + dim_order = std::string(image_metadata_->dims); result_spacing.reserve(dim_order.size()); } @@ -395,7 +395,7 @@ std::vector CuImage::spacing_units(std::string dim_order) const { if (dim_order.empty()) { - dim_order = std::move(std::string(image_metadata_->dims)); + dim_order = std::string(image_metadata_->dims); result_spacing_units.reserve(dim_order.size()); } diff --git a/cpp/src/filesystem/cufile_driver.cpp b/cpp/src/filesystem/cufile_driver.cpp index da3a95367..dfea2ea00 100644 --- a/cpp/src/filesystem/cufile_driver.cpp +++ b/cpp/src/filesystem/cufile_driver.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -105,6 +105,11 @@ static int get_file_flags(const char* flags) return file_flags; } +bool is_gds_available() +{ + return static_cast(s_cufile_initializer); +} + std::shared_ptr open(const char* file_path, const char* flags, mode_t mode) { bool use_o_direct = true; diff --git a/cucim.code-workspace b/cucim.code-workspace index 016c2bda4..fa4cdf08a 100644 --- a/cucim.code-workspace +++ b/cucim.code-workspace @@ -30,7 +30,7 @@ "env": { "CUCIM_TESTDATA_FOLDER": "${workspaceDirectory}/test_data", // Add cuslide plugin's library path to LD_LIBRARY_PATH - "LD_LIBRARY_PATH": "${workspaceDirectory}/build-debug/lib:${workspaceDirectory}/cpp/plugins/cucim.kit.cuslide/build-debug/lib:${os_env:LD_LIBRARY_PATH}", + "LD_LIBRARY_PATH": "${workspaceDirectory}/build-debug/lib:${workspaceDirectory}/cpp/plugins/cucim.kit.cuslide/build-debug/lib:${workspaceDirectory}/temp/cuda/lib64:${os_env:LD_LIBRARY_PATH}", "CUCIM_TEST_PLUGIN_PATH": "cucim.kit.cuslide@0.19.0.so" }, "cwd": "${workspaceDirectory}", @@ -126,7 +126,10 @@ "__tree": "cpp", "queue": "cpp", "stack": "cpp" - } + }, + // https://vector-of-bool.github.io/docs/vscode-cmake-tools/settings.html + "cmake.buildTask": true, + "cmake.buildDirectory": "${workspaceFolder}/build-debug" }, "tasks": { "version": "2.0.0", diff --git a/gds/CMakeLists.txt b/gds/CMakeLists.txt index 6c6d907ea..b8a959840 100644 --- a/gds/CMakeLists.txt +++ b/gds/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2021, 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 @@ -61,47 +61,68 @@ target_compile_options(cufile_stub ) ## Link libraries - target_link_libraries(cufile_stub - PUBLIC - ${CMAKE_DL_LIBS} - ) +target_link_libraries(cufile_stub + PUBLIC + ${CMAKE_DL_LIBS} + ) + +# 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 the current folder. +# under ../temp/cuda folder. if (CUCIM_STATIC_GDS) add_library(deps::gds_static STATIC IMPORTED GLOBAL) - set(GDS_STATIC_LIB_PATH ${CMAKE_CURRENT_LIST_DIR}/lib/libcufile_static.a) + + 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 "${CMAKE_CURRENT_LIST_DIR}/include" + INTERFACE_INCLUDE_DIRECTORIES "${GDS_INCLUDE_PATH}" ) target_link_libraries(cufile_stub - PUBLIC - ${CMAKE_DL_LIBS} - INTERFACE - $ - ) - - target_compile_definitions(cufile_stub PUBLIC - CUCIM_STATIC_GDS=1 + ${CMAKE_DL_LIBS} + PRIVATE + deps::gds_static ) - target_include_directories(cufile_stub - PUBLIC - $ - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../cpp/include # for including helper.h in cucim/dynlib - ) -else() - target_include_directories(cufile_stub - PUBLIC - # add path to cufile.h explicitly. ${TOP}/temp/gds would be available by `./run copy_gds_files_` - $ - $ - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../cpp/include # for including helper.h in cucim/dynlib - ) endif() +target_compile_definitions(cufile_stub +PUBLIC + CUCIM_SUPPORT_GDS=$ + CUCIM_STATIC_GDS=$ +) + +target_include_directories(cufile_stub + PUBLIC + $ + $ + 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 +) + add_library(deps::gds ALIAS cufile_stub) # Do not generate SONAME as this would be used as a stub library for building on CentOS until cufile has a static library. diff --git a/python/.vscode/settings.json b/python/.vscode/settings.json new file mode 100644 index 000000000..e774417ea --- /dev/null +++ b/python/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "cmake.sourceDirectory": "${workspaceFolder}/.", + "cmake.buildDirectory": "${workspaceFolder}/build-debug" +} \ No newline at end of file diff --git a/python/cucim/CHANGELOG.md b/python/cucim/CHANGELOG.md index 251e28728..c92544121 100644 --- a/python/cucim/CHANGELOG.md +++ b/python/cucim/CHANGELOG.md @@ -1,11 +1,14 @@ # Changelog -## 0.19.0 (2021-04-15) +## 0.19.0 (2021-04-19) - The first release of cuClaraImage + [cupyimg](https://github.com/mritools/cupyimg) as a single project `cuCIM`. - `cucim.skimage` package is added from `cupyimg`. - CuPy (>=9.0.0b3), scipy, scikit-image is required to use cuCIM's scikit-image-compatible API. + +## 0.18.3 (2021-04-16) + - Fix memory leaks that occur when reading completely out-of-boundary regions. ## 0.18.2 (2021-03-29) diff --git a/python/cucim/docs/release_notes/index.md b/python/cucim/docs/release_notes/index.md index 2e2844884..84183cc4d 100644 --- a/python/cucim/docs/release_notes/index.md +++ b/python/cucim/docs/release_notes/index.md @@ -6,6 +6,7 @@ :maxdepth: 2 v0.19.0 +v0.18.3 v0.18.2 v0.18.1 v0.18.0 @@ -28,6 +29,7 @@ v0.19.0 ```{toctree} :maxdepth: 2 +v0.18.3 v0.18.2 v0.18.1 v0.18.0 diff --git a/python/cucim/docs/release_notes/v0.18.3.md b/python/cucim/docs/release_notes/v0.18.3.md new file mode 100644 index 000000000..c3dead3c1 --- /dev/null +++ b/python/cucim/docs/release_notes/v0.18.3.md @@ -0,0 +1,5 @@ +# Version 0.18.3 (April 16, 2021) + +## Fixes + +- Fix memory leaks that occur when reading completely out-of-boundary regions. diff --git a/python/cucim/docs/release_notes/v0.19.0.md b/python/cucim/docs/release_notes/v0.19.0.md index f4ff08115..00b2b5083 100644 --- a/python/cucim/docs/release_notes/v0.19.0.md +++ b/python/cucim/docs/release_notes/v0.19.0.md @@ -1,11 +1,7 @@ -# Version 0.19.0 (April 15, 2021) +# Version 0.19.0 (April 19, 2021) ## What's new? - The first release of cuClaraImage + [cupyimg](https://github.com/mritools/cupyimg) as a single project `cuCIM`. - `cucim.skimage` package is added from `cupyimg`. - CuPy (>=9.0.0b3), scipy, scikit-image is required to use cuCIM's scikit-image-compatible API. - -## Fixes - -- Fix memory leaks that occur when reading completely out-of-boundary regions. diff --git a/python/cucim/src/localtest.py b/python/cucim/src/localtest.py index 324013205..e6c524279 100644 --- a/python/cucim/src/localtest.py +++ b/python/cucim/src/localtest.py @@ -23,7 +23,9 @@ from cucim import CuImage -img = CuImage("notebooks/0486052bb.tiff") +input_file = "notebooks/input/image.tif" + +img = CuImage(input_file) # True if image data is loaded & available. print(img.is_loaded) # A device type. @@ -93,7 +95,6 @@ def __exit__(self, exc_type, exc, exc_tb): num_threads = 1 # os.cpu_count() -input_file = "notebooks/0486052bb.tiff" start_location = 0 tile_size = 256 diff --git a/python/pybind11/filesystem/filesystem_py.cpp b/python/pybind11/filesystem/filesystem_py.cpp index 69767ad69..e78a22803 100644 --- a/python/pybind11/filesystem/filesystem_py.cpp +++ b/python/pybind11/filesystem/filesystem_py.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,11 +60,12 @@ void init_filesystem(py::module& fs) return fmt::format("", fd.path()); }); - fs.def("open", &py_open, doc::doc_open, - py::arg("file_path"), // - py::arg("flags"), // - py::arg("mode") = 0644, // - py::call_guard()) + fs.def("is_gds_available", &is_gds_available, doc::doc_is_gds_available, py::call_guard()) + .def("open", &py_open, doc::doc_open, + py::arg("file_path"), // + py::arg("flags"), // + py::arg("mode") = 0644, // + py::call_guard()) .def("pread", &py_pread, doc::doc_pread, // Do not release GIL as it would access properties of python object py::arg("fd"), // py::arg("buf"), // diff --git a/python/pybind11/filesystem/filesystem_pydoc.h b/python/pybind11/filesystem/filesystem_pydoc.h index a79e08f29..c39a74744 100644 --- a/python/pybind11/filesystem/filesystem_pydoc.h +++ b/python/pybind11/filesystem/filesystem_pydoc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,16 @@ namespace cucim::filesystem::doc { + +// bool is_gds_available(); +PYDOC(is_gds_available, R"doc( +Check if the GDS is available in the system. + +Returns: + True if libcufile.so is loaded and cuFileDriverOpen() API call succeeds. +)doc") + + // std::shared_ptr open(const char* file_path, const char* flags = "r", mode_t mode = 0644); PYDOC(open, R"doc( Open file with specific flags and mode. diff --git a/run b/run index ce60653c2..fde4610cc 100755 --- a/run +++ b/run @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2021, 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 @@ -266,7 +266,7 @@ build_local_libcucim_() { pushd ${source_folder} > /dev/null - # Copy cufile SDK from host system to temp/gds + # Copy cufile SDK from host system to temp/cuda copy_gds_files_ $source_folder ${CMAKE_CMD} -S ${source_folder} -B ${build_folder} -G "Unix Makefiles" \ @@ -389,24 +389,43 @@ build_local() { copy_gds_files_() { local root_folder=${1:-${TOP}} + local cufile_search="${root_folder}/temp/cuda/include:${root_folder}/temp/cuda/lib64" #"/usr/local/cuda/include:/usr/local/cuda/lib64 ${PREFIX:-}/include:${PREFIX:-}/lib ${CONDA_PREFIX:-}/include:${CONDA_PREFIX:-}/lib ${root_folder}/temp/cuda/include:${root_folder}/temp/cuda/lib64" + 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 - run_command rm -rf ${root_folder}/temp/gds - run_command mkdir -p ${root_folder}/temp/gds/lib64 + 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." - if [ ! -f /usr/local/cuda/lib64/cufile.h ] && [ ! -f /usr/local/cuda/lib64/libcufile.so ]; then - c_echo_err Y "GDS is not available at /usr/local/cuda/gds! Downloading internal package to get cufile.h" + run_command rm -rf ${root_folder}/temp/cuda + run_command mkdir -p ${root_folder}/temp/cuda/include ${root_folder}/temp/cuda/lib64 - local temp_deb_dir=$(mktemp -d) - pushd ${temp_deb_dir} - run_command wget https://developer.download.nvidia.com/gds/redist/ # TODO: update this once the official file is available. - run_command ar x libcufile-dev-11-0_0.95.0.34-1_amd64.deb - run_command tar xvf *.tar.xz - run_command cp usr/local/cuda-11.0/targets/x86_64-linux/lib/cufile.h ${root_folder}/temp/gds/lib64/ + local temp_tgz_dir=$(mktemp -d) + pushd ${temp_tgz_dir} + run_command wget https://developer.download.nvidia.com/gds/redist/rel-0.95.0/gds-redistrib-0.95.0.tgz + run_command tar xzvf gds-redistrib-0.95.0.tgz + run_command cp -P gds-redistrib-0.95.0/targets/x86_64-linux/include/cufile.h ${root_folder}/temp/cuda/include/ + run_command cp -P gds-redistrib-0.95.0/targets/x86_64-linux/lib/* ${root_folder}/temp/cuda/lib64/ popd > /dev/null - run_command rm -r ${temp_deb_dir} + run_command rm -r ${temp_tgz_dir} else - run_command cp -P -r /usr/local/cuda/gds/* ${root_folder}/temp/gds/ || true - run_command cp -P /usr/local/cuda/lib64/cufile.h /usr/local/cuda/lib64/libcufile* ${root_folder}/temp/gds/lib64/ || true + 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 } @@ -420,7 +439,7 @@ build_python_package() { local old_opt="$(shopt -op errexit);$(shopt -op nounset)" # save old shopts set -eu - # Copy cufile SDK from host system to temp/gds + # Copy cufile SDK from host system to temp/cuda copy_gds_files_ run_command ${TOP}/dockcross-manylinux2014-x64 ./run build_python_package_ @@ -453,6 +472,12 @@ build_python_package_() { local old_opt="$(shopt -op errexit);$(shopt -op nounset)" # save old shopts set -eu + # Clear CMakeCache.txt to use the latest options + run_command rm -f ${BUILD_ROOT}/libcucim/CMakeCache.txt + run_command rm -f ${BUILD_ROOT}/cuslide/CMakeCache.txt + run_command rm -f ${BUILD_ROOT}/cucim/CMakeCache.txt + + # Create a folder for .whl file that repair_wheel_ is not applied. TEMP_PYPKG_DIR=${BUILD_ROOT}/py_pkg # $(mktemp -d) c_echo b "TEMP_PYPKG_DIR=${TEMP_PYPKG_DIR}" mkdir -p $TEMP_PYPKG_DIR @@ -475,6 +500,7 @@ build_python_package_() { rm -rf ${BUILD_ROOT}/cuslide/lib/* rm -rf ${BUILD_ROOT}/cuslide/install/lib*/cucim* rm -rf ${BUILD_ROOT}/cucim/lib/cucim/*.so* + rm -rf ${BUILD_ROOT}/cucim/install/lib/*.so* # Build libcucim ${CMAKE_CMD} -S ${SRC_ROOT} -B ${BUILD_ROOT}/libcucim \ @@ -651,9 +677,9 @@ download_testdata() { launch_notebooks_desc() { echo 'Launch jupyter notebooks Arguments: - -p - port number - -h - hostname to serve documentation on (default: 0.0.0.0) - -g - launch GDS-enabled container + -p - port number + -h - hostname to serve documentation on (default: 0.0.0.0) + -g - launch GDS-enabled container ' } launch_notebooks() { @@ -678,7 +704,7 @@ launch_notebooks() { gds_nvme_path=$(readlink -f "$OPTARG") [ ! -d "$gds_nvme_path" ] && c_echo_err R "Folder $gds_nvme_path doesn't exist!" && return 1 - # Copy cufile SDK from host system to temp/gds + # Copy cufile SDK from host system to temp/cuda copy_gds_files_ ;; *) @@ -748,6 +774,18 @@ launch_notebooks() { # Section: Documentation #================================================================================== +install_tox_() { + if ! command -v tox > /dev/null; then + c_echo G "tox" W " doesn't exists. Installing " G "tox" W "..." + if [ -n "${CONDA_PREFIX}" ]; then + run_command pip3 install tox + else + run_command pip3 install --user tox + fi + hash -r + fi +} + gen_docs_desc() { echo 'Generate document Generated docs would be avaialable at ${TOP}/dist/docs. @@ -764,6 +802,9 @@ gen_docs() { local ret=0 pushd ${TOP}/python/cucim > /dev/null + # Install prerequisites + install_tox_ + # Remove existing files in dist/docs run_command rm -rf ${OUTPUT_FOLDER}/* @@ -822,6 +863,9 @@ gen_docs_dev() { pushd ${TOP}/python/cucim > /dev/null + # Install prerequisites + install_tox_ + # Remove existing files in python/cucim/dist/docs run_command rm -rf ${TOP}/python/cucim/dist/docs/* # Copy notebook files to python/cucim/dist/docs/notebooks @@ -915,7 +959,11 @@ bump_version() { if ! command -v bump2version > /dev/null; then c_echo G "bump2version" W " doesn't exists. Installing " G "bump2version" W "..." - run_command pip3 install --user bump2version + if [ -n "${CONDA_PREFIX}" ]; then + run_command pip3 install bump2version + else + run_command pip3 install --user bump2version + fi hash -r fi