Skip to content

Commit

Permalink
Merge pull request #82 from rapidsai/develop
Browse files Browse the repository at this point in the history
[REVIEW] merge develop to master and release it as 0.4
  • Loading branch information
avolkov1 authored May 19, 2020
2 parents b0ede1d + 273d50f commit 8190afe
Show file tree
Hide file tree
Showing 68 changed files with 13,576 additions and 1,311 deletions.
105 changes: 52 additions & 53 deletions docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,57 @@

echo "Building gQuant container..."

echo -e "Please, select the option which better fits your system configuration:\n" \
" - '1' for Ubuntu 16.04 + cuda 9.2\n" \
" - '2' for Ubuntu 16.04 + cuda 10.0\n" \
" - '3' for Ubuntu 18.04 + cuda 9.2\n" \
" - '4' for Ubuntu 18.04 + cuda 10.0"
echo -e "\nPlease, select your operating system:\n" \
" - '1' for Ubuntu 16.04\n" \
" - '2' for Ubuntu 18.04\n" \
" - '3' for CentOS"

read -p "Enter your option and hit return [1]-4: " SYSTEM_CONFIGURATION
read -p "Enter your option and hit return [1]-3: " OPERATING_SYSTEM

SYSTEM_CONFIGURATION=${SYSTEM_CONFIGURATION:-1}
case $SYSTEM_CONFIGURATION in
OPERATING_SYSTEM=${OPERATING_SYSTEM:-1}
case $OPERATING_SYSTEM in
2)
echo "Ubuntu 16.04 + cuda 10.0 selected."
OS_STR='16.04'
CONTAINER_VER='10.0'
CUPY='cupy-cuda100'
;;
echo "Ubuntu 18.04 selected."
OS_STR="ubuntu18.04"
;;
3)
echo "Ubuntu 18.04 + cuda 9.2 selected."
OS_STR='18.04'
CONTAINER_VER='9.2'
CUPY='cupy-cuda92'
;;
4)
echo "Ubuntu 18.04 + cuda 10.0 selected."
OS_STR='18.04'
CONTAINER_VER='10.0'
CUPY='cupy-cuda100'
;;
echo "CentOS selected."
OS_STR="centos7"
;;
*)
echo "Ubuntu 16.04 + cuda 9.2 selected."
OS_STR='16.04'
CONTAINER_VER='9.2'
CUPY='cupy-cuda92'
;;
echo "Ubuntu 16.04 selected."
OS_STR="ubuntu16.04"
;;
esac

CONTAINER="nvcr.io/nvidia/rapidsai/rapidsai:0.9-cuda${CONTAINER_VER}-runtime-ubuntu${OS_STR}"
echo -e "\nPlease, select your cuda version:\n" \
" - '1' for cuda 9.2\n" \
" - '2' for cuda 10.0\n" \
" - '3' for cuda 10.1.2"

read -p "Enter your option and hit return [1]-3: " CUDA_VERSION

RAPIDS_VERSION="0.13"

read -p "Would you like to install Vim JupyterLab Extension (optional) [N]/y: " VIM_INSTALL
CUDA_VERSION=${CUDA_VERSION:-1}
case $CUDA_VERSION in
2)
echo "cuda 10.0 selected."
CONTAINER_VER='10.0'
;;
3)
echo "cuda 10.1.2 selected."
CONTAINER_VER='10.1'
;;
*)
echo "cuda 9.2 selected."
CONTAINER_VER='9.2'
;;
esac

VIM_INSTALL=${VIM_INSTALL:-N}
if [ "$VIM_INSTALL" = "Y" ] || [ "$VIM_INSTALL" = "y" ]; then
echo "Vim JupyterLab Extension will be installed."
else
echo "Vim JupyterLab Extension will not be installed."
fi
CONTAINER="nvcr.io/nvidia/rapidsai/rapidsai:${RAPIDS_VERSION}-cuda${CONTAINER_VER}-runtime-${OS_STR}"

D_FILE=${D_FILE:='Dockerfile.Rapids'}
D_CONT=${D_CONT:='gquant/gquant:latest'}

mkdir -p gQuant
cp -r ../gquant ./gQuant
Expand All @@ -60,30 +62,31 @@ cp ../setup.py ./gQuant
cp ../LICENSE ./gQuant
rsync -av --progress ../notebooks ./gQuant --exclude data --exclude .cache --exclude many-small --exclude storage --exclude dask-worker-space --exclude __pycache__

gquant_ver=$(grep version gQuant/setup.py | sed "s/^.*version='\([^;]*\)'.*/\1/")
D_CONT=${D_CONT:="gquant/gquant:${gquant_ver}_${OS_STR}_${CONTAINER_VER}_${RAPIDS_VERSION}"}

