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

version requirements for julia dependencies #5

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM julia:1.1.1
WORKDIR /code
RUN apt-get update && apt-get -y upgrade
RUN apt-get install -y --fix-missing --no-install-recommends \
debconf build-essential autoconf \
curl dirmngr apt-transport-https lsb-release ca-certificates \
python3 python3-setuptools python3-pip
# install latex dependencies
# if timezone is not setup texlive-latex-base can not be installed
RUN ln -snf /usr/share/zoneinfo/Etc/UTC /etc/localtime \
&& echo "Etc/UTC" > /etc/timezone
RUN apt-get install -y --fix-missing --no-install-recommends \
pdf2svg texlive-pictures texlive-latex-extra texlive-luatex
# install nodejs
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
RUN apt-get install -y --fix-missing --no-install-recommends nodejs
RUN python3 -m pip -q install pip --upgrade
RUN python3 -m pip install numpy h5py tensorflow
RUN python3 -m pip install jupyterlab==2.3.1
# RUN useradd -ms /bin/bash jupyter
# USER jupyter
RUN julia -e 'using Pkg; Pkg.add.([ \
Pkg.PackageSpec(;name="Printf"), \
Pkg.PackageSpec(;name="POMDPs", version="v0.7.0"), \
Pkg.PackageSpec(;name="POMDPModelTools", version="v0.1.2"), \
Pkg.PackageSpec(;name="LocalFunctionApproximation", version="v1.1.0"), \
Pkg.PackageSpec(;name="GridInterpolations", version="v1.1.1"), \
Pkg.PackageSpec(;name="Distributed"), \
Pkg.PackageSpec(;name="SharedArrays"), \
Pkg.PackageSpec(;name="StaticArrays", version="v0.12.5"), \
Pkg.PackageSpec(;name="HDF5", version="v0.12.5"), \
Pkg.PackageSpec(;name="Revise"), \
Pkg.PackageSpec(;name="Interact", version="v0.10.3"), \
Pkg.PackageSpec(;name="PGFPlots", version="v3.2.1"), \
Pkg.PackageSpec(;name="Colors", version="v0.12.6"), \
Pkg.PackageSpec(;name="ColorBrewer", version="v0.4"), \
Pkg.PackageSpec(;name="IJulia"), \
Pkg.PackageSpec(;name="WebIO", version="v0.8.15")])'
ENV JUPYTER_ENABLE_LAB=yes
RUN julia -e 'using WebIO; WebIO.install_jupyter_labextension()'
EXPOSE 8888/tcp
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ Although this repository contains the source code used to generate the advisory
The remainder of this README describes how the score table is generated in Julia, how neural networks are trained in Python using tensorflow, and how the neural network policies can be visualized using Julia kernel for a Jupyter notebook.

## Generate MDP Policy
Required Julia Packages: Printf, POMDPs, POMDPModelTools, LocalFunctionApproximation, GridInterpolations, Distributed, SharedArrays, StaticArrays, HDF5
Required Julia Packages: Printf, POMDPs@v0.7.0, POMDPModelTools@v0.1.2, LocalFunctionApproximation, GridInterpolations, Distributed, SharedArrays, StaticArrays, HDF5

Tested with Julia v1.1
> Note: A Docker container with Julia v1.1 and the dependencies set up at the correct versions is available with the Dockerfile of this repository. Have a look at the end of this document on a quick guide on how to use it.

The policy is generated in parallel via Julia by running `julia -p NUM_PROCS SolveMDP.jl` in the GenerateTable folder, where NUM_PROCS is the number of processors you want to use. The top of SolveMatrix.jl specifies where the table should be written to as an HDF5 file.

Expand All @@ -38,8 +39,23 @@ After generating the table, the table needs to be formatted into training data f
Next, run `python trainHCAS.py PREV_ADV TAU <gpu_ind>`, where PREV_ADV is the index of the previous advsiroy you want to train, TAU is the tau value, and gpu_ind is an optional input to specify which GPU to use. If you want to use a CPU instead, use -1 (the default if omitted). Options at the top of the file allow you to specify where the training data is stored and where the .nnet files should be written. There are additional options for the user to specify additional setting for network training.

## Visualize the Policies
Required Julia Packages: GridInterpolations, Interact, PGFPlots, Colors, ColorBrewer, HDF5
Required Julia Packages: GridInterpolations, Interact, PGFPlots, Colors, ColorBrewer, HDF5, Revise

Tested with Julia v1.1

After generating MDP policies and training neural networks, the policies can be visualized. There is an example Jupyter notebook in the PolicyViz folder that shows how the policies can be interactively visualized.

## Julia Docker Container
The Dockerfile of this repository contains a docker container which contains Julia v1.1 and the packages that are required to run the Julia code in this repository.
To use the container, install docker and run the following commands from the root directory of this repository:
```shell
docker build . -t hcas
docker run -it --rm --mount src="$PWD",target=/code,type=bind hcas bash
```
This will start bash inside the container. To leave the container type "exit".
To execute the code in this repository, just execute the necessary commands inside this bash. The outputs will be available in your copy of the repository (faciliated via the -v option to docker run).

Run the below command to start a jupyter lab instance which will allow you to run the PolicyViz exaple notebook.
```shell
docker run -it --rm --mount src="$PWD",target=/code,type=bind -p 8888:8888 hcas jupyter lab --port 8888 --no-browser --ip 0.0.0.0 --allow-root
```