Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

installation and docker guide #261

Draft
wants to merge 77 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
59d122e
add docker, fix windows problems, add installation guide
alexey-pronkin Nov 3, 2021
56891f7
litle fixes, not done yet
alexey-pronkin Nov 22, 2021
2c7d41f
start making dokerfile
alexey-pronkin Jun 13, 2022
4ec42f2
add script convert2ipynb and light docker
alexey-pronkin Jun 15, 2022
91f9e20
change gitignore and next stage of dockerfile
alexey-pronkin Jun 16, 2022
a98aa91
working docker
alexey-pronkin Jun 16, 2022
8485671
Merge branch 'master' into feature/docker2
alexey-pronkin Jun 18, 2022
bd136bc
style change
alexey-pronkin Jun 18, 2022
8b9e629
style 2
alexey-pronkin Jun 18, 2022
77f632e
style 2
alexey-pronkin Jun 18, 2022
893218d
fix convert2ipynb.py; add .dockerignore; add toml2requirements.py
Jun 22, 2022
d519fc8
refactor scripts, remove bugs
alexey-pronkin Jun 24, 2022
e306988
manually change requirements file
alexey-pronkin Jun 25, 2022
f6bf0d8
Merge branch 'master' into feature/docker2
alexey-pronkin Jun 25, 2022
69e1fc6
working with listner docker stage
alexey-pronkin Jun 26, 2022
a9677ce
not working bash in listener stage
alexey-pronkin Jun 27, 2022
a75192c
Update comment
alexey-pronkin Jun 27, 2022
efcd23d
Merge branch 'master' into feature/docker2
alexey-pronkin Jun 27, 2022
cb3ee79
add entry point
alexey-pronkin Jun 28, 2022
170dcd0
add tex libs
Jul 3, 2022
607e2dd
refactor docker, remove buildings to interactive regime
alexey-pronkin Jul 7, 2022
5da04d1
clean
alexey-pronkin Jul 8, 2022
1bdefba
merge master
alexey-pronkin Jul 8, 2022
c9916f4
add test to convert2ipynb.py
alexey-pronkin Jul 8, 2022
f51727f
Merge branch 'feature/docker' into feature/docker2
alexey-pronkin Jul 8, 2022
ab11b58
Merge pull request #409 from quantum-ods/feature/docker2
alexey-pronkin Jul 8, 2022
9859ef1
fix merge
alexey-pronkin Jul 8, 2022
fc33b41
starting working on docker lecture
alexey-pronkin Jul 8, 2022
2cc4136
Merge branch 'master' into feature/docker
vvssttkk Jul 8, 2022
1a3f891
start working on install lecture test
alexey-pronkin Jul 10, 2022
0047393
Merge branch 'feature/docker' of https://github.com/SemyonSinchenko/q…
alexey-pronkin Jul 10, 2022
a2c6657
Merge branch 'master' into feature/docker
alexey-pronkin Jul 10, 2022
0830fbb
fix test-installation and lecture
alexey-pronkin Jul 10, 2022
b8c24d2
Merge branch 'feature/docker' of https://github.com/SemyonSinchenko/q…
alexey-pronkin Jul 10, 2022
abfc0ae
staged version
alexey-pronkin Jul 11, 2022
dfd9354
Merge branch 'master' into feature/docker
vvssttkk Jul 15, 2022
a015f45
style: apply
vvssttkk Jul 15, 2022
494779b
pre-commit autoupdate & add args for mypy
vvssttkk Jul 15, 2022
bf7f9c2
style: bump flake8
vvssttkk Jul 15, 2022
8a05e8b
style: apply
vvssttkk Jul 15, 2022
92ec179
refactor: rename `scripts/` to `tools/`
vvssttkk Jul 16, 2022
6aaddc6
refactor: transfer from tools/ to tests/ 1 test file
vvssttkk Jul 16, 2022
da9292e
refactor: remove comment lines from makefile
vvssttkk Jul 16, 2022
6edf150
refactor tests
vvssttkk Jul 16, 2022
d126c03
refactor: rename `convert2ipynb` to `convert`
vvssttkk Jul 16, 2022
ded0cba
refactorL naming
vvssttkk Jul 16, 2022
314fa67
refactor: update how to run convert file
vvssttkk Jul 16, 2022
298d822
refactor: add version for some reqs & add fire
vvssttkk Jul 16, 2022
a3e1b65
refactor
vvssttkk Jul 16, 2022
099e1a4
ci: rename `name` pre-commit
vvssttkk Jul 16, 2022
b99537e
add todo about toml2reqs
vvssttkk Jul 16, 2022
c88a8cc
tests: replave some test files by conftest
vvssttkk Jul 16, 2022
016d6a6
test: update tests little bit
vvssttkk Jul 16, 2022
cc1e80a
style: apply for conftest
vvssttkk Jul 16, 2022
a979664
ci: add jupytext to runt tests
vvssttkk Jul 16, 2022
3a37698
add __init__
vvssttkk Jul 16, 2022
922d8d9
add tools/__init__
vvssttkk Jul 16, 2022
515a382
fixL typing for toc file
vvssttkk Jul 16, 2022
fb7008f
test: add data/
vvssttkk Jul 16, 2022
f61efa7
test: update
vvssttkk Jul 16, 2022
96f1078
refactor tools
vvssttkk Jul 16, 2022
28f7e61
style
vvssttkk Jul 16, 2022
0ebcb6d
ci: add deps
vvssttkk Jul 16, 2022
22dbabb
ci: add pytests
vvssttkk Jul 16, 2022
66e7e07
add loguru to reqs
vvssttkk Jul 16, 2022
5c0eef4
refactor
vvssttkk Jul 16, 2022
771fb5c
style
vvssttkk Jul 16, 2022
c719ca5
remove caplog
vvssttkk Jul 16, 2022
c8ce44e
refactor
vvssttkk Jul 16, 2022
a4cc27a
test: remove finally
vvssttkk Jul 16, 2022
e760dfd
add to gitignore some tests data
vvssttkk Jul 16, 2022
3cd5836
ci: refactor test-installation
vvssttkk Jul 16, 2022
0a327f3
Merge branch 'master' into feature/docker
vvssttkk Jul 17, 2022
2b3ad8e
change order of dockerfile for old docker engines. Change order in le…
alexey-pronkin Jul 18, 2022
99ec43c
resolve conflict
vvssttkk Aug 19, 2022
2da977b
Merge branch 'master' into feature/docker
vvssttkk Aug 19, 2022
7deea99
ci: add instaling deps & tests
vvssttkk Aug 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.git/*
.github/*
34 changes: 33 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

pre-commit:
runs-on: ubuntu-latest
timeout-minutes: 10
timeout-minutes: 4

steps:
- name: checkout code
Expand All @@ -20,8 +20,40 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: 3.8
cache: 'pip'

- name: install dependencies
run: |
python -m pip install --upgrade pip

pip install fire jupytext pytest loguru

- name: run pre-commit action
uses: pre-commit/[email protected]
with:
extra_args: --all-files

tests:
needs: pre-commit
runs-on: ubuntu-latest
timeout-minutes: 2

steps:
- name: checkout code
uses: actions/checkout@v3

- name: set up py3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
cache: 'pip'

- name: install dependencies
run: |
python -m pip install --upgrade pip

pip install fire jupytext pytest loguru

- name: run tests
run: |
python -m pytest tests/ -vv
36 changes: 36 additions & 0 deletions .github/workflows/test-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Test docker for dev and listner
name: test-docker

on:
workflow_dispatch:
push:
branches: [ master ]

jobs:

deploy_book:
runs-on: ubuntu-latest
timeout-minutes: 60

steps:
- name: checkout branch for build
uses: actions/checkout@v2
- name: set up docker
uses: actions/setup-docker@v1
- name: build dev (qml-dev) docker
run: |
docker build . --tag qml-dev:latest --target dev
- name: test dev (qml-dev) docker
run: |
docker run -it qml-dev:latest /bin/bash
exit
- name: build listener (qmlcourse) docker
run: |
docker build . --tag qmlcourse:latest --target listener
docker run -it -p 8888:8888 qmlcourse:latest
- name: test listener (qmlcourse) docker
run: |
docker run -it -p 8888:8888 qmlcourse:latest
conda activate qmlcourse
jupyter --version
exit
46 changes: 46 additions & 0 deletions .github/workflows/test-installation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: test-listener-os
# This repo testing instructions from lecture book/install/{ru/en}/intro.md

on:
workflow_dispatch:
inputs:
os:
# TODO
description: 'Choose OS for test'
required: false
default: '"ubuntu-latest", "macos-latest", "windows-latest"'

jobs:

test-listener-all:
name: Listener miniconda (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest"]
python-version: ["3.8", "3.9"]

steps:
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}

- name: conda create and activate env
shell: bash -l {0}
run: |
conda create -n qmlcourse python=3.8 --yes
conda activate qmlcourse

- name: install psi-4 Non-Windows
shell: bash -l {0}
run: conda run -n qmlcourse conda install psi4 python=3.8 -c psi4 --yes

- name: install all other packages
run: |
conda run -n qmlcourse python -m pip install -r requirements.txt
conda run -n qmlcourse conda install -c conda-forge jupyterlab --yes

- name: test jupyter
run: conda run -n qmlcourse jupyter --version
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,11 @@ _minted*
# Jupyter Book
_build*

# VSCode settings dir
# VSode settings dir
.vscode
_tmp_notebooks

# Notebooks dir
notebooks/

# some tests data
tests/data/lecture.ipynb
56 changes: 56 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
####
# Purpose of this stage is to get all packages from lectures and jupyter lab to interact with lectures.
####

FROM continuumio/miniconda3:latest as listener
WORKDIR qmlcourse
COPY . .
RUN conda create -n qmlcourse python=3.8 --yes
RUN conda run -n qmlcourse conda install psi4 python=3.8 -c psi4 --yes
RUN conda run -n qmlcourse python -m pip install -r requirements/requirements-listener.txt
RUN conda run -n qmlcourse conda install -c conda-forge jupyterlab --yes

# Configure environment
ENV CONDA_DIR=/opt/conda \
SHELL=/bin/bash
ENV PATH="${SHELL}:${PATH}"
ENV PATH="${CONDA_DIR}/bin:${PATH}"
EXPOSE 8888
ENTRYPOINT ["bash"]

# Starting jupyter lab in interactive docker shell:
# docker run -it -p 8888:8888 qmlcourse:latest
# conda activate qmlcourse
# jupyter lab --ip='0.0.0.0' --port=8888 --no-browser --allow-root

####
# Purpose of the builder is to make all lectures, convert them into ipython notebooks (.ipynb). This operation is time costly and take a lot of space on the drive.
# After that we could use lightweight environment
####

ARG GIT-BRANCH=master
FROM ubuntu:20.04 as dev
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/London
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt update && apt install -y build-essential git wget tzdata
RUN apt update && apt install -y python3-pip
RUN python3 -m pip install poetry
RUN apt update && apt install -y

# Needed if we pull from dockerhub without local repo.
# RUN git clone https://github.com/quantum-ods/qmlcourse.git

WORKDIR qmlcourse
COPY . .
# RUN git checkout ${GIT-BRANCH}
RUN poetry install --no-interaction --no-root
RUN apt update && apt install -y texlive-latex-extra texlive-fonts-extra texlive-xetex latexmk
RUN poetry run python tools/convert.py md_to_ipynb
RUN poetry run jupyter-book toc migrate ./qmlcourse/_toc.yml -o ./qmlcourse/_toc.yml
RUN poetry run jupyter-book build ./qmlcourse --keep-going
# Get latex file
RUN poetry run jupyter-book build ./qmlcourse --builder latex --keep-going
# TODO: Building pdf
# xelatex -interaction nonstopmode qmlcourse.tex
ENTRYPOINT ["/bin/bash"]
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,17 @@ install-python-poetry-ubuntu:
sudo apt install python3-distutils -y
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3

# curl "http://vergil.chemistry.gatech.edu/psicode-download/Psi4conda-1.4rc3-py38-Linux-x86_64.sh" -o Psi4conda-1.4rc3-py38.sh --keepalive-time 2

install-python-poetry-macos:
brew update
brew install zlib pyenv poetry

pyenv install 3.8.10
pyenv local 3.8.10

# curl "http://vergil.chemistry.gatech.edu/psicode-download/Psi4conda-1.4rc3-py38-MacOSX-x86_64.sh" -o Psi4conda-1.4rc3-py38.sh --keepalive-time 2

install-python-dependencies:
# poetry env use python3.8
poetry env list
poetry install --no-interaction --no-root

build-linux-macos:
# cd $(HOME)/psi4conda/etc/profile.d/ && source conda.sh && conda activate && cd - && poetry run psi4 --test
poetry run jupyter-book build ./qmlcourse
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ tensorflow-quantum = "0.6.0"

Jinja2 = "3.0.3"
# [tool.poetry.dev-dependencies]
jupytext = "^1.13.8"
fire = "^0.4.0"
loguru = "^0.6.0"
pre-commit = "^2.20.0"


[build-system]
Expand Down
9 changes: 9 additions & 0 deletions qmlcourse/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,15 @@
- file: book/intro/en/prerequisite.md
title: ⬜ Prerequisite

- part: Installation
chapters:
- file: book/install/en/intro.md
title: 🟩 Basic installation
- file: book/install/en/docker.md
title: 🟩 Working with docker
- file: book/install/en/advanced.md
title: 🟧 Optimization environment for production or GPU use

- part: Linear Algebra and Numpy
chapters:
- file: book/linalg/en/linalg_intro.md
Expand Down
53 changes: 53 additions & 0 deletions qmlcourse/book/install/en/advanced.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Advanced install of packages

**NOTE**

You could also install all packages from Intel optimized repositories, but for now, we don't test this approach. This could make sense in four cases:

- if you are using a very old Intel/AMD processor (that does not have AVX2 instructions, for example). Then with high probability, you'll need to compile some packages by yourself. Intel® Distribution for Python contains many compilers and tools to help you with this non-trivial task.
- if you are using an extra modern Intel CPU with AVX-512 or new AMX instructions. Or your CPU has more than eight cores.
- if you are using cluster and don't want to install OpenMP and other libraries manually.
In the mean case scenario with 8 cores CPU, you probably get about a 10% increase in the speed of calculations that, in my opinion, do not cost additional efforts and space on your SSD/HDD. Some users review that this actually works with an AMD processor, so if you have an AMD CPU you could message @avpronkin in ODS.ai Slack about a successful installation or ask for help.

### Intel® Distribution for Python

First of all, update your conda:

```shell
conda update conda
```

Secondly, add the Intel channel for packages:

```shell
conda config --add channels intel
```

Finally, create intel based python environment and activate it:

```shell
conda create -n qmlcourse intelpython3_core python=3.8 --yes
conda activate qmlcourse
```

After you could activate your environment and continue to install all other packages, conda automatically search all repositories with the preference of the intel repo.

If you stack with problems, you could remove the Intel channel

```shell
conda config --remove channels intel
```

And remove `qmlcourse` environment:
**WARNING**
_This cannot be undone, so you remove all packages that you install in `qmlcourse` environment_

```shell
conda deactivate
conda env remove -n qmlcourse
```

## GPU

Before installation the main packages, you could install the GPU version of TensorFlow/JAX.
See instructions here [_tensorflow-gpu_](https://www.tensorflow.org/install/gpu), [_JAX GPU_](https://github.com/google/jax#pip-installation-gpu-cuda).
Loading