Skip to content

Commit 2a73733

Browse files
feat: adding release v0.13.0 of CV-CUDA (#219)
1 parent 07d5e44 commit 2a73733

30 files changed

+2350
-147
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ endif()
2323

2424
project(cvcuda
2525
LANGUAGES C CXX
26-
VERSION 0.12.0
26+
VERSION 0.13.0
2727
DESCRIPTION "CUDA-accelerated Computer Vision algorithms"
2828
)
2929

README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
[![License](https://img.shields.io/badge/License-Apache_2.0-yellogreen.svg)](https://opensource.org/licenses/Apache-2.0)
2020

21-
![Version](https://img.shields.io/badge/Version-v0.12.0--beta-blue)
21+
![Version](https://img.shields.io/badge/Version-v0.13.0--beta-blue)
2222

2323
![Platform](https://img.shields.io/badge/Platform-linux--64_%7C_win--64_wsl2%7C_aarch64-gray)
2424

@@ -239,12 +239,13 @@ cpack . -G [DEB|TXZ]
239239

240240
Python Wheels
241241

242-
By default during the `release` build, Python bindings and wheels are created for the available CUDA version and the specified Python version(s). The wheels are stored in `build-rel/pythonX.Y/wheel` folder, where `build-rel` is the build directory used to build the release build and `X` and `Y` are Python major and minor versions.
242+
By default, during the `release` build, Python bindings and wheels are created for the available CUDA version and the specified Python version(s). The wheels are now output to the `build-rel/python3/repaired_wheels` folder (after being processed by the `auditwheel repair` command in the case of ManyLinux). The single generated python wheel is compatible with all versions of python specified during the cmake build step. Here, `build-rel` is the build directory used to build the release build.
243243

244-
The built wheels can be installed using pip.
245-
For example, to install the Python wheel built for CUDA 12.x, Python 3.10 on Linux x86_64 systems:
244+
The new Python wheels for PyPI compliance must be built within the ManyLinux 2014 Docker environment. The Docker images can be generated using the `docker/manylinux/docker_buildx.sh` script. These images ensure the wheels meet ManyLinux 2014 and PyPI standards.
245+
246+
The built wheels can still be installed using `pip`. For example, to install the Python wheel built for CUDA 12.x, Python 3.10 and 3.11 on Linux x86_64 systems:
246247
```shell
247-
pip install cvcuda_cu12-<x.x.x>-cp310-cp310-linux_x86_64.whl
248+
pip install cvcuda_cu12-<x.x.x>-cp310.cp311-cp310.cp311-linux_x86_64.whl
248249
```
249250

250251
## Contributing

cmake/BuildPython.cmake

+38-8
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ list(APPEND PYPROJ_COMMON_ARGS
4545
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
4646
)
4747

48-
# It need to overwrite the PYTHON_MODULE_EXTENSION to generate
48+
# It needs to overwrite the PYTHON_MODULE_EXTENSION to generate
4949
# python module name with correct name when cross compiling
5050
# example: set(PYTHON_MODULE_EXTENSION .cpython-py38-aarch64-linux-gnu.so)
5151
if (CMAKE_CROSSCOMPILING)
52-
list(APPEND PYPROJ_COMMON_ARGS
53-
-DCUDAToolkit_ROOT=${CUDAToolkit_ROOT}
54-
-DPYTHON_MODULE_EXTENSION=${PYTHON_MODULE_EXTENSION}
55-
)
52+
list(APPEND PYPROJ_COMMON_ARGS
53+
-DCUDAToolkit_ROOT=${CUDAToolkit_ROOT}
54+
-DPYTHON_MODULE_EXTENSION=${PYTHON_MODULE_EXTENSION}
55+
)
5656
endif()
5757

5858
foreach(VER ${PYTHON_VERSIONS})
@@ -61,7 +61,7 @@ foreach(VER ${PYTHON_VERSIONS})
6161
ExternalProject_Add(cvcuda_python${VER}
6262
PREFIX ${BASEDIR}
6363
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/python
64-
CMAKE_ARGS ${PYPROJ_COMMON_ARGS} -DPYTHON_VERSION=${VER} -DBUILD_ROOT=${CMAKE_BINARY_DIR} -DPYTHON_VERSION_SHORT=${VER}
64+
CMAKE_ARGS ${PYPROJ_COMMON_ARGS} -DPYTHON_VERSION=${VER}
6565
BINARY_DIR ${BASEDIR}/build
6666
TMP_DIR ${BASEDIR}/tmp
6767
STAMP_DIR ${BASEDIR}/stamp
@@ -72,7 +72,37 @@ foreach(VER ${PYTHON_VERSIONS})
7272
endforeach()
7373

7474
if(CMAKE_BUILD_TYPE STREQUAL "Release")
75-
foreach(PYTHON_VERSION ${PYTHON_VERSIONS})
76-
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/python/setup.py.in" "${CMAKE_BINARY_DIR}/python${PYTHON_VERSION}/setup.py")
75+
set(PACKAGE_LIB_DIR ${CMAKE_BINARY_DIR}/python3/lib)
76+
77+
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/python3)
78+
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/python3/lib)
79+
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/python3/cvcuda)
80+
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/python3/cvcuda/_bindings)
81+
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/python3/nvcv)
82+
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/python3/nvcv/_bindings)
83+
84+
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/python/setup.py.in" "${CMAKE_BINARY_DIR}/python3/setup.py")
85+
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/python/__init__.py.in" "${CMAKE_BINARY_DIR}/python3/cvcuda/__init__.py")
86+
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/python/__init__.py.in" "${CMAKE_BINARY_DIR}/python3/nvcv/__init__.py")
87+
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/python/_load_binding.py.in" "${CMAKE_BINARY_DIR}/python3/cvcuda/_load_binding.py")
88+
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/python/_load_binding.py.in" "${CMAKE_BINARY_DIR}/python3/nvcv/_load_binding.py")
89+
90+
add_custom_target(wheel ALL)
91+
92+
foreach(VER ${PYTHON_VERSIONS})
93+
add_dependencies(wheel cvcuda_python${VER})
7794
endforeach()
95+
96+
add_custom_command(
97+
TARGET wheel
98+
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:cvcuda> ${CMAKE_BINARY_DIR}/python3/lib
99+
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:nvcv_types> ${CMAKE_BINARY_DIR}/python3/lib
100+
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/lib/python/cvcuda*.so ${CMAKE_BINARY_DIR}/python3/cvcuda/_bindings
101+
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/lib/python/nvcv*.so ${CMAKE_BINARY_DIR}/python3/nvcv/_bindings
102+
)
103+
104+
add_custom_command(
105+
TARGET wheel
106+
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/python/build_wheels.sh" "${CMAKE_BINARY_DIR}/python3"
107+
)
78108
endif()

cmake/ConfigCompiler.cmake

+10-3
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@ if(BUILD_TESTS)
8181
set(candidate_compilers ${PUBLIC_API_COMPILERS})
8282
else()
8383
# If not, by default, we'll try these.
84-
set(candidate_compilers gcc-11 gcc-9 clang-11 clang-14)
84+
set(candidate_compilers gcc-11 gcc-10 gcc-9 clang-11 clang-14)
8585
endif()
8686

8787
unset(valid_compilers)
88+
set(at_least_one_compiler_found OFF)
8889

8990
foreach(comp ${candidate_compilers})
9091
string(MAKE_C_IDENTIFIER "${comp}" comp_str)
@@ -93,14 +94,20 @@ if(BUILD_TESTS)
9394
find_program(COMPILER_EXEC_${COMP_STR} ${comp})
9495
if(COMPILER_EXEC_${COMP_STR})
9596
list(APPEND valid_compilers ${comp})
97+
set(at_least_one_compiler_found ON)
9698
else()
9799
if(PUBLIC_API_COMPILERS)
98100
message(FATAL_ERROR "Compiler '${comp}' not found")
99-
else()
100-
message(WARNING "Compiler '${comp}' not found, skipping public API checks for it")
101101
endif()
102102
endif()
103103
endforeach()
104+
105+
if(NOT at_least_one_compiler_found)
106+
foreach(comp ${candidate_compilers})
107+
message(WARNING "Compiler '${comp}' not found, skipping public API checks for it")
108+
endforeach()
109+
endif()
110+
104111
set(PUBLIC_API_COMPILERS "${valid_compilers}")
105112
endif()
106113

cmake/ConfigPython.cmake

+27
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,33 @@ file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cmake/cvcuda_$<LOWER_CASE:$<CON
8181
# Python versions to build already set?
8282
if(PYTHON_VERSIONS)
8383
set(USE_DEFAULT_PYTHON false)
84+
85+
set(AVAILABLE_PYTHON_VERSIONS "")
86+
foreach(VER ${PYTHON_VERSIONS})
87+
find_program(PYTHON_EXECUTABLE python${VER} PATHS /usr/bin /usr/local/bin NO_DEFAULT_PATH)
88+
if (PYTHON_EXECUTABLE)
89+
execute_process(
90+
COMMAND ${PYTHON_EXECUTABLE} -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')"
91+
OUTPUT_VARIABLE PYTHON_VERSION_OUTPUT
92+
OUTPUT_STRIP_TRAILING_WHITESPACE
93+
)
94+
if (PYTHON_VERSION_OUTPUT STREQUAL ${VER})
95+
list(APPEND AVAILABLE_PYTHON_VERSIONS ${VER})
96+
else()
97+
message(WARNING "Python executable ${PYTHON_EXECUTABLE} does not match version ${VER} (${PYTHON_VERSION_OUTPUT}). Skipping.")
98+
endif()
99+
else()
100+
message(WARNING "Python version ${VER} not found. Skipping.")
101+
endif()
102+
unset(PYTHON_EXECUTABLE CACHE)
103+
endforeach()
104+
105+
if(NOT AVAILABLE_PYTHON_VERSIONS)
106+
message(FATAL_ERROR "No available Python versions found. Exiting.")
107+
endif()
108+
109+
set(PYTHON_VERSIONS ${AVAILABLE_PYTHON_VERSIONS})
110+
unset(AVAILABLE_PYTHON_VERSIONS)
84111
# If not, gets the default version from FindPython
85112
else()
86113
find_package(Python COMPONENTS Interpreter REQUIRED)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# Build arguments and version numbers
17+
ARG FROM_IMAGE_NAME=quay.io/pypa/manylinux2014_x86_64
18+
ARG BUILDER_EXTRA_DEPS=scratch
19+
20+
# Base image
21+
FROM ${BUILDER_EXTRA_DEPS} AS extra_deps
22+
FROM ${FROM_IMAGE_NAME}
23+
24+
ARG ARCH=x86_64
25+
ARG CC=gcc
26+
ARG CXX=g++
27+
ARG PATCHELF_VERSION=0.17.2
28+
ARG CMAKE_VERSION=3.20.1
29+
ARG PYVER=3.8
30+
ARG PYV=38
31+
ARG CLANG_VERSION=14.0
32+
ARG SPHINX_VERSION=4.5.0
33+
34+
# Set build arguments as environment variables
35+
ENV ARCH=${ARCH}
36+
ENV CC=${CC}
37+
ENV CXX=${CXX}
38+
ENV PATCHELF_VERSION=${PATCHELF_VERSION}
39+
ENV CMAKE_VERSION=${CMAKE_VERSION}
40+
ENV PYVER=${PYVER}
41+
ENV PYV=${PYV}
42+
ENV CLANG_VERSION=${CLANG_VERSION}
43+
ENV LIBCLANG_VERSION=${CLANG_VERSION}
44+
ENV SPHINX_VERSION=${SPHINX_VERSION}
45+
46+
# Install additional dependencies
47+
RUN yum install -y ninja-build ccache ShellCheck curl
48+
49+
# Configure ccache
50+
RUN mkdir -p /cache
51+
COPY ccache.conf /etc/ccache.conf
52+
ENV CCACHE_CONFIGPATH=/etc/ccache.conf
53+
ENV PRE_COMMIT_HOME=/cache/pre-commit
54+
55+
# Install patchelf (needed to patch rpath of dependencies in bundle-wheel.sh)
56+
RUN wget -q https://github.com/NixOS/patchelf/releases/download/${PATCHELF_VERSION}/patchelf-${PATCHELF_VERSION}-${ARCH}.tar.gz -O /tmp/patchelf.tar.gz && \
57+
tar -xzf /tmp/patchelf.tar.gz -C /tmp && \
58+
mv /tmp/bin/patchelf /usr/local/bin/ && \
59+
rm -rf /tmp/patchelf*
60+
61+
# Install CMake
62+
RUN cmake --version
63+
RUN wget -q https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-${ARCH}.sh -O /tmp/cmake-install.sh && \
64+
chmod +x /tmp/cmake-install.sh && \
65+
mkdir /opt/cmake-${CMAKE_VERSION} && \
66+
/tmp/cmake-install.sh --skip-license --prefix=/opt/cmake-${CMAKE_VERSION} \
67+
&& rm -f /usr/local/bin/*cmake* \
68+
&& rm -f /usr/local/bin/cpack \
69+
&& rm -f /usr/local/bin/ctest && \
70+
ln -s /opt/cmake-${CMAKE_VERSION}/bin/* /usr/local/bin/ && \
71+
rm -rf /tmp/cmake-install.sh
72+
73+
# Set up Python environment variables
74+
ENV PYTHONPATH=/opt/python/v
75+
ENV PYBIN=${PYTHONPATH}/bin
76+
ENV PYLIB=${PYTHONPATH}/lib
77+
78+
# Create symlink to the desired Python version
79+
RUN ln -s /opt/python/cp${PYV}* ${PYTHONPATH}
80+
81+
# Update PATH and library paths
82+
ENV PATH=${PYTHONPATH}/bin:/opt/python/*/bin:${PATH}
83+
ENV LD_LIBRARY_PATH=/usr/local/lib:/opt/python/*/lib:${PYLIB}:${LD_LIBRARY_PATH}
84+
ENV LIBRARY_PATH=/usr/local/lib:/opt/python/*/lib:${PYLIB}:${LIBRARY_PATH}
85+
86+
# Propagate the environment variable to profile.d
87+
RUN echo "export PYTHONPATH=${PYTHONPATH}" >> /etc/profile.d/python.sh && \
88+
echo "export PYBIN=${PYBIN}" >> /etc/profile.d/python.sh && \
89+
echo "export PYLIB=${PYLIB}" >> /etc/profile.d/python.sh && \
90+
echo "export PATH=\${PYTHONPATH}/bin:/opt/python/*/bin:\${PATH}" >> /etc/profile.d/python.sh && \
91+
echo "export LD_LIBRARY_PATH=/usr/local/lib:/opt/python/*/lib:\${PYLIB}:\${LD_LIBRARY_PATH}" >> /etc/profile.d/python.sh && \
92+
echo "export LIBRARY_PATH=/usr/local/lib:/opt/python/*/lib:\${PYLIB}:\${LIBRARY_PATH}" >> /etc/profile.d/python.sh && \
93+
chmod +x /etc/profile.d/python.sh
94+
95+
# Install Python packages
96+
RUN python3 -m pip install --no-cache-dir \
97+
breathe \
98+
cibuildwheel \
99+
clang==${CLANG_VERSION} \
100+
exhale \
101+
flake8 \
102+
future \
103+
graphviz \
104+
numpy \
105+
pre-commit \
106+
recommonmark \
107+
setuptools \
108+
sphinx_rtd_theme \
109+
sphinx==${SPHINX_VERSION} \
110+
twine \
111+
wheel
112+
113+
# Update the dynamic linker run-time bindings
114+
RUN ldconfig
115+
116+
# extra deps
117+
COPY --from=extra_deps / /
+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
ARG FROM_IMAGE_NAME=quay.io/pypa/manylinux2014_x86_64
17+
ARG CUDA_IMAGE
18+
ARG BUILDER_CUDA_EXTRA_DEPS=scratch
19+
20+
FROM ${BUILDER_CUDA_EXTRA_DEPS} AS cuda_extra_deps
21+
FROM ${CUDA_IMAGE} AS cuda
22+
23+
# Find and copy libcuda.so* to /cuda_libs
24+
RUN mkdir /cuda_libs && \
25+
find /usr -name 'libcuda.so*' -exec cp {} /cuda_libs/ \;
26+
27+
FROM ${FROM_IMAGE_NAME}
28+
29+
ENV PATH=/usr/local/cuda/bin:${PATH}
30+
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64:${LD_LIBRARY_PATH}
31+
32+
ENV NVIDIA_DRIVER_CAPABILITIES=video,compute,utility,compat32
33+
34+
# Propagating the environment variable to profile.d
35+
RUN echo "export NVIDIA_DRIVER_CAPABILITIES=video,compute,utility,compat32" >> /etc/profile.d/nvidia.sh && \
36+
echo "export PATH=/usr/local/cuda/bin:\${PATH}" >> /etc/profile.d/nvidia.sh && \
37+
echo "export LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64:\${LD_LIBRARY_PATH}" >> /etc/profile.d/nvidia.sh && \
38+
chmod +x /etc/profile.d/nvidia.sh
39+
40+
# CUDA
41+
COPY --from=cuda /usr/local/cuda /usr/local/cuda
42+
43+
# Copy libcuda.so* files
44+
COPY --from=cuda /cuda_libs/* /usr/lib64/
45+
46+
# Test CUDA compiler
47+
RUN nvcc --version
48+
49+
# Ensure tmp is writable by all users recursively
50+
RUN chmod -R a+rw /tmp
51+
52+
RUN git clone https://github.com/google/googletest.git -b release-1.10.0 && \
53+
pushd googletest && \
54+
mkdir build && \
55+
pushd build && \
56+
cmake .. && \
57+
make -j$(nproc) && make install && \
58+
popd && popd && rm -rf googletest
59+
60+
# Extra deps
61+
COPY --from=cuda_extra_deps / /
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
ARG FROM_IMAGE_NAME=nvidia/cuda:11.4.3-devel-centos7
17+
FROM ${FROM_IMAGE_NAME} AS cuda
18+
19+
RUN ln -sf /usr/share/zoneinfo/US/Pacific /etc/localtime

0 commit comments

Comments
 (0)