Skip to content

Commit f4087bc

Browse files
committed
Initial code drop
1 parent a5f24e2 commit f4087bc

File tree

335 files changed

+48035
-26
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

335 files changed

+48035
-26
lines changed

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
*~
2+
build
3+
*.pyc
4+
doxygen
5+
html
6+
latex
7+
.vimrc
8+
.ycm_extra_conf.py
9+
**/imgui.ini
10+
.*.swp
11+
valgrind-out.txt
12+
**/.ipynb_checkpoints
13+
.dockerignore

.gitmodules

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[submodule "third_party/googletest"]
2+
path = third_party/googletest
3+
url = https://github.com/google/googletest.git
4+
[submodule "third_party/benchmark"]
5+
path = third_party/benchmark
6+
url = https://github.com/google/benchmark.git
7+
[submodule "third_party/pybind11"]
8+
path = third_party/pybind11
9+
url = https://github.com/pybind/pybind11.git

Acknowledgements.txt

Lines changed: 782 additions & 0 deletions
Large diffs are not rendered by default.

CMakeLists.txt

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
cmake_minimum_required(VERSION 3.5)
16+
17+
project(DALI CXX)
18+
19+
# Build options
20+
option(BUILD_TEST "Build googletest test suite" ON)
21+
option(BUILD_BENCHMARK "Build benchmark suite" ON)
22+
option(BUILD_NVTX "Build with NVTX profiling enabled" OFF)
23+
option(BUILD_PYTHON "Build python bindings" ON)
24+
option(BUILD_LMDB "Build LMDB readers" OFF)
25+
option(BUILD_TENSORFLOW "Build TensorFlow plugin" OFF)
26+
27+
# Helper function to remove elements from a variable
28+
function (remove TARGET INPUT)
29+
foreach(ITEM ${ARGN})
30+
list(REMOVE_ITEM INPUT "${ITEM}")
31+
endforeach()
32+
set(${TARGET} ${INPUT} PARENT_SCOPE)
33+
endfunction(remove)
34+
35+
# Default to release build
36+
if (NOT CMAKE_BUILD_TYPE)
37+
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
38+
"Build type from [Debug, Release]. For perf testing, build Release" FORCE)
39+
endif()
40+
41+
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
42+
message(STATUS "Building in DEBUG mode")
43+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb -DDALI_DEBUG=1")
44+
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -g -G -DDALI_DEBUG=1")
45+
else()
46+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDALI_DEBUG=0")
47+
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -DDALI_DEBUG=0")
48+
endif()
49+
50+
# Cmake path
51+
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)
52+
53+
# Dependencies
54+
include(cmake/Dependencies.cmake)
55+
56+
# CXX flags
57+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wno-unused-variable -Wno-unused-function -fno-strict-aliasing -O2 -fPIC")
58+
59+
# Add ptx & bin flags for cuda
60+
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} \
61+
-gencode arch=compute_35,code=sm_35 \
62+
-gencode arch=compute_50,code=sm_50 \
63+
-gencode arch=compute_52,code=sm_52 \
64+
-gencode arch=compute_60,code=sm_60 \
65+
-gencode arch=compute_61,code=sm_61 \
66+
-gencode arch=compute_70,code=sm_70 \
67+
-gencode arch=compute_70,code=compute_70")
68+
69+
# Project dir
70+
include_directories(BEFORE ${PROJECT_SOURCE_DIR})
71+
include_directories(BEFORE ${PROJECT_BINARY_DIR})
72+
cuda_include_directories(${PROJECT_SOURCE_DIR})
73+
74+
# Project build
75+
add_subdirectory(dali)
76+
77+
# HACK: Add __init__.pys as needed
78+
file(WRITE ${CMAKE_BINARY_DIR}/dali/__init__.py "")
79+
80+
add_custom_target(lint COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/lint.cmake)
81+

COPYRIGHT

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

Dockerfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#########################################################################################
2+
## Stage 2: build DALI wheels using manylinux1 (CentOS 5 derivative)
3+
#########################################################################################
4+
ARG DEPS_IMAGE_NAME
5+
FROM ${DEPS_IMAGE_NAME}
6+
7+
ARG PYVER=2.7
8+
ARG PYV=27
9+
10+
ENV PYVER=${PYVER} PYV=${PYV} PYTHONPATH=/opt/python/v
11+
12+
ENV PYBIN=${PYTHONPATH}/bin \
13+
PYLIB=${PYTHONPATH}/lib
14+
15+
ENV PATH=${PYBIN}:${PATH} \
16+
LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:/opt/dali/build:${PYLIB}:${LD_LIBRARY_PATH}
17+
18+
RUN ln -s /opt/python/cp${PYV}* /opt/python/v
19+
20+
RUN pip install future numpy setuptools wheel tensorflow-gpu && \
21+
rm -rf /root/.cache/pip/
22+
23+
RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \
24+
ldconfig
25+
26+
WORKDIR /opt/dali
27+
28+
COPY . .
29+
30+
WORKDIR /opt/dali/build
31+
32+
RUN LD_LIBRARY_PATH="${PWD}:${LD_LIBRARY_PATH}" && \
33+
cmake ../ -DCMAKE_INSTALL_PREFIX=. \
34+
-DBUILD_TEST=ON -DBUILD_BENCHMARK=ON -DBUILD_PYTHON=ON \
35+
-DBUILD_LMDB=ON -DBUILD_TENSORFLOW=ON && \
36+
make -j"$(grep ^processor /proc/cpuinfo | wc -l)" install
37+
38+
ARG NVIDIA_BUILD_ID
39+
ENV NVIDIA_BUILD_ID ${NVIDIA_BUILD_ID:-0}
40+
41+
RUN pip wheel -v dali/python \
42+
--build-option --python-tag=$(basename /opt/python/cp${PYV}-*) \
43+
--build-option --plat-name=manylinux1_x86_64 \
44+
--build-option --build-number=${NVIDIA_BUILD_ID} && \
45+
../dali/python/bundle-wheel.sh nvidia_dali-*.whl

