0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

DockerでQuantum Espresso環境構築

Posted at

はじめに

新しく購入したMac miniにQuantum Espressoの実行環境を整えたい。Macに直接インストールしても良いのですが、dockerで作った仮想環境上にインストールすれば、ローカルの環境を汚さずにできるのでは?と考えました。
調べてみたところ以下のgithubレポジトリがかなり参考になりそうでした:

これを元に、dockerを使ってMac(Apple M2)上にQE v7.3.1(とPython)をインストールしてみます。

この記事ですること

  • dockerを使ってQuantum EspressoとPythonがインストールされた仮想環境を構築する

この記事の対象者

  • Quantum Espressoをインストールしたいけど、ローカルの環境を汚したくない人

手順

  1. Dockerを使い始める
  2. Dockerfileを書く
  3. Dockerイメージをビルドする
  4. ビルドしたDockerイメージを使ってコンテナを作る
  5. そのコンテナ内で色々作業していく

動作環境

  • OSバージョン
    • macOS Sonoma 14.5
  • ツール
    • docker
    • Quantum Espresso 7.3.1
    • Python 3.9.4

参考資料

詳細

ステップ1: Dockerを使い始める

まず以下に従ってDocker Desktopをインストールします。
https://docs.docker.com/desktop/setup/install/mac-install/

ステップ2: Dockefileを書く

参考レポジトリのDockerfileを少し修正し、
今回は以下内容にしました。

# Dockerfile for quantum espresso ver7.3.1 and Python-3.9.4

# Use the latest Ubuntu as the base image
FROM ubuntu:latest

# Set the frontend to noninteractive to prevent interactive prompts during installation
# switch off this line for debugging
ENV DEBIAN_FRONTEND "noninteractive"

# Install necessary packages
RUN apt-get update \
    && apt-get install -y \
        git \
        vim \
        curl \
        build-essential \
        gcc \
        gfortran \
        gnuplot \
        openmpi-doc \
        openmpi-bin \
        libopenmpi-dev \
        openssl \
        libssl-dev \
        libreadline-dev \
        ncurses-dev \
        bzip2 \
        zlib1g-dev \
        libbz2-dev \
        libffi-dev \
        libopenblas-dev \
        liblapack-dev \
        libsqlite3-dev \
        liblzma-dev \
        libpng-dev \
        libfreetype6-dev

# OpenMPI configuration
ENV OMPI_MCA_btl_vader_single_copy_mechanism "none"
ENV OMPI_ALLOW_RUN_AS_ROOT 1
ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM 1

# Set working directory to /usr/local/src
WORKDIR /usr/local/src

## Python installation
RUN curl https://www.python.org/ftp/python/3.9.4/Python-3.9.4.tgz -O -L \
    && tar zxf Python-3.9.4.tgz \
    && rm -rf Python-3.9.4.tgz \
    && cd Python-3.9.4 \
    && ./configure \
    && make \
    && make altinstall \
    && ln -s /usr/local/bin/python3.9 /usr/local/bin/python \
    && ln -s /usr/local/bin/pip3.9 /usr/local/bin/pip
    ENV PYTHONIOENCODING "utf-8"
    RUN pip install pip -U \
        && pip install \
            numpy \
            scipy \
            matplotlib \
            sympy \
            pandas \
            tqdm \
            Pillow \
            ase \
            joblib \
            Cython \
            fire

RUN cd ..

## Quantum espresso installation
RUN curl hogehoge -O -L
RUN tar xvf qe-7.3.1-ReleasePack.tar.gz \
    && rm -rf qe-7.3.1-ReleasePack.tar.gz
RUN cd qe-7.3.1 \
    && ./configure \
    && make all \
    && make install

ただし最後のRUN curl hogehoge -O -Lの部分には、Quantum Espressoダウンロードページからv7.3.1のダウンロードリンクをコピーして貼り付けしてください

ステップ3: Dockerイメージをビルドする

ターミナルで以下を実行する

docker build ./ -t qe-7.3.1:latest

ステップ4: ビルドしたDockerイメージを使ってコンテナを作る

ターミナルで以下を実行する

docker run --name qe-7.3.1 -it qe-7.3.1:latest

ステップ5: そのコンテナ内で色々作業していく

Let's 作業

おわりに

dockerを使って、ローカル環境に影響を与えずにQuantum Espressoをインストールしてみました。

これから実際に色々計算してき、仮想環境上でQEを実行することのメリットやデメリット、
またどうやったら使いやすくなるかなど、気づいたことがあったら追記/記事作成していこうと思います。

コメントなどあればどしどしお願いします!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?