Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of ImageDecoder (required nvImageCodec >= 0.4.0) #5576

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
11 changes: 6 additions & 5 deletions cmake/Dependencies.common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,9 @@ endif()
##################################################################
set(DALI_INSTALL_REQUIRES_NVIMGCODEC "")
if(BUILD_NVIMAGECODEC)
set(NVIMGCODEC_MIN_VERSION "0.3.0")
set(NVIMGCODEC_MAX_VERSION "0.4.0")
set(NVIMGCODEC_MIN_VERSION "0.4.0")
set(NVIMGCODEC_MAX_VERSION "0.5.0")
message(STATUS "nvImageCodec - requires version >=${NVIMGCODEC_MIN_VERSION}, <${NVIMGCODEC_MAX_VERSION}")
if (WITH_DYNAMIC_NVIMGCODEC)
message(STATUS "nvImageCodec - dynamic load")

Expand All @@ -288,8 +289,8 @@ if(BUILD_NVIMAGECODEC)
include(FetchContent)
FetchContent_Declare(
nvimgcodec_headers
URL https://developer.download.nvidia.com/compute/nvimgcodec/redist/nvimgcodec/linux-x86_64/nvimgcodec-linux-x86_64-0.3.0.5-archive.tar.xz
URL_HASH SHA512=259bff93305c301fb4325c6e2f71da93f3f6e0b38c7c8739913ca70b5a9c74cc898a608c5ac6e830dba1739878e53607ded03deaf2f23af3a9cc473463f100eb
URL https://developer.download.nvidia.com/compute/nvimgcodec/redist/nvimgcodec/linux-x86_64/nvimgcodec-linux-x86_64-0.4.0.9-archive.tar.xz
URL_HASH SHA512=d1dc489b6f6795548ec88293cc3e08034fc5bca636f134d622c9f2c3f54569b8779464ab7628ea3dfaad283ff631962ef0601354ff5e2c602a769beb44f19f00
)
FetchContent_Populate(nvimgcodec_headers)
set(nvimgcodec_SEARCH_PATH "${nvimgcodec_headers_SOURCE_DIR}/${CUDA_VERSION_MAJOR}/include")
Expand Down Expand Up @@ -321,7 +322,7 @@ if(BUILD_NVIMAGECODEC)
ExternalProject_Add(
nvImageCodec
GIT_REPOSITORY https://github.com/NVIDIA/nvImageCodec.git
GIT_TAG v0.3.0
GIT_TAG v0.4.0
GIT_SUBMODULES "external/pybind11"
"external/NVTX"
"external/googletest"
Expand Down
4 changes: 2 additions & 2 deletions conda/third_party/dali_nvimagecodec/recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
# limitations under the License.


{% set build_version = "0.3.0" %}
{% set build_version = "0.4.0" %}

package:
name: nvidia-nvimagecodec-cuda{{ environ.get('CUDA_VERSION', '') | replace(".","") }}
version: {{ build_version }}

source:
git_url: https://github.com/NVIDIA/nvImageCodec.git
git_rev: v0.3.0
git_rev: v0.4.0

build:
number: 0
Expand Down
11 changes: 11 additions & 0 deletions dali/core/cuda_event_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <utility>
#include "dali/core/cuda_event_pool.h"
#include "dali/core/cuda_error.h"
#include "dali/core/math_util.h"

namespace dali {

Expand All @@ -29,6 +30,16 @@ CUDAEventPool::CUDAEventPool(unsigned event_flags) {
int num_devices = 0;
CUDA_CALL(cudaGetDeviceCount(&num_devices));
dev_events_.resize(num_devices);
// Avoid creation of events during pipeline run
int evt_pool_init_sz = 2000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: where do we get this default from? Did you take it based on the pool size for some run?

Is this pool per proces or per pipeline instance?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the pool is global. It is a rather arbitrary number. @mzient to comment if this is a sensible value.

if (const char *evt_pool_init_sz_env = std::getenv("DALI_EVENT_POOL_INITIAL_SIZE")) {
klecki marked this conversation as resolved.
Show resolved Hide resolved
evt_pool_init_sz = clamp(atoi(evt_pool_init_sz_env), 0, 10000);
}
for (int device_id = 0; device_id < num_devices; device_id++) {
for (int i = 0; i < evt_pool_init_sz; i++) {
Put(CUDAEvent::CreateWithFlags(cudaEventDisableTiming), device_id);
}
}
}

CUDAEvent CUDAEventPool::Get(int device_id) {
Expand Down
Loading
Loading