Giter Site home page Giter Site logo

Comments (3)

xeniorn avatar xeniorn commented on May 27, 2024

@komatsuna-san: we'd also like to containerize relion via apptainer - would you be willing to share your def file if you already have it running? Would be highly appreciated.
Cheers,
xen

from relion.

komatsuna-san avatar komatsuna-san commented on May 27, 2024

@xeniorn

My current environment is shown below. Note that I have not been able to test all features.

                      OS: AlmaLinux 8 (on WSL2)
               Apptainer: ver. 1.2.3-1.el8
           NVIDIA Driver: ver. 531.41
NVIDIA Container Toolkit: ver. 1.13.5

My apptainer container recipe relion-v5.0b.def is as follows.

BootStrap: docker
From: nvidia/cuda:11.7.1-cudnn8-devel-ubuntu22.04

%post
  ### Set up Ubuntu ###
  # for localtime WARNING
  touch /etc/localtime

  # Install RELION dependent packages
  apt update && apt upgrade -y
  apt install -y \
    build-essential gcc-9 g++-9 cmake git curl mpi-default-bin mpi-default-dev \
    libtiff-dev libpng-dev ghostscript libxft-dev libgl1-mesa-dev
  
  # Add en_US.UTF-8 to locale
  apt install -y locales
  locale-gen en_US.UTF-8

  # Clean up apt
  rm -rf /var/lib/apt/lists/* && apt autoremove -y && apt clean

  # Default to gcc-9 and g++-9
  update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 99
  gcc --version
  update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 99
  g++ --version
  
  ### Install CTFFIND-4.1.14 ###
  # Prepare the installation directory
  mkdir -p /usr/local/apps/ctffind-4.1.14
  cd /usr/local/apps/ctffind-4.1.14
  
  # Download CTFFIND
  DL_URL='https://grigoriefflab.umassmed.edu/system/tdf?path=ctffind-4.1.14-linux64.tar.gz&file=1&type=node&id=26'
  curl -L ${DL_URL} -o ./ctffind-4.1.14-linux64.tar.gz
  
  # Extract and then remove the downloaded .tar.gz file
  tar -xvf ./ctffind-4.1.14-linux64.tar.gz
  rm -f ./ctffind-4.1.14-linux64.tar.gz
  
  ### Install python libraries for RELION                       ###
  ### Blush, DynaMight, Model-Angelo, Classranker, Topaz, etc.) ###
  # Install Pyenv to /usr/local/apps
  git clone https://github.com/yyuu/pyenv.git /usr/local/apps/pyenv
  export PYENV_ROOT="/usr/local/apps/pyenv"
  export PATH="${PYENV_ROOT}/bin:${PATH}"

  # Install Miniforge through Pyenv
  pyenv install --list
  pyenv install miniforge3-22.9.0-3
  pyenv global miniforge3-22.9.0-3
  pyenv versions
  # Activate the environment of installed Miniforge
  export MINIFORGE3_ROOT="${PYENV_ROOT}/versions/miniforge3-22.9.0-3"
  export PATH="${MINIFORGE3_ROOT}/bin:${PATH}"
  
  # Update conda
  conda update -n base conda
  
  # Clone RELION (ver. 5.0-beta) repository to /usr/local/apps/relion-git
  git clone https://github.com/3dem/relion.git -b ver5.0 /usr/local/apps/relion-git
  cd /usr/local/apps/relion-git
  # Modify the environment.yml to use only conda-forge
  sed -i.bak -e 's|name: relion-5.0|name: relion-conda|g' ./environment.yml
  sed '/- defaults/d' ./environment.yml
  
  # Create a conda environment for RELION (relion-conda)
  conda env create -f ./environment.yml
  # Clean up conda
  conda clean --all --force-pkgs-dirs --yes

  # Activate the relion-conda
  export RELION_CONDA="${MINIFORGE3_ROOT}/envs/relion-conda"
  export PATH="${RELION_CONDA}/bin:${PATH}"
  export LD_LIBRARY_PATH="${RELION_CONDA}/lib:${LD_LIBRARY_PATH}"
  # Check the list of installed libraries
  conda list -n relion-conda

  ### Install RELION (ver. 5.0-beta) ###
  # Prepare directories for RELION build
  mkdir -p /usr/local/apps/relion-git/build
  mkdir -p /usr/local/apps/torch/home
  export TORCH_HOME="/usr/local/apps/torch/home"
  
  cd /usr/local/apps/relion-git/build
  
  # Install RELION to /usr/local/apps/relion-v5.0-beta
  # Add -DAMDFFTW=ON to the following (if AMD CPU)
  cmake \
    -DCMAKE_INSTALL_PREFIX="/usr/local/apps/relion-v5.0-beta" \
    -DFORCE_OWN_FFTW=ON -DFORCE_OWN_FLTK=ON \
    -DPYTHON_EXE_PATH="${RELION_CONDA}/bin/python" \
    -DTORCH_HOME_PATH="${TORCH_HOME}" \
    ..
  make -j8 && make install

%environment
  # For OpenMPI
  export LD_LIBRARY_PATH="/usr/lib/x86_64-linux-gnu/openmpi/lib:${LD_LIBRARY_PATH}"
  
  # For RELION
  export RELION_HOME="/usr/local/apps/relion-v5.0-beta"
  export PATH="${RELION_HOME}/bin:${PATH}"
  export LD_LIBRARY_PATH="${RELION_HOME}/lib:${LD_LIBRARY_PATH}"

  # For Blush, DynaMight, Model-Angelo, Classranker, Topaz, etc.
  export MINIFORGE3_ROOT="/usr/local/apps/pyenv/versions/miniforge3-22.9.0-3"
  export RELION_CONDA="${MINIFORGE3_ROOT}/envs/relion-conda"
  export PATH="${RELION_CONDA}/bin:${PATH}"
  export TORCH_HOME="/usr/local/apps/torch/home"
  
  # Default CTFFIND-4.1+ executable
  export RELION_CTFFIND_EXECUTABLE="/usr/local/apps/ctffind-4.1.14/bin/ctffind"

  # The default scratch directory in the GUI
  # (depends on your environment outside this container)
  export RELION_SCRATCH_DIR="/scratch"

%runscript
  "$@"

For example, build the RELION container as follows.

apptainer build ./relion-v5.0b.sif ./relion-v5.0b.def

Start RELION as follows.
Suppose the relion-v5.0b.sif is placed at ${APPTAINER_IMAGE}.

apptainer run --nvccli --bind /scratch:/scratch ${APPTAINER_IMAGE}/relion-v5.0b.sif relion

--nvccli needs nvidia-container-toolkit.

--bind /scratch:/scratch depends on your system.

Regards,

from relion.

xeniorn avatar xeniorn commented on May 27, 2024

Thanks a lot, highly appreciated!

from relion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.