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 libnvjpeg2k #28142

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 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
17 changes: 17 additions & 0 deletions recipes/nvjpeg2k/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

:: Relocate CUDA major specific libraries to single prefix layout

for /f "tokens=1 delims=." %%a in ("%cuda_version%") do (
set "CUDA_MAJOR=%%a"
break
)

move lib lib.backup
move lib.backup\%CUDA_MAJOR% lib
del lib.backup

if not exist %PREFIX% mkdir %PREFIX%

move lib\*.lib %LIBRARY_LIB%
move lib\*.dll %LIBRARY_BIN%
move include\* %LIBRARY_INC%
44 changes: 44 additions & 0 deletions recipes/nvjpeg2k/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# Relocate CUDA major specific libraries to single prefix layout
export CUDA_MAJOR=${cuda_version%%.*}
mv -v lib lib.backup
mv -v lib.backup/${CUDA_MAJOR} lib
rm -rv lib.backup

# Install to conda style directories
[[ -d lib64 ]] && mv lib64 lib
mkdir -p ${PREFIX}/lib
[[ -d pkg-config ]] && mv pkg-config ${PREFIX}/lib/pkgconfig
[[ -d "$PREFIX/lib/pkgconfig" ]] && sed -E -i "s|cudaroot=.+|cudaroot=$PREFIX|g" $PREFIX/lib/pkgconfig/nvjpeg*.pc

[[ ${target_platform} == "linux-64" ]] && targetsDir="targets/x86_64-linux"
[[ ${target_platform} == "linux-ppc64le" ]] && targetsDir="targets/ppc64le-linux"
[[ ${target_platform} == "linux-aarch64" ]] && targetsDir="targets/sbsa-linux"
# [[ ${target_platform} == "linux-aarch64" ]] && targetsDir="targets/aarch64-linux"

