Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: Charlie Drage <[email protected]>
  • Loading branch information
cdrage committed Aug 15, 2024
1 parent ba28fb9 commit 0071257
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Type=oneshot
ExecStart=-/usr/bin/mkdir -p /etc/cdi
ExecStart=/bin/bash -c '/usr/bin/nvidia-ctk cdi generate > /etc/cdi/nvidia.yaml'
RemainAfterExit=yes
TimeoutStartSec=300

[Install]
WantedBy=basic.target
71 changes: 71 additions & 0 deletions vulkan-mac-silicon-gpu-helloworld/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# **Description:**
#
# This is a "hello world" GPU container that showcases
# how we can use the Mac Silicon GPU within a container.
#
# You must use Podman Desktop with Podman 5.2.0 or above and run a
# podman machine with libkrun support.
#
# For a more technical TLDR it is:
# * Creates a virtualized Vulkan GPU interface
# * Virtualized GPU is passed to a vulkan-to-metal layer on the host MacOS
# * Uses https://github.com/containers/libkrun for all of this to work.
#
# Source code:
# In order for this to work, a patched version of mesa / vulkan
#
# **Running:**
#
# ```sh
# podman run -d \
# -p 8080:8080 \
# --name rickroll \
# ghcr.io/cdrage/rickroll
# ```

FROM fedora:40
USER 0
RUN dnf -y install dnf-plugins-core && \
dnf -y copr enable slp/mesa-krunkit && \
dnf -y install mesa-vulkan-drivers vulkan-loader-devel vulkan-headers vulkan-loader vulkan-tools && \
dnf clean all

# Install necessary packages including X11, VNC server, noVNC, and Vulkan tools
RUN dnf -y install dnf-plugins-core xorg-x11-server-Xvfb tigervnc-server \
novnc vulkan-headers vulkan-loader vulkan-tools && \
dnf -y copr enable slp/mesa-krunkit && \
dnf clean all

# Set up a VNC password
#RUN mkdir -p ~/.vnc && \
#echo "password" | vncpasswd -f > ~/.vnc/passwd && \
#chmod 600 ~/.vnc/passwd


RUN dnf install git -y

RUN dnf install procps -y
# Clone and set up noVNC
RUN git clone https://github.com/novnc/noVNC.git /opt/noVNC && \
git clone https://github.com/novnc/websockify /opt/noVNC/utils/websockify && \
ln -s /opt/noVNC/utils/novnc_proxy /usr/local/bin/novnc_proxy

# Create a symlink in the noVNC directory to server index by default
RUN ln -s /opt/noVNC/vnc.html /opt/noVNC/index.html

# Expose the noVNC port
EXPOSE 6080 5900 80

# Start VNC server using systemd
#RUN systemctl enable vncserver@:1.service

RUN dnf install hostname -y

# Copy the startup script into the container
COPY startup.sh /usr/local/bin/startup.sh

# Make the script executable
RUN chmod +x /usr/local/bin/startup.sh

# Set the default command to start everything
CMD ["/usr/local/bin/startup.sh"]
22 changes: 22 additions & 0 deletions vulkan-mac-silicon-gpu-helloworld/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# Start Xvfb
#Xvfb :0 -screen 0 1024x768x24 -nolisten tcp &

#sleep 2

# Set DISPLAY environment variable
export DISPLAY=:1

# Start VNC server with no password
vncserver :1 -geometry 1024x768 -localhost -SecurityTypes None &
sleep 1
#/usr/share/novnc/utils/novnc_proxy --vnc localhost:5901 &> /var/log/novnc.log &
/usr/local/bin/novnc_proxy --vnc localhost:5901 --listen 6080 &

nginx

export VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.aarch64.json

sleep 5
vkcube

0 comments on commit 0071257

Please sign in to comment.