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

NEW: Add recipe for libnvimgcodec #27546

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci_support/linux64_cuda120.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ docker_image:
cuda_compiler:
- cuda-nvcc
cuda_compiler_version:
- 12.0
- 12.6
cuda_compiler_version_min:
- 11.8
62 changes: 62 additions & 0 deletions recipes/libnvimgcodec/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
@echo on
REM Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
REM Licensed under the Apache License, Version 2.0 (the "License");

setlocal enabledelayedexpansion

mkdir build

cd build

if errorlevel 1 exit 1

set CUDAARCHS="50"

set NVIMG_BUILD_ARGS= ^
-DBUILD_DOCS:BOOL=OFF ^
-DBUILD_SAMPLES:BOOL=OFF ^
-DBUILD_TEST:BOOL=OFF ^
-DCUDA_TARGET_ARCHS=%CUDAARCHS%

set NVIMG_LIBRARY_ARGS= ^
-DBUILD_LIBRARY:BOOL=ON ^
-DBUILD_SHARED_LIBS:BOOL=ON ^
-DBUILD_STATIC_LIBS:BOOL=OFF ^
-DWITH_DYNAMIC_LINK:BOOL=OFF

set NVIMG_EXT_ARGS= ^
-DBUILD_EXTENSIONS:BOOL=ON ^
-DBUILD_LIBJPEG_TURBO_EXT:BOOL=ON ^
-DBUILD_LIBTIFF_EXT:BOOL=ON ^
-DBUILD_NVBMP_EXT:BOOL=ON ^
-DBUILD_NVJPEG_EXT:BOOL=ON ^
-DBUILD_NVJPEG2K_EXT:BOOL=ON ^
-DBUILD_NVPNM_EXT:BOOL=ON ^
-DBUILD_NVTIFF_EXT:BOOL=OFF ^
-DBUILD_OPENCV_EXT:BOOL=ON

set NVIMG_PYTHON_ARGS= ^
-DPython_EXECUTABLE=%PYTHON% ^
-DBUILD_PYTHON:BOOL=OFF ^
-DPYTHON_VERSIONS=%PY_VER% ^
-DBUILD_WHEEL:BOOL=OFF ^
-DNVIMGCODEC_COPY_LIBS_TO_PYTHON_DIR:BOOL=OFF ^
-DNVIMGCODEC_BUILD_PYBIND11:BOOL=OFF ^
-DNVIMGCODEC_BUILD_DLPACK:BOOL=OFF

cmake %CMAKE_ARGS% -GNinja -DCMAKE_INSTALL_PREFIX="%PREFIX%/Library" ^
%NVIMG_BUILD_ARGS% %NVIMG_LIBRARY_ARGS% %NVIMG_EXT_ARGS% ^
%NVIMG_PYTHON_ARGS% %SRC_DIR%

if errorlevel 1 exit 1

cmake --build .

if errorlevel 1 exit 1

cmake --install .

del %PREFIX%/Library/LICENSE.txt
del %PREFIX%/Library/Acknowledgements.txt

endlocal
61 changes: 61 additions & 0 deletions recipes/libnvimgcodec/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#! bash
# Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# 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.

set -ex

mkdir build
cd build

export CUDAARCHS="50"