cat > $D_FILE <<EOF
FROM $CONTAINER
USER root
ADD ./gQuant /rapids/gQuant
RUN apt-get update && apt-get install -y libfontconfig1 libxrender1
RUN if [ "$OS_STR" = "centos7" ]; then \
yum install -y fontconfig-devel libXrender ; \
else \
apt-get update && apt-get install -y libfontconfig1 libxrender1 ; \
fi
# RUN apt-get update && apt-get install -y libfontconfig1 libxrender1
SHELL ["bash","-c"]
#
# Additional python libs
#
RUN source activate rapids \
&& pip install nxpd $CUPY
RUN source activate rapids \
&& cd /rapids/gQuant \
&& pip install .
RUN source activate rapids \
&& conda install -y -c conda-forge dask-labextension recommonmark numpydoc sphinx_rtd_theme pudb \
python-graphviz bqplot=0.11.5 nodejs=11.11.0 jupyterlab=0.35.4 ipywidgets=7.4.2 pytables mkl numexpr
python-graphviz bqplot=0.11.5 nodejs=11.11.0 jupyterlab=0.35.4 ipywidgets=7.4.2 pytables mkl numexpr \
pydot
#
# required set up
#
Expand All @@ -92,17 +95,13 @@ RUN source activate rapids \
&& jupyter labextension install [email protected] --no-build \
&& mkdir /.local /.jupyter /.config /.cupy \
&& chmod 777 /.local /.jupyter /.config /.cupy
RUN if [ "$VIM_INSTALL" = "Y" ] || [ "$VIM_INSTALL" = "y" ]; then /conda/envs/rapids/bin/jupyter labextension install [email protected] --no-build ; fi
RUN source activate rapids \
&& jupyter lab build && jupyter lab clean
EXPOSE 8888
EXPOSE 8787
EXPOSE 8786
WORKDIR /rapids
ENTRYPOINT /bin/bash -c 'source activate rapids; /bin/bash'
EOF

docker build -f $D_FILE -t $D_CONT .
15 changes: 15 additions & 0 deletions gquant/_common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from collections import namedtuple, Mapping

__all__ = ['_namedtuple_with_defaults']


def _namedtuple_with_defaults(typename, field_names, default_values=()):
# https://stackoverflow.com/a/18348004/3457624
T = namedtuple(typename, field_names)
T.__new__.__defaults__ = (None,) * len(T._fields)
if isinstance(default_values, Mapping):
prototype = T(**default_values)
else:
prototype = T(*default_values)
T.__new__.__defaults__ = tuple(prototype)
return T
6 changes: 3 additions & 3 deletions gquant/cuindicator/ewm.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def kernel(in_arr, out_arr, average_length, span, arr_len, thread_tile,
for j in range(0, average_length - 1, block_size):
if (((tx + j) < average_length - 1) and
(starting_id - average_length + 1 + tx + j >= 0)):
shared[tx + j] = \
in_arr[starting_id - average_length + 1 + tx + j]
shared[tx + j] = \
in_arr[starting_id - average_length + 1 + tx + j]
cuda.syncthreads()
# slice the shared memory for each threads
start_shared = tx * thread_tile
Expand Down Expand Up @@ -95,7 +95,7 @@ def __init__(self, span, input_arr, min_periods=None, thread_tile=48,
if isinstance(input_arr, numba.cuda.cudadrv.devicearray.DeviceNDArray):
self.gpu_in = input_arr
else:
self.gpu_in = input_arr.data.to_gpu_array()
self.gpu_in = input_arr.to_gpu_array()
if min_periods is None:
self.min_periods = span
else:
Expand Down
4 changes: 2 additions & 2 deletions gquant/cuindicator/frac_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def fractional_diff(input_arr, d=0.5, floor=1e-3, min_periods=None,
if isinstance(input_arr, numba.cuda.cudadrv.devicearray.DeviceNDArray):
gpu_in = input_arr
else:
gpu_in = input_arr.data.to_gpu_array()
gpu_in = input_arr.to_gpu_array()

# compute the weights for the fractional difference
weights = get_weights_floored(d=d,
Expand Down Expand Up @@ -269,6 +269,6 @@ def port_fractional_diff(asset_indicator, input_arr, d=0.5, floor=1e-3,
min_periods=min_periods,
thread_tile=thread_tile,
number_of_threads=number_of_threads)
port_mask_nan(asset_indicator.data.to_gpu_array(), out, 0,
port_mask_nan(asset_indicator.to_gpu_array(), out, 0,
len(weights) - 1)
return out, weights
Loading

0 comments on commit 8190afe

Please sign in to comment.