Skip to content
This repository has been archived by the owner on Oct 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1 from mitmul/create-wheels
Browse files Browse the repository at this point in the history
Create wheels
  • Loading branch information
mitmul authored May 5, 2018
2 parents bd63a34 + 443e33a commit 8d84a40
Show file tree
Hide file tree
Showing 14 changed files with 393 additions and 70 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pynvvl/*.cpp
!examples/sample.png
pynvvl/_lib/
docker/include/
examples/*.txt

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
30 changes: 19 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,28 @@ PyNVVL is a thin wrapper of [NVIDIA Video Loader (NVVL)](https://github.com/NVID

## Requirements

- Python 2.7.6+, 3.4.7+, 3.5.1+, 3.6.0+
- [CuPy](https://github.com/cupy/cupy) v4.0.0

## Install
## Tested Environment

```
pip install [WHEEL URL]
```
- Ubuntu 16.04
- Python 2.7.6+, 3.4.7+, 3.5.1+, 3.6.0+

## Install the pre-built binary

Replace `[WHEEL URL]` with one of the wheels below:
Please choose a right package depending on your CUDA version.

### Python 3.5
```bash
# [For CUDA 8.0]
pip install pynvvl-cuda80

- CUDA 8.0: `https://github.com/mitmul/pynvvl/releases/download/v0.0.1/pynvvl_cuda80-0.0.1-cp35-cp35m-linux_x86_64.whl`
- CUDA 9.0: `https://github.com/mitmul/pynvvl/releases/download/v0.0.1/pynvvl_cuda90-0.0.1-cp35-cp35m-linux_x86_64.whl`
- CUDA 9.1: `https://github.com/mitmul/pynvvl/releases/download/v0.0.1/pynvvl_cuda91-0.0.1-cp35-cp35m-linux_x86_64.whl`
# [For CUDA 9.0]
pip install pynvvl-cuda90

# [For CUDA 9.1]
pip install pynvvl-cuda91
```

## Usage

Expand Down Expand Up @@ -103,7 +110,7 @@ Loads the video from disk and returns it as a CuPy ndarray.
yuv 4:2:0 to 4:4:4. It should be 'Linear' currently.
```

## Build wheels
## How to build wheels

### Requirements for build

Expand All @@ -114,5 +121,6 @@ Loads the video from disk and returns it as a CuPy ndarray.
bash docker/build_docker.sh
sudo rm -rf docker/lib
bash docker/build_nvvl.sh
bash docker/build_wheels.sh
sudo rm -rf build dist *.egg-info
python docker/build_wheels.py
```
4 changes: 3 additions & 1 deletion docker/Dockerfile.develop
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ RUN pip3 install \
cython \
numpy \
matplotlib
RUN echo ${CUDA_VERSION} | sed -E "s/\.//g" | awk '{print substr ($0, 0, 2)}' | xargs -I{} pip3 install cupy-cuda{}

ARG CUPY_PACKAGE_NAME
RUN pip3 install ${CUPY_PACKAGE_NAME}
77 changes: 62 additions & 15 deletions docker/Dockerfile.test
Original file line number Diff line number Diff line change
@@ -1,18 +1,65 @@
ARG CUDA_VERSION=9.1
FROM nvidia/cuda:${CUDA_VERSION}-devel-ubuntu16.04
ARG cuda_version
FROM nvidia/cuda:${cuda_version}-devel-ubuntu16.04

ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,video,utility
ENV NVIDIA_DRIVER_CAPABILITIES=video,compute,utility

RUN apt-get update && apt-get install -y \
python3 \
python3-dev \
python3-pip \
python3-tk \
gawk

RUN pip3 install \
cython \
numpy \
matplotlib
RUN echo ${CUDA_VERSION} | sed -E "s/\.//g" | awk '{print substr ($0, 0, 2)}' | xargs -I{} pip3 install cupy-cuda{}
python \
python-dev \
python-pip \
python-wheel \
python-setuptools \
gawk \
make \
build-essential \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
wget \
curl \
llvm \
libncurses5-dev \
libncursesw5-dev \
xz-utils \
tk-dev \
git

WORKDIR /root

ENV HOME /root

# Install pyenv.
RUN git clone https://github.com/pyenv/pyenv.git ${HOME}/.pyenv
ENV PYENV_ROOT ${HOME}/.pyenv
ENV PATH ${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${PYENV_ROOT}/libexec:${PATH}
RUN eval "$(pyenv init -)"
RUN pyenv versions

# Install Python.
ARG python_versions
# RUN pyenv install 3.5.1
RUN for VERSION in ${python_versions}; do \
echo "Installing Python ${VERSION}..." && \
pyenv install ${VERSION} && \
pyenv global ${VERSION} && \
pyenv rehash && \
echo "Finished"; \
done;
RUN pyenv versions

# Install Python libraries.
ARG cython_version
ARG cupy_version
ARG cupy_package_name
RUN for VERSION in ${python_versions}; do \
echo "Installing libraries on Python ${VERSION}..." && \
pyenv global ${VERSION} && \
pip install -U pip setuptools && \
pip install argparse && \
pip install Cython==${cython_version} wheel auditwheel && \
pip install numpy matplotlib ${cupy_package_name}; \
done;

ENV MPLBACKEND Agg
65 changes: 65 additions & 0 deletions docker/Dockerfile.wheels
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
ARG cuda_version
FROM mitmul/pynvvl:cuda-${cuda_version}

ENV NVIDIA_DRIVER_CAPABILITIES=video,compute,utility

RUN apt-get update && apt-get install -y \
python \
python-dev \
python-pip \
python-wheel \
python-setuptools \
gawk \
make \
build-essential \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
wget \
curl \
llvm \
libncurses5-dev \
libncursesw5-dev \
xz-utils \
tk-dev \
git

WORKDIR /root

ENV HOME /root

# Install pyenv.
RUN git clone https://github.com/pyenv/pyenv.git ${HOME}/.pyenv
ENV PYENV_ROOT ${HOME}/.pyenv
ENV PATH ${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${PYENV_ROOT}/libexec:${PATH}
RUN eval "$(pyenv init -)"
RUN pyenv versions

# Install Python.
ARG python_versions
# RUN pyenv install 3.5.1
RUN for VERSION in ${python_versions}; do \
echo "Installing Python ${VERSION}..." && \
pyenv install ${VERSION} && \
pyenv global ${VERSION} && \
pyenv rehash && \
echo "Finished"; \
done;
RUN pyenv versions

# Install Python libraries.
ARG cython_version
ARG cupy_package_name
ARG cupy_version
RUN for VERSION in ${python_versions}; do \
echo "Installing libraries on Python ${VERSION}..." && \
pyenv global ${VERSION} && \
pip install -U pip setuptools && \
pip install argparse && \
pip install Cython==${cython_version} wheel auditwheel && \
pip install ${cupy_package_name}==${cupy_version} && \
pip freeze; \
done;

16 changes: 11 additions & 5 deletions docker/build_docker.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
#!/bin/bash

build_docker_image() {
docker build -t mitmul/pynvvl:cuda-$1 --build-arg CUDA_VERSION=$1 -f docker/Dockerfile.build-nvvl docker
docker build -t mitmul/pynvvl:cuda-$1 \
--build-arg CUDA_VERSION=$1 \
-f docker/Dockerfile.build-nvvl docker
docker push mitmul/pynvvl:cuda-$1
docker build -t mitmul/pynvvl:cuda-$1-dev --build-arg CUDA_VERSION=$1 -f docker/Dockerfile.develop docker

docker build -t mitmul/pynvvl:cuda-$1-dev \
--build-arg CUDA_VERSION=$1 \
--build-arg CUPY_PACKAGE_NAME=$2 \
-f docker/Dockerfile.develop docker
docker push mitmul/pynvvl:cuda-$1-dev
}

build_docker_image 8.0
build_docker_image 9.0
build_docker_image 9.1
build_docker_image 8.0 cupy-cuda80
build_docker_image 9.0 cupy-cuda90
build_docker_image 9.1 cupy-cuda91
11 changes: 8 additions & 3 deletions docker/build_nvvl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ build_libnvvl() {
nvidia-docker run \
--rm \
-v $PWD/docker:/root/build -t mitmul/pynvvl:cuda-$1 \
bash -c "find / -name \"*libnvcuvid.so.1\" | \
xargs -I{} ln -s {} /usr/local/lib/libnvcuvid.so && \
if [ ! -d /root/build/lib/cuda-$1 ]; then mkdir -p /root/build/lib/cuda-$1; fi && \
bash -c " \
if [ ! -f /usr/local/lib/libnvcuvid.so ]; then \
find / -name \"*libnvcuvid.so.1\" | \
xargs -I{} ln -s {} /usr/local/lib/libnvcuvid.so; \
fi && \
if [ ! -d /root/build/lib/cuda-$1 ]; then \
mkdir -p /root/build/lib/cuda-$1; \
fi && \
cp -r /usr/local/lib /root/build/lib/cuda-$1 && \
mv /root/build/lib/cuda-$1/lib/* /root/build/lib/cuda-$1/ && \
rm -rf /root/build/lib/cuda-$1/lib && \
Expand Down
Loading

0 comments on commit 8d84a40

Please sign in to comment.