nvimg_build_args=(
Copy link
Member Author

Choose a reason for hiding this comment

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

Are there any build options missing?

-DBUILD_DOCS:BOOL=OFF
-DBUILD_SAMPLES:BOOL=OFF
-DBUILD_TEST:BOOL=OFF
-DCUDA_TARGET_ARCHS=${CUDAARCHS}
# Library args
-DBUILD_LIBRARY:BOOL=ON
-DBUILD_SHARED_LIBS:BOOL=ON
-DBUILD_STATIC_LIBS:BOOL=OFF
# "DYNAMIC_LINK" means using dlopen, but we want to link to shared libraries.
-DWITH_DYNAMIC_LINK:BOOL=OFF
# Extension args
-DBUILD_EXTENSIONS:BOOL=ON
-DBUILD_LIBJPEG_TURBO_EXT:BOOL=ON
-DBUILD_LIBTIFF_EXT:BOOL=ON
-DBUILD_NVBMP_EXT:BOOL=ON
-DBUILD_NVJPEG_EXT:BOOL=ON
-DBUILD_NVJPEG2K_EXT:BOOL=ON
-DBUILD_NVPNM_EXT:BOOL=ON
-DBUILD_NVTIFF_EXT:BOOL=ON
-DBUILD_OPENCV_EXT:BOOL=ON
# Python args
-DPython_EXECUTABLE=$PYTHON
-DBUILD_PYTHON:BOOL=OFF
-DPYTHON_VERSIONS="${PY_VER}"
-DBUILD_WHEEL:BOOL=OFF
-DNVIMGCODEC_COPY_LIBS_TO_PYTHON_DIR:BOOL=OFF
-DNVIMGCODEC_BUILD_PYBIND11:BOOL=OFF
-DNVIMGCODEC_BUILD_DLPACK:BOOL=OFF
)

cmake ${CMAKE_ARGS} -GNinja "${nvimg_build_args[@]}" ${SRC_DIR}

cmake --build .

cmake --install . --strip

rm $PREFIX/LICENSE.txt
rm $PREFIX/Acknowledgements.txt
169 changes: 169 additions & 0 deletions recipes/libnvimgcodec/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
# Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# 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.
{% set version = '0.5.0' %}
{% set somajor = version.split('.')[0] %}
{% set cuda_major = environ.get("cuda_compiler_version", "11.8").split(".")[0]|int %}

package:
name: libnvimgcodec-split
version: {{ version }}

source:
url: https://github.com/NVIDIA/nvImageCodec/archive/refs/tags/v{{ version }}.tar.gz
sha256: 4bba949d6cf4e88fcd6b2d86bff960c9ed68eb25b6c4dde3b7772615480ab9fb
patches:
- patches/0002-BLD-Use-only-dynamic-shared-library-links-to-CUDA-ta.patch
- patches/001-move-config.patch
build:
number: 0
skip: true # [cuda_compiler_version in (undefined, 'None')]
# Debug skips below
# skip: true # [py != 312]
requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cuda') }}
- {{ compiler('cxx') }}
- {{ stdlib('c') }}
# Must use 3.18 because of changes in find_package(TIFF) - @carterbox Jan 2025
- cmake 3.18.* # [win]
- cmake # [not win]
- ninja
- pkg-config
host:
- cuda-version {{ cuda_compiler_version }}
- libboost-headers
- libjpeg-turbo
{% if cuda_major == 12 %}
- cuda-driver-dev # [linux]
- cuda-cudart-dev
- libnvjpeg-dev
Copy link
Member Author

Choose a reason for hiding this comment

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

Should dependencies linked with dlopen be made optional or converted to standard dynamic links?

- libnvjpeg2k-dev
- libnvtiff-dev
{% endif %}
- libopencv
Copy link
Member Author

Choose a reason for hiding this comment

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

Strongly consider making opencv optional for users because it is heavy

- libtiff
- nvtx-c
- zlib
- zstd

outputs:

- name: libnvimgcodec-dev
build:
run_exports:
- {{ pin_subpackage('libnvimgcodec' ~ somajor) }}
files:
# This recipe requires conda-build 24.7 or later
include:
- include/** # [linux]
- lib/libnvimgcodec.so # [linux]
- lib/cmake/nvimgcodec # [linux]
- etc/** # [linux]
- extensions/*.so # [linux]
Copy link
Member Author

Choose a reason for hiding this comment

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

is PREFIX/extensions the "correct" place to install these modules?

# FIXME: Drop static libraries once CMake config supports it
- lib/libnvimgcodec_static.a # [linux]
- Library/include/** # [win]
- Library/lib/nvimgcodec.lib # [win]
- Library/lib/cmake/nvimgcodec # [win]
- Library/etc/** # [win]
- Library/extensions/*.lib # [win]
# FIXME: Drop static libraries once CMake config supports it
- Library/lib/nvimgcodec_static.lib # [win]
exclude:
- lib/python* # [linux]
- lib/libnvimgcodec.so.* # [linux]
- extensions/*.so.* # [linux]
requirements:
host:
- {{ pin_subpackage('libnvimgcodec' ~ somajor, exact=True) }}
run:
- {{ pin_subpackage('libnvimgcodec' ~ somajor, exact=True) }}
test:
files:
- test
requires: # [build_platform == target_platform]
- {{ compiler('c') }} # [build_platform == target_platform]
- {{ compiler('cxx') }} # [build_platform == target_platform]
- {{ compiler('cuda') }} # [build_platform == target_platform]
- {{ stdlib('c') }} # [build_platform == target_platform]
- cmake # [build_platform == target_platform]
- ninja # [build_platform == target_platform]
{% if cuda_major == 12 %}
- cuda-cudart-dev # [build_platform == target_platform]
{% endif %}
commands:
- test -f ${PREFIX}/include/nvimgcodec.h # [linux]
- if not exist %LIBRARY_INC%\\nvimgcodec.h exit 1 # [win]
- test -f ${PREFIX}/lib/libnvimgcodec.so.{{ somajor }} # [linux]
- test -f ${PREFIX}/lib/libnvimgcodec.so.{{ version }} # [linux]
- if not exist %LIBRARY_LIB%\\nvimgcodec.lib exit 1 # [win]
- test -f ${PREFIX}/etc/ld.so.conf.d/nvimgcodec.conf # [unix]
- test -f ${PREFIX}/lib/cmake/nvimgcodec/nvimgcodecConfig.cmake # [unix]
- cmake ${CMAKE_ARGS} -GNinja test # [build_platform == target_platform]
- cmake --build . # [build_platform == target_platform]
# - test ! -f ${PREFIX}/lib/libnvimgcodec_static.a # [unix]

- name: libnvimgcodec{{ somajor }}
files:
- lib/libnvimgcodec.so.* # [linux]
- extensions/*.so.* # [linux]
- Library/bin/nvimgcodec_{{ somajor }}.dll # [win]
- Library/extensions/*.dll # [win]
build:
ignore_run_exports_from:
- {{ compiler('cuda') }}
requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cuda') }}
- {{ compiler('cxx') }}
- {{ stdlib('c') }}
host:
- cuda-version {{ cuda_compiler_version }}
- libjpeg-turbo
{% if cuda_major == 12 %}
- cuda-driver-dev # [linux]
- cuda-cudart-dev
- libnvjpeg-dev
- libnvjpeg2k-dev
- libnvtiff-dev
{% endif %}
- libopencv
- libtiff
run:
- {{ pin_compatible('cuda-version', min_pin='x', max_pin='x') }}
test:
commands:
- test -f ${PREFIX}/lib/libnvimgcodec.so.{{ somajor }} # [linux]
- test -f ${PREFIX}/lib/libnvimgcodec.so.{{ version }} # [linux]
- if not exist %LIBRARY_BIN%\\nvimgcodec_{{ somajor }}.dll exit 1 # [win]

about:
home: https://github.com/NVIDIA/nvImageCodec
summary: The C API for nvImageCodec.
description: >
The nvImageCodec is an open-source library of accelerated codecs with
unified interface. This package is the C-API only. See nvimgcodec for the
Python-API.
license: Apache-2.0
license_family: APACHE
license_file:
- LICENSE.txt
- Acknowledgements.txt

extra:
feedstock-name: libnvimgcodec
recipe-maintainers:
- conda-forge/cuda
Loading