FROM nvidia/cuda:10.1-cudnn7-devel

ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && apt install -y --no-install-recommends \
    sudo \
    git \
    unzip \
    tmux \
    ssh \
    fish \
    curl \
    nano \
    libfreetype6-dev \
    libpng-dev \
    libjpeg-dev \
    libsm6 \
    libvtk6-dev \
    libdc1394-22-dev \
    libavcodec-dev \
    libavformat-dev \
    libswscale-dev \
    libtheora-dev \
    libvorbis-dev \
    libxvidcore-dev \
    libx264-dev \
    yasm \
    libopencore-amrnb-dev \
    libopencore-amrwb-dev \
    libv4l-dev \
    libxine2-dev \
    libtbb-dev \
    libeigen3-dev \
    wget \
    bzip2 \
    ca-certificates \
    cmake \
    xclip \
    libblas3 \
    libblas-dev \
    libxext6 \
    libgl1-mesa-glx \
    libxrender-dev \
    && \
    rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*

ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
ENV TORCH_CUDA_ARCH_LIST="6.0 6.1 7.0+PTX 7.5+PTX"
ENV PATH /opt/conda/bin:$PATH
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh && \
    /bin/bash ~/miniconda.sh -b -p /opt/conda && \
    rm ~/miniconda.sh && \
    /opt/conda/bin/conda clean -tipsy && \
    ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
    echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
    echo "conda activate base" >> ~/.bashrc
RUN conda update -n base -c defaults conda
RUN conda create -n py37 python=3.7 conda && \
    . /opt/conda/etc/profile.d/conda.sh && \
    conda init bash && \
    conda activate py37 && \
    conda install -c conda-forge openmpi &&\
    conda install pytorch==1.4.0 cudatoolkit=10.1 -c pytorch
RUN . /opt/conda/etc/profile.d/conda.sh && conda init bash && conda activate py37 && HOROVOD_GPU_ALLREDUCE=NCCL pip install --no-cache-dir horovod ninja open3d-python==0.5.0.0
ADD conda-entrypoint.sh /conda-entrypoint.sh
ENTRYPOINT [ "/conda-entrypoint.sh" ]