• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

README.mdH A D06-Dec-20214.7 KiB12394

dockerfileH A D06-Dec-20211.8 KiB6046

README.md

1# Docker setup for OpenFermion and select plugins
2
3This Docker image contains [OpenFermion](https://github.com/quantumlib/OpenFermion)
4and its available plugins for
5[Cirq](https://github.com/quantumlib/Cirq),
6[Psi4](https://github.com/quantumlib/OpenFermion-Psi4), and
7[PySCF](https://github.com/quantumlib/OpenFermion-PySCF).
8Check out Docker's [website](https://www.docker.com/what-container) for a description of
9what a container image is and why it can be so useful.
10The Docker-based installation is extremely robust and runs on any operating
11system, so it is an ideal solution for anyone having difficulty installing
12OpenFermion (or any of its plugins) using the standard procedure.
13
14
15## What's included?
16
17- Git
18- Python 3
19- [OpenFermion](https://github.com/quantumlib/OpenFermion)
20- [Cirq](https://github.com/quantumlib/Cirq)
21- [Psi4](http://www.psicode.org)
22- [PySCF](https://github.com/sunqm/pyscf)
23- [OpenFermion-Cirq](https://github.com/quantumlib/OpenFermion-Cirq)
24- [OpenFermion-Psi4](https://github.com/quantumlib/OpenFermion-Psi4)
25- [OpenFermion-PySCF](https://github.com/quantumlib/OpenFermion-PySCF)
26
27
28## Setting up Docker for the first time
29
30You first need to install [Docker](https://www.docker.com/).
31Once Docker is setup, one can navigate to the folder containing the
32Dockerfile for building the OpenFermion image (docker/dockerfile) and run
33
34```
35docker build -t openfermion_docker .
36```
37
38where "openfermion_docker" is just an arbitrary name for our docker image.
39Building the Dockerfile starts from a base image of Ubuntu and then installs
40OpenFermion, its plugins, and the necessary applications needed for running these
41programs. This is a fairly involved setup and will take some time
42(perhaps up to thiry minutes depending on the computer). Once installation has
43completed, run the image with
44
45```
46docker run -it openfermion_docker
47```
48
49With this command the terminal enters a new environment which emulates Ubuntu with
50OpenFermion and accessories installed. To transfer files from somewhere on the disk to the Docker
51container, first run `docker ps` in a seperate terminal from the one running
52Docker. This returns a list of running containers, e.g.:
53
54```
55+CONTAINER ID        IMAGE               COMMAND             CREATED
56+STATUS              PORTS               NAMES
57+3cc87ed4205b        5a67a4d66d05        "/bin/bash"         2 hours ago
58+Up 2 hours                              competent_feynman
59```
60
61In this example, the container name is "competent_feynman" (the name is
62random and generated automatically). Using this name, one can then copy
63files into the active Docker session from other terminal using:
64
65```
66docker cp [path to file on disk] [container name]:[path in container]
67```
68
69An alternative way of loading files onto the Docker container is through
70remote repos such as GitHub. Git is installed in the Docker image.
71After `docker run`, one could run "git clone ..." etc to pull files
72remotely into the Docker container.
73
74
75## Running Jupyter notebook with Docker backend
76
77To run Jupyter notebooks (such as our demos) in a browser with a Docker container
78running as a backend, first check the ip address of the virtual machine by running
79
80```
81docker-machine ip default
82```
83
84where "default" can be replaced by the name of whichever virtual machine whose
85ip address you want to check. Assuming the Docker image for OpenFermion is built
86and called openfermion_docker, run the container with an additional -p flag:
87
88
89```
90docker run -it -p 8888:8888 openfermion_docker
91```
92
93Here the numbers 8888 simply specifies the port number through which the Docker
94container communicates with the browser. If for some reason this port is not
95available, any other number in 8000-9000 will do. When the terminal enters the Docker container,
96run a Jupyter notebook with:
97
98```
99jupyter-notebook --allow-root --no-browser --port 8888 --ip=0.0.0.0
100```
101
102where 8888 is the port number used previously for setting up the container.
103The message returned to the terminal should end with a statement that says
104something like:
105```
106Copy/paste this URL into your browser when you connect for the first time,
107to login with a token:
108   http://0.0.0.0:8888/?token=8f70c035fb9b0dbbf160d996f7f341fecf94c9aedc7cfaf7
109```
110
111Note the token string 8f70c035fb9b0dbbf160d996f7f341fecf94c9aedc7cfaf7.
112Open a browser and type in the address line
113
114```
115        [virtual machine ip]:8888
116```
117
118where [virtual machine ip] is extracted from `docker-machine ip` and 8888 is the port
119number (or any other port number that one specifies previously). A webpage
120asking for token string should appear. Use the token string obtained from before to
121enter Jupyter notebook. If logged in successfully, you should be able to freely
122navigate through the entire Docker image and launch any Jupyter notebook in the image.
123