Dockerfile.deps

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#########################################################################################
2+
## Stage 1: build DALI dependencies using manylinux1 (CentOS 5 derivative)
3+
#########################################################################################
4+
FROM quay.io/pypa/manylinux1_x86_64
5+
6+
# Install yum Dependencies
7+
RUN yum install -y zip
8+
9+
# Don't want the short-unicode version for Python 2.7
10+
RUN rm -f /opt/python/cp27-cp27m
11+
12+
# Boost
13+
RUN BOOST_VERSION=1.66.0 && \
14+
cd /usr/local && \
15+
curl -L https://dl.bintray.com/boostorg/release/1.66.0/source/boost_${BOOST_VERSION//./_}.tar.gz | tar -xzf - && \
16+
ln -s ../boost_${BOOST_VERSION//./_}/boost include/boost
17+
18+
# CMake
19+
RUN CMAKE_VERSION=3.11 && \
20+
CMAKE_BUILD=3.11.3 && \
21+
curl -L https://cmake.org/files/v${CMAKE_VERSION}/cmake-${CMAKE_BUILD}.tar.gz | tar -xzf - && \
22+
cd /cmake-${CMAKE_BUILD} && \
23+
./bootstrap --parallel=$(grep ^processor /proc/cpuinfo | wc -l) && \
24+
make -j"$(grep ^processor /proc/cpuinfo | wc -l)" install && \
25+
rm -rf /cmake-${CMAKE_BUILD}
26+
27+
# protobuf v3.5.1
28+
RUN PROTOBUF_VERSION=3.5.1 && \
29+
curl -L https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protobuf-all-${PROTOBUF_VERSION}.tar.gz | tar -xzf - && \
30+
cd /protobuf-${PROTOBUF_VERSION} && \
31+
./autogen.sh && \
32+
./configure --prefix=/usr/local 2>&1 > /dev/null && \
33+
make -j"$(grep ^processor /proc/cpuinfo | wc -l)" install 2>&1 > /dev/null && \
34+
rm -rf /protobuf-${PROTOBUF_VERSION}
35+
36+
# LMDB
37+
RUN LMDB_VERSION=0.9.22 && \
38+
git clone -b LMDB_${LMDB_VERSION} --single-branch https://github.com/LMDB/lmdb && \
39+
cd /lmdb/libraries/liblmdb && \
40+
make -j"$(grep ^processor /proc/cpuinfo | wc -l)" install && \
41+
rm -rf /lmdb
42+
43+
# OpenCV
44+
RUN OPENCV_VERSION=3.1.0 && \
45+
curl -L https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.tar.gz | tar -xzf - && \
46+
cd /opencv-${OPENCV_VERSION} && \
47+
cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local \
48+
-DWITH_CUDA=OFF -DWITH_1394=OFF -DWITH_IPP=OFF -DWITH_OPENCL=OFF -DWITH_GTK=OFF \
49+
-DBUILD_DOCS=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF \
50+
-DBUILD_opencv_cudalegacy=OFF -DBUILD_opencv_stitching=OFF . && \
51+
make -j"$(grep ^processor /proc/cpuinfo | wc -l)" install && \
52+
rm -rf /opencv-${OPENCV_VERSION}
53+
54+
# libjpeg-turbo
55+
#
56+
# Note: the preceding OpenCV installation intentionally does NOT use libjpeg-turbo.
57+
# DALI will directly call libjpeg-turbo first, and if it fails, DALI will fall back
58+
# to OpenCV, which in turn will call its bundled (built-from-source) libjpeg.
59+
# To be extra sure OpenCV doesn't pick up libjpeg-turbo (in which case we'd have no
60+
# fallback), libjpeg-turbo is built and installed _after_ OpenCV.
61+
#
62+
RUN JPEG_TURBO_VERSION=1.5.2 && \
63+
curl -L https://github.com/libjpeg-turbo/libjpeg-turbo/archive/${JPEG_TURBO_VERSION}.tar.gz | tar -xzf - && \
64+
cd /libjpeg-turbo-${JPEG_TURBO_VERSION} && \
65+
autoreconf -fiv && \
66+
./configure --enable-shared --prefix=/usr/local 2>&1 >/dev/null && \
67+
make -j"$(grep ^processor /proc/cpuinfo | wc -l)" install 2>&1 >/dev/null && \
68+
rm -rf /libjpeg-turbo-${JPEG_TURBO_VERSION}
69+
70+
# CUDA
71+
RUN CUDA_VERSION=9.0 && \
72+
CUDA_BUILD=9.0.176_384.81 && \
73+
curl -LO https://developer.nvidia.com/compute/cuda/${CUDA_VERSION}/Prod/local_installers/cuda_${CUDA_BUILD}_linux-run && \
74+
chmod +x cuda_${CUDA_BUILD}_linux-run && \
75+
./cuda_${CUDA_BUILD}_linux-run --silent --no-opengl-libs --toolkit && \
76+
rm -f cuda_${CUDA_BUILD}_linux-run
77+
78+
# NVJPEG
79+
RUN NVJPEG_VERSION=9.0 && \
80+
curl -L https://developer.download.nvidia.com/compute/redist/libnvjpeg/cuda-linux64-nvjpeg-${NVJPEG_VERSION}.tar.gz | tar -xzf - && \
81+
cd /cuda-linux64-nvjpeg/ && \
82+
mv lib64/libnvjpeg.so* /usr/local/lib/ && \
83+
mv include/nvjpeg.h /usr/local/include/ && \
84+
rm -rf /cuda-linux64-nvjpeg
85+
86+

0 commit comments

Comments
 (0)