Skip to content

Commit abbd619

Browse files
authored
Add NGC-Matlab R2022a/b images (#277)
1 parent b19f3ce commit abbd619

File tree

6 files changed

+223
-0
lines changed

6 files changed

+223
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,8 @@ yarn.lock
8181
.*.swp
8282
venv*
8383

84+
# Mac
85+
.DS_Store
86+
8487
# Local modification of build script
8588
build-local.sh

vendor/ngc-matlab/Dockerfile.r2022a

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM nvcr.io/partners/matlab:r2022a
2+
3+
USER root
4+
ENV DEBIAN_FRONTEND=noninteractive
5+
6+
# Update the NVIDIA GPG signing key.
7+
RUN apt-key del 7fa2af80 && \
8+
apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub && \
9+
rm -f /etc/apt/sources.list.d/cuda.list && \
10+
rm -f /etc/apt/sources.list.d/nvidia-ml.list
11+
12+
RUN apt update -y && \
13+
apt install -y curl git vim && \
14+
apt install -y ncurses-term && \
15+
ln -sf /usr/share/terminfo/x/xterm-color /usr/share/terminfo/x/xterm-256color && \
16+
apt clean && rm -rf /var/lib/apt/lists/ && rm -rf /root/.cache && rm -rf /tmp/*
17+
18+
LABEL ai.backend.kernelspec="1" \
19+
ai.backend.envs.corecount="OPENBLAS_NUM_THREADS,OMP_NUM_THREADS,NPROC" \
20+
ai.backend.accelerators="cuda" \
21+
ai.backend.features="uid-match" \
22+
ai.backend.base-distro="ubuntu16.04" \
23+
ai.backend.resource.min.cpu="1" \
24+
ai.backend.resource.min.mem="1g" \
25+
ai.backend.resource.preferred.shmem="512m" \
26+
ai.backend.resource.min.cuda.device=0 \
27+
ai.backend.resource.min.cuda.shares=0 \
28+
ai.backend.runtime-type="app" \
29+
ai.backend.runtime-path="/bin/false" \
30+
ai.backend.service-ports="vnc-web:http:6080"
31+
32+
COPY policy.yml /etc/backend.ai/jail/policy.yml
33+
COPY ./service-defs /etc/backend.ai/service-defs
34+
COPY bootstrap.r2022a.sh /opt/container/bootstrap.sh
35+
36+
WORKDIR /home/work
37+
# vim: ft=dockerfile

vendor/ngc-matlab/Dockerfile.r2022b

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM nvcr.io/partners/matlab:r2022b
2+
3+
USER root
4+
ENV DEBIAN_FRONTEND=noninteractive
5+
6+
# Update the NVIDIA GPG signing key.
7+
RUN apt-key del 7fa2af80 && \
8+
apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub && \
9+
rm -f /etc/apt/sources.list.d/cuda.list && \
10+
rm -f /etc/apt/sources.list.d/nvidia-ml.list
11+
12+
RUN apt update -y && \
13+
apt install -y curl git vim && \
14+
apt install -y ncurses-term && \
15+
ln -sf /usr/share/terminfo/x/xterm-color /usr/share/terminfo/x/xterm-256color && \
16+
apt clean && rm -rf /var/lib/apt/lists/ && rm -rf /root/.cache && rm -rf /tmp/*
17+
18+
LABEL ai.backend.kernelspec="1" \
19+
ai.backend.envs.corecount="OPENBLAS_NUM_THREADS,OMP_NUM_THREADS,NPROC" \
20+
ai.backend.accelerators="cuda" \
21+
ai.backend.features="uid-match" \
22+
ai.backend.base-distro="ubuntu16.04" \
23+
ai.backend.resource.min.cpu="1" \
24+
ai.backend.resource.min.mem="1g" \
25+
ai.backend.resource.preferred.shmem="512m" \
26+
ai.backend.resource.min.cuda.device=0 \
27+
ai.backend.resource.min.cuda.shares=0 \
28+
ai.backend.runtime-type="app" \
29+
ai.backend.runtime-path="/bin/false" \
30+
ai.backend.service-ports="vnc-web:http:6080"
31+
32+
COPY policy.yml /etc/backend.ai/jail/policy.yml
33+
COPY ./service-defs /etc/backend.ai/service-defs
34+
COPY bootstrap.r2022b.sh /opt/container/bootstrap.sh
35+
36+
WORKDIR /home/work
37+
# vim: ft=dockerfile

vendor/ngc-matlab/bootstrap.r2022a.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#! /bin/sh
2+
# Reference: /bin/run.sh
3+
set -e
4+
5+
echo ">> Setting up MATLAB environment"
6+
echo ""
7+
echo "# == Matlab" >> ~/.bashrc
8+
export USAGE=cloud && echo "export USAGE=cloud" >> ~/.bashrc
9+
export VARIANTmatlab=matlabLNU && echo "export VARIANTmatlab=matlabLNU" >> ~/.bashrc
10+
export SILENT=false && echo "export SILENT=false" >> ~/.bashrc
11+
12+
SHM_SIZE=$( df -P | grep shm | sed -n -e 's/^\w*\s*\([0-9]*\)\s.*/\1/p' )
13+
if [ -z "$SILENT" ] && [ -n "$SHM_SIZE" ] ; then
14+
# Check it is big enough
15+
if [ ${SHM_SIZE} -le 524200 ] ; then
16+
echo
17+
echo "WARNING:"
18+
echo
19+
echo "This container has a shared area (/dev/shm) of size ${SHM_SIZE}kB. The MATLAB "
20+
echo "desktop requires at least 512MB to run correctly. Restart the session with "
21+
echo "512M of the shared memory."
22+
echo
23+
fi
24+
fi
25+
26+
# Create a desktop launcher
27+
mkdir -p /home/work/Desktop
28+
cat >/home/work/Desktop/MATLAB.desktop <<EOF
29+
[Desktop Entry]
30+
Version=1.0
31+
Type=Application
32+
Name=MATLAB R2022a
33+
Comment=
34+
Exec=/opt/matlab/R2022a/bin/matlab
35+
Icon=/opt/matlab/R2022a/bin/glnxa64/cef_resources/matlab_icon.png
36+
Path=
37+
Terminal=true
38+
StartupNotify=false
39+
Path=/home/matlab/Documents/MATLAB
40+
EOF
41+
chmod +x /home/work/Desktop/MATLAB.desktop
42+
43+
# Make browser VNC auto connect
44+
echo ">> Setting up noVNC auto-connection"
45+
rm /opt/noVNC/index.html
46+
ln -s /opt/noVNC/redirect.html /opt/noVNC/index.html
47+
sed -i 's/password=matlab/password=backendai/' /opt/noVNC/index.html
48+
49+
# Clean up VNC lock files in case they exist
50+
rm -rf /tmp/.X*
51+
52+
echo ">> Starting background VNC server"
53+
printf "backendai\nbackendai\n\n" | /opt/kernel/su-exec $LOCAL_USER_ID:$LOCAL_GROUP_ID vncpasswd >/dev/null 2>&1
54+
55+
cp -R /home/matlab/.config /home/work
56+
chown -R $LOCAL_USER_ID:$LOCAL_GROUP_ID /home/work/.config
57+
cp -R /home/matlab/Documents /home/work
58+
chown -R $LOCAL_USER_ID:$LOCAL_GROUP_ID /home/work/Documents
59+
mkdir -p /home/work/.vnc
60+
cp /home/matlab/.vnc/xstartup /home/work/.vnc/xstartup
61+
/opt/kernel/su-exec $LOCAL_USER_ID:$LOCAL_GROUP_ID /usr/bin/vncserver -geometry 1600x1200
62+
cat >/home/work/.xscreensaver <<EOF
63+
mode: off
64+
EOF
65+
66+
echo ">> VNC server is started."
67+
68+
# The next line will be executed by the kernel runner's service def.
69+
# "$SUEXEC" /opt/noVNC/utils/launch.sh --listen 6080 --vnc localhost:5901 > /dev/null 2>&1 &

vendor/ngc-matlab/bootstrap.r2022b.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#! /bin/sh
2+
# Reference: /bin/run.sh
3+
set -e
4+
5+
echo ">> Setting up MATLAB environment"
6+
echo ""
7+
echo "# == Matlab" >> ~/.bashrc
8+
export USAGE=cloud && echo "export USAGE=cloud" >> ~/.bashrc
9+
export VARIANTmatlab=matlabLNU && echo "export VARIANTmatlab=matlabLNU" >> ~/.bashrc
10+
export SILENT=false && echo "export SILENT=false" >> ~/.bashrc
11+
12+
SHM_SIZE=$( df -P | grep shm | sed -n -e 's/^\w*\s*\([0-9]*\)\s.*/\1/p' )
13+
if [ -z "$SILENT" ] && [ -n "$SHM_SIZE" ] ; then
14+
# Check it is big enough
15+
if [ ${SHM_SIZE} -le 524200 ] ; then
16+
echo
17+
echo "WARNING:"
18+
echo
19+
echo "This container has a shared area (/dev/shm) of size ${SHM_SIZE}kB. The MATLAB "
20+
echo "desktop requires at least 512MB to run correctly. Restart the session with "
21+
echo "512M of the shared memory."
22+
echo
23+
fi
24+
fi
25+
26+
# Create a desktop launcher
27+
mkdir -p /home/work/Desktop
28+
cat >/home/work/Desktop/MATLAB.desktop <<EOF
29+
[Desktop Entry]
30+
Version=1.0
31+
Type=Application
32+
Name=MATLAB R2022b
33+
Comment=
34+
Exec=/opt/matlab/R2022b/bin/matlab
35+
Icon=/opt/matlab/R2022b/bin/glnxa64/cef_resources/matlab_icon.png
36+
Path=
37+
Terminal=true
38+
StartupNotify=false
39+
Path=/home/matlab/Documents/MATLAB
40+
EOF
41+
chmod +x /home/work/Desktop/MATLAB.desktop
42+
43+
# Make browser VNC auto connect
44+
echo ">> Setting up noVNC auto-connection"
45+
rm /opt/noVNC/index.html
46+
ln -s /opt/noVNC/redirect.html /opt/noVNC/index.html
47+
sed -i 's/password=matlab/password=backendai/' /opt/noVNC/index.html
48+
49+
# Clean up VNC lock files in case they exist
50+
rm -rf /tmp/.X*
51+
52+
echo ">> Starting background VNC server"
53+
printf "backendai\nbackendai\n\n" | /opt/kernel/su-exec $LOCAL_USER_ID:$LOCAL_GROUP_ID vncpasswd >/dev/null 2>&1
54+
55+
cp -R /home/matlab/.config /home/work
56+
chown -R $LOCAL_USER_ID:$LOCAL_GROUP_ID /home/work/.config
57+
cp -R /home/matlab/Documents /home/work
58+
chown -R $LOCAL_USER_ID:$LOCAL_GROUP_ID /home/work/Documents
59+
mkdir -p /home/work/.vnc
60+
cp /home/matlab/.vnc/xstartup /home/work/.vnc/xstartup
61+
/opt/kernel/su-exec $LOCAL_USER_ID:$LOCAL_GROUP_ID /usr/bin/vncserver -geometry 1600x1200
62+
cat >/home/work/.xscreensaver <<EOF
63+
mode: off
64+
EOF
65+
66+
echo ">> VNC server is started."
67+
68+
# The next line will be executed by the kernel runner's service def.
69+
# "$SUEXEC" /opt/noVNC/utils/launch.sh --listen 6080 --vnc localhost:5901 > /dev/null 2>&1 &

vendor/ngc-matlab/vnc-web.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"command": [
3+
"/opt/noVNC/utils/launch.sh",
4+
"--vnc", "localhost:5901",
5+
"--listen", "{ports[0]}"
6+
],
7+
"url_template": "{protocol}://{host}:{port}/vnc.html?host=localhost&port=6080&password=backendai&autoconnect=true"
8+
}

0 commit comments

Comments
 (0)