MeasureTransport / MeasureTransport/MParT
MATLAB Dockerfile
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
This is more of a posting, perhaps prefacing official support for a docker image for matlab bindings. This works on my computer, and I think should work on others. EDIT: This has been updated 1/27/23 to reflect the state of our current dependencies (i.e. added cereal and nlopt).
Change your directory to /your/path/MPART_DOCKER_MATLAB/ and make a file Dockerfile (no file extension)
# We pull from the MATLAB official image
FROM mathworks/matlab:r2022b
# Everything has to be done as root
USER root
# Install all the dependencies
RUN apt-get update && \
apt-get install -y git cmake g++-9 libstdc++6
# Ensure we're using a new version of g++
RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 100
# Clone and install Eigen 3.4
RUN git clone --depth 1 https://gitlab.com/libeigen/eigen.git --branch 3.4 && \
cd eigen && \
mkdir build && \
cd build && \
cmake .. && \
make && \
make install
# Clone and install Kokkos
RUN git clone --depth 1 https://github.com/kokkos/kokkos.git --branch 3.7.01 && \
mkdir kokkos/build && \
cd kokkos/build && \
cmake \
-DKokkos_ENABLE_SERIAL=ON \
-DKokkos_ENABLE_OPENMP=ON \
-DKokkos_ENABLE_CUDA=OFF \
-DKokkos_ENABLE_HIP=OFF \
-DKokkos_ENABLE_SYCL=OFF \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_CXX_STANDARD=17 \
../ && \
make -j$(nproc) && \
make install && \
cd / && \
rm -rf kokkos
# Clone and install cereal
RUN git clone --depth 1 https://github.com/USCiLab/cereal.git --branch v1.3.2 && \
mkdir cereal/build && \
cd cereal/build && \
cmake -DJUST_INSTALL_CEREAL=ON ../ && \
make -j$(nproc) && \
make install && \
cd / && \
rm -rf cereal
# Clone and install NLopt
RUN git clone --depth 1 https://github.com/stevengj/nlopt.git --branch v2.7.1 && \
mkdir nlopt/build && \
cd nlopt/build && \
cmake ../ && \
make -j$(nproc) && \
make install && \
cd / && \
rm -rf nlopt
# Set default user as matlab
ENV M_USER=matlab
ENV MPART_HOME=/home/${M_USER}/MParT
# Set up and compile Matlab
RUN git clone --depth 1 https://github.com/MeasureTransport/MParT.git && \
cd MParT && \
mkdir build && \
cd build && \
cmake -DMPART_BUILD_TESTS=OFF \
-DMPART_PYTHON=OFF \
-DMPART_JULIA=OFF \
-DMPART_FETCH_DEPS=OFF \
-DMPART_MATLAB=ON \
-DCMAKE_INSTALL_PREFIX=${MPART_HOME} \
../ && \
make && \
make -j$(nproc) install && \
cd / && \
rm -rf MParT
WORKDIR /home/${M_USER}
SHELL ["/bin/bash","-c"]
# You may need the below for <2021 MATLAB?
# RUN MATLAB_VERSION=$(basename $(matlab -n | grep ' MATLAB ' | cut -d= -f2)) && \
# echo ${MATLAB_VERSION} && \
# rm /opt/matlab/${MATLAB_VERSION}/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6 && \
# ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /opt/matlab/${MATLAB_VERSION}/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6
RUN sed -i "2iaddpath(genpath('$MPART_HOME'))\nsetenv('OMP_PROC_BIND','spread')\nsetenv('OMP_PLACES','threads')" /home/$M_USER/Documents/MATLAB/startup.m
USER $M_USER
Then, run docker build . to build the image. At the very bottom, you should get a container ID (12 digit hexadecimal). Finally, run the image in command line with docker run -it 0123456789ab, where you replace the last phrase with your container ID. Follow the directions to log into MATLAB, and you'll have a matlab REPL with MParT already installed.
More importantly, you can run docker run -it -p 8888:8888 0123456789ab -browser to get an interactive window in your browser. For more information and other stuff, check out the official MATLAB Docker documentation here.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the proposed Dockerfile and the documented docker build . and docker run commands. Review how the listed Eigen, Kokkos, cereal, NLopt, and MParT dependencies are built, then verify that the image provides an interactive MATLAB session with MParT installed and supports the browser command shown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp, docker, matlab
- Domain
- build-system, devops
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100