for i in `ls`; do
[[ $i == "build_env_setup.sh" ]] && continue
[[ $i == "conda_build.sh" ]] && continue
[[ $i == "metadata_conda_debug.yaml" ]] && continue
if [[ $i == "lib" ]] || [[ $i == "include" ]]; then
# Headers and libraries are installed to targetsDir
mkdir -p ${PREFIX}/${targetsDir}
mkdir -p ${PREFIX}/$i
cp -rv $i ${PREFIX}/${targetsDir}
if [[ $i == "lib" ]]; then
for j in "$i"/*.so*; do
# Shared libraries are symlinked in $PREFIX/lib
ln -s ${PREFIX}/${targetsDir}/$j ${PREFIX}/$j

if [[ $j =~ \.so\. ]]; then
patchelf --set-rpath '$ORIGIN' --force-rpath ${PREFIX}/${targetsDir}/$j
fi
done
fi
else
# Put all other files in targetsDir
mkdir -p ${PREFIX}/${targetsDir}/${PKG_NAME}
cp -rv $i ${PREFIX}/${targetsDir}/${PKG_NAME}
fi
done
6 changes: 6 additions & 0 deletions recipes/nvjpeg2k/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
arm_variant_type: # [aarch64]
- sbsa # [aarch64]
- tegra # [false]
cuda_version:
- 11.8
- 12.0
137 changes: 137 additions & 0 deletions recipes/nvjpeg2k/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
{% set name = "libnvjpeg2k" %}
{% set version = "0.8.0.38" %}
{% set platform = "linux-x86_64" %} # [linux64]
{% set platform = "linux-ppc64le" %} # [ppc64le]
{% set platform = "linux-sbsa" %} # [aarch64 and arm_variant_type == "sbsa"]
{% set platform = "linux-aarch64" %} # [aarch64 and arm_variant_type == "tegra"]
{% set platform = "windows-x86_64" %} # [win]
{% set target_name = "x86_64-linux" %} # [linux64]
{% set target_name = "ppc64le-linux" %} # [ppc64le]
{% set target_name = "sbsa-linux" %} # [aarch64 and arm_variant_type == "sbsa"]
{% set target_name = "aarch64-linux" %} # [aarch64 and arm_variant_type == "tegra"]
{% set target_name = "x64" %} # [win]
{% set extension = "tar.xz" %} # [not win]
{% set extension = "zip" %} # [win]

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

source:
url: https://developer.download.nvidia.com/compute/nvjpeg2000/redist/libnvjpeg_2k/{{ platform }}/libnvjpeg_2k-{{ platform }}-{{ version }}-archive.{{ extension }}
sha256: f0b4f0ab9e19579c547e96ce189c6a93731f662898751a88d62e3caa59472367 # [linux64]
sha256: 03a568305989b25be6def7d860b2519577ebef1538c703de0ad086fa2314a1e0 # [aarch64 and arm_variant_type == "sbsa"]
sha256: dac4f1d0c088c22155067b781142dc27ec1d3ced68b99d2180fcd1fcf02fe19e # [aarch64 and arm_variant_type == "tegra"]
sha256: feabb2f4108805b251f44b0561b194a24041d01207b272a3aa42a664e938e5d4 # [win]

build:
number: 0
skip: true # [osx or ppc64le]

requirements:
build:
- patchelf <0.18.0 # [linux]

outputs:

- name: libnvjpeg2k{{ version.split(".")[0] }}
build:
binary_relocation: false
run_exports:
- {{ pin_subpackage("libnvjpeg2k" ~ version.split(".")[0]) }}
files:
- lib/libnvjpeg2k.so.* # [linux]
- targets/{{ target_name }}/lib/libnvjpeg2k.so.* # [linux]
- Library\bin\nvjpeg2k*.dll # [win]
requirements:
build:
- {{ compiler("c") }}
- {{ compiler("cxx") }}
- {{ stdlib("c") }}
- arm-variant * {{ arm_variant_type }} # [aarch64]
host:
- cuda-version {{ cuda_version }}
Copy link
Member Author

Choose a reason for hiding this comment

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

It's unclear to me if we have hard dependency on the cudart.

run:
- {{ pin_compatible("cuda-version") }}
run_constrained:
- arm-variant * {{ arm_variant_type }} # [aarch64]
test:
requires:
- patchelf # [linux]
files:
- test-rpath.sh
commands:
- test -L $PREFIX/lib/libnvjpeg2k.so.{{ version.split(".")[0] }} # [linux]
- test -L $PREFIX/lib/libnvjpeg2k.so.{{ version }} # [linux]
- test -L $PREFIX/targets/{{ target_name }}/lib/libnvjpeg2k.so.{{ version.split(".")[0] }} # [linux]
- test -f $PREFIX/targets/{{ target_name }}/lib/libnvjpeg2k.so.{{ version }} # [linux]
- bash test-rpath.sh # [linux]
- if not exist %LIBRARY_BIN%\nvjpeg2k_{{ version.split(".")[0] }}.dll exit 1 # [win]

- name: libnvjpeg2k-dev
build:
run_exports:
- {{ pin_subpackage("libnvjpeg2k" ~ version.split(".")[0]) }}
files:
- lib/libnvjpeg2k.so # [linux]
# - lib/pkgconfig/nvjpeg*.pc # [linux]
- targets/{{ target_name }}/lib/libnvjpeg2k.so # [linux]
# - targets/{{ target_name }}/lib/stubs/libnvjpeg2k.so # [linux]
- targets/{{ target_name }}/include/nvjpeg* # [linux]
- Library\include # [win]
- Library\lib\nvjpeg.lib # [win]
requirements:
build:
- arm-variant * {{ arm_variant_type }} # [aarch64]
host:
- cuda-version {{ cuda_version }}
- {{ pin_subpackage("libnvjpeg2k" ~ version.split(".")[0], exact=True) }}
run:
- {{ pin_compatible("cuda-version") }}
- {{ pin_subpackage("libnvjpeg2k" ~ version.split(".")[0], exact=True) }}
run_constrained:
- arm-variant * {{ arm_variant_type }} # [aarch64]
test:
commands:
- test -L $PREFIX/lib/libnvjpeg2k.so # [linux]
# - test -f $PREFIX/lib/pkgconfig/nvjpeg*.pc # [linux]
- test -f $PREFIX/targets/{{ target_name }}/include/nvjpeg2k_version.h # [linux]
- test -f $PREFIX/targets/{{ target_name }}/include/nvjpeg2k.h # [linux]
- test -L $PREFIX/targets/{{ target_name }}/lib/libnvjpeg2k.so # [linux]
# - test -f $PREFIX/targets/{{ target_name }}/lib/stubs/libnvjpeg2k.so # [linux]
- if not exist %LIBRARY_INC%\nvjpeg2k_version.h exit 1 # [win]
- if not exist %LIBRARY_INC%\nvjpeg2k.h exit 1 # [win]
- if not exist %LIBRARY_LIB%\nvjpeg2k.lib exit 1 # [win]

- name: libnvjpeg2k-static
build:
skip: True # [not linux]
files:
- targets/{{ target_name }}/lib/libnvjpeg2k_static.a # [linux]
requirements:
build:
- arm-variant * {{ arm_variant_type }} # [aarch64]
host:
- cuda-version {{ cuda_version }}
run:
- {{ pin_compatible("cuda-version") }}
- {{ pin_subpackage("libnvjpeg2k-dev", exact=True) }}
run_constrained:
- arm-variant * {{ arm_variant_type }} # [aarch64]
test:
commands:
- test -f $PREFIX/targets/{{ target_name }}/lib/libnvjpeg2k_static.a # [linux]

about:
home: https://docs.nvidia.com/cuda/nvjpeg2000/
license_file: LICENSE
license: LicenseRef-NVIDIA-End-User-License-Agreement
license_url: https://docs.nvidia.com/cuda/eula/index.html
summary: nvJPEG2000 native runtime libraries
description: |
nvJPEG2000 native runtime libraries
doc_url: https://docs.nvidia.com/cuda/nvjpeg2000/

extra:
recipe-maintainers:
- conda-forge/cuda
28 changes: 28 additions & 0 deletions recipes/nvjpeg2k/test-rpath.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

[[ ${target_platform} == "linux-64" ]] && targetsDir="targets/x86_64-linux"
[[ ${target_platform} == "linux-ppc64le" ]] && targetsDir="targets/ppc64le-linux"
[[ ${target_platform} == "linux-aarch64" ]] && targetsDir="targets/sbsa-linux"

errors=""

for lib in `find ${PREFIX}/${targetsDir}/lib -type f`; do
[[ $lib =~ \.so ]] || continue

rpath=$(patchelf --print-rpath $lib)
echo "$lib rpath: $rpath"
if [[ $rpath != "\$ORIGIN" ]]; then
errors+="$lib\n"
elif [[ $(objdump -x ${lib} | grep "PATH") == *"RUNPATH"* ]]; then
errors+="$lib\n"
fi
done

if [[ $errors ]]; then
echo "The following libraries were found with an unexpected RPATH:"
echo -e "$errors"

exit 1
else
exit 0
fi
Loading