# CUDA base
# Setup environmental variables
ENV CUDA_VERSION $cuda_version
ENV NVARCH x86_64
ENV NVIDIA_REQUIRE_CUDA "$nvidia_require_cuda"
 
RUN apt-get update && apt-get install -y --no-install-recommends \
    gnupg2 ca-certificates && \
    curl -fsSLO https://developer.download.nvidia.com/compute/cuda/repos/$ubuntu_version/$${NVARCH}/cuda-keyring_1.1-1_all.deb && \
    dpkg -i cuda-keyring_1.1-1_all.deb \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

# For libraries in the cuda-compat-* package: https://docs.nvidia.com/cuda/eula/index.html#attachment-a
RUN apt-get update && apt-get install -y --no-install-recommends \
    cuda-cudart-$cuda_cudart_version \
    cuda-compat-$cuda_compat_version \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

# Required for nvidia-docker v1
RUN echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf \
    && echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf

ENV PATH /usr/local/nvidia/bin:/usr/local/cuda/bin:$${PATH}
ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64

# TODO: Needed?
# COPY NGC-DL-CONTAINER-LICENSE /

# nvidia-container-runtime
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility