content: FROM nvcr.io/nvidia/clara/bionemo-framework:1.2
  
  ARG EFA_INSTALLER_VERSION=1.37.0
  ARG AWS_OFI_NCCL_VERSION=v1.13.2-aws
  
  RUN apt-get update -y && apt-get upgrade -y
  RUN apt-get remove -y --allow-change-held-packages \
      ibverbs-utils \
      libibverbs-dev \
      libibverbs1 \
      libmlx5-1 \
      libnccl2 \
      libnccl-dev
  
  RUN rm -rf /opt/hpcx \
      && rm -rf /usr/local/mpi \
      && rm -f /etc/ld.so.conf.d/hpcx.conf \
      && ldconfig
  
  ENV OPAL_PREFIX=
  
  RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated \
      apt-utils \
      autoconf \
      automake \
      build-essential \
      check \
      cmake \
      curl \
      debhelper \
      devscripts \
      git \
      gcc \
      gdb \
      kmod \
      libsubunit-dev \
      libtool \
      openssh-client \
      openssh-server \
      pkg-config \
      python3-setuptools \
      vim
  RUN apt-get purge -y cuda-compat-*
  
  RUN mkdir -p /var/run/sshd
  RUN sed -i 's/[ #]\(.*StrictHostKeyChecking \).*/ \1no/g' /etc/ssh/ssh_config && \
      echo "    UserKnownHostsFile /dev/null" >> /etc/ssh/ssh_config && \
      sed -i 's/#\(StrictModes \).*/\1no/g' /etc/ssh/sshd_config
  
  ENV LD_LIBRARY_PATH=/usr/local/cuda/extras/CUPTI/lib64:/opt/amazon/openmpi/lib:/opt/nccl/build/lib:/opt/amazon/efa/lib:/opt/aws-ofi-nccl/install/lib:/usr/local/lib:$LD_LIBRARY_PATH
  ENV PATH=/opt/amazon/openmpi/bin/:/opt/amazon/efa/bin:/usr/bin:/usr/local/bin:$PATH
  
  RUN curl https://bootstrap.pypa.io/get-pip.py -o /tmp/get-pip.py \
      && python3 /tmp/get-pip.py \
      && pip3 install awscli pynvml
  
  #################################################
  ## Install EFA installer
  RUN cd $HOME \
      && curl -O https://efa-installer.amazonaws.com/aws-efa-installer-${EFA_INSTALLER_VERSION}.tar.gz \
      && tar -xf $HOME/aws-efa-installer-${EFA_INSTALLER_VERSION}.tar.gz \
      && cd aws-efa-installer \
      && ./efa_installer.sh -y -g -d --skip-kmod --skip-limit-conf --no-verify \
      && rm -rf $HOME/aws-efa-installer
  
  ###################################################
  ## Install AWS-OFI-NCCL plugin
  RUN DEBIAN_FRONTEND=noninteractive apt-get install -y libhwloc-dev
  #Switch from sh to bash to allow parameter expansion
  SHELL ["/bin/bash", "-c"]
  RUN curl -OL https://github.com/aws/aws-ofi-nccl/releases/download/${AWS_OFI_NCCL_VERSION}/aws-ofi-nccl-${AWS_OFI_NCCL_VERSION//v}.tar.gz \
      && tar -xf aws-ofi-nccl-${AWS_OFI_NCCL_VERSION//v}.tar.gz \
      && cd aws-ofi-nccl-${AWS_OFI_NCCL_VERSION//v} \
      && ./configure --prefix=/opt/aws-ofi-nccl/install \
          --with-mpi=/opt/amazon/openmpi \
          --with-libfabric=/opt/amazon/efa \
          --with-cuda=/usr/local/cuda \
          --enable-platform-aws \
      && make -j $(nproc) \
      && make install \
      && cd .. \
      && rm -rf aws-ofi-nccl-${AWS_OFI_NCCL_VERSION//v} \
      && rm aws-ofi-nccl-${AWS_OFI_NCCL_VERSION//v}.tar.gz
  
  SHELL ["/bin/sh", "-c"]
  
  
  ##############################################
  ## BioNemo dependencies
  COPY requirements.txt /workspace/
  RUN pip3 install -r /workspace/requirements.txt
  
  COPY prepare_uniref50.py /workspace/bionemo
  
  WORKDIR /workspace/bionemo
  