This commit is contained in:
MacRimi 2025-03-04 17:37:46 +01:00
parent ff5784d2ed
commit 98951475cb
3 changed files with 69 additions and 68 deletions

View File

@ -41,7 +41,7 @@ select_container() {
fi fi
CONTAINER_ID=$(whiptail --title "$(translate 'Select Container')" \ CONTAINER_ID=$(whiptail --title "$(translate 'Select Container')" \
--menu "$(translate 'Select the LXC container:')" 15 60 5 $CONTAINERS 3>&1 1>&2 2>&3) --menu "$(translate 'Select the LXC container:')" 15 60 8 $CONTAINERS 3>&1 1>&2 2>&3)
if [ -z "$CONTAINER_ID" ]; then if [ -z "$CONTAINER_ID" ]; then
msg_error "$(translate 'No container selected. Exiting.')" msg_error "$(translate 'No container selected. Exiting.')"
@ -95,6 +95,15 @@ configure_lxc_for_igpu() {
msg_ok "$(translate 'Container changed to privileged.')" msg_ok "$(translate 'Container changed to privileged.')"
fi fi
if grep -q "^lxc.apparmor.profile" "$CONFIG_FILE"; then
msg_info "$(translate 'Disabling AppArmor profile to avoid conflicts...')"
sed -i "/^lxc.apparmor.profile/d" "$CONFIG_FILE"
msg_ok "$(translate 'AppArmor profile removed.')"
fi
# Configure iGPU # Configure iGPU
if ! grep -q "features: nesting=1" "$CONFIG_FILE"; then if ! grep -q "features: nesting=1" "$CONFIG_FILE"; then
echo "features: nesting=1" >> "$CONFIG_FILE" echo "features: nesting=1" >> "$CONFIG_FILE"
@ -128,12 +137,12 @@ install_igpu_in_container() {
tput sc tput sc
LOG_FILE=$(mktemp) LOG_FILE=$(mktemp)
pct start "$CONTAINER_ID" msg_info "$(translate 'Installing iGPU drivers...')"
pct start "$CONTAINER_ID" >/dev/null 2>&1
script -q -c "pct exec \"$CONTAINER_ID\" -- bash -c ' script -q -c "pct exec \"$CONTAINER_ID\" -- bash -c '
set -e set -e
echo \"- Updating package lists...\" apt-get update >/dev/null 2>&1
apt-get update
echo \"- Installing iGPU drivers...\"
apt-get install -y va-driver-all ocl-icd-libopencl1 intel-opencl-icd vainfo intel-gpu-tools apt-get install -y va-driver-all ocl-icd-libopencl1 intel-opencl-icd vainfo intel-gpu-tools
chgrp video /dev/dri && chmod 755 /dev/dri chgrp video /dev/dri && chmod 755 /dev/dri
adduser root video && adduser root render adduser root video && adduser root render
@ -161,5 +170,5 @@ configure_lxc_for_igpu
install_igpu_in_container install_igpu_in_container
msg_ok "$(translate 'iGPU configuration completed in container') $CONTAINER_ID." msg_success "$(translate 'iGPU configuration completed in container') $CONTAINER_ID."
sleep 2 sleep 2

View File

@ -1,87 +1,83 @@
import type { Metadata } from "next" "use client"
import { Steps } from "@/components/ui/steps"
export const metadata: Metadata = { import { Steps } from "@/components/ui/steps"
title: "Coral TPU to an LXC | ProxMenux Documentation", import CopyableCode from "@/components/CopyableCode"
description: "Learn how to add Coral TPU support to an LXC container in Proxmox VE.", import Image from "next/image"
export const metadata = {
title: "Enable Coral TPU in LXC | ProxMenux Documentation",
description: "Step-by-step guide to enable Google Coral TPU support in an LXC container using ProxMenux.",
} }
export default function CoralTPULXC() { export default function CoralTPULXC() {
return ( return (
<div className="max-w-3xl mx-auto"> <div className="max-w-3xl mx-auto">
<h1 className="text-3xl font-bold mb-6">Coral TPU to an LXC</h1> <h1 className="text-3xl font-bold mb-6">Enable Coral TPU in an LXC</h1>
<p className="mb-4"> <p className="mb-4">
This script automates the process of adding Google Coral TPU (Tensor Processing Unit) support to LXC containers This guide explains how to configure Google Coral TPU support for LXC containers in Proxmox VE using <strong>ProxMenux</strong>.
in Proxmox VE. It configures containers to leverage the power of Coral TPU for AI and machine learning tasks, Coral TPU provides dedicated AI acceleration, improving inference performance for machine learning applications.
significantly accelerating inference operations.
</p> </p>
<h2 className="text-2xl font-semibold mt-8 mb-4">What Does This Script Do?</h2> <h2 className="text-2xl font-semibold mt-8 mb-4">Overview</h2>
<p className="mb-4">When executed, this script performs the following actions:</p> <p className="mb-4">The script automates the following steps:</p>
<ol className="list-decimal pl-6 space-y-2 mb-6"> <ol className="list-decimal pl-6 space-y-2 mb-6">
<li>Presents a list of available LXC containers for selection</li> <li>Allows selection of an existing LXC container.</li>
<li>Configures the selected container to support both Coral TPU and Intel iGPU</li> <li>Ensures the container is privileged for hardware access.</li>
<li>Installs necessary drivers and tools inside the container</li> <li>Configures LXC parameters for Coral TPU and Intel iGPU.</li>
<li>Sets up proper permissions and mounts for hardware access</li> <li>Installs required drivers and dependencies inside the container.</li>
</ol> </ol>
<h2 className="text-2xl font-semibold mt-8 mb-4">Key Steps</h2> <h2 className="text-2xl font-semibold mt-8 mb-4">Implementation Steps</h2>
<Steps> <Steps>
<Steps.Step title="Container Selection"> <Steps.Step title="Select an LXC Container">
<p>You'll be prompted to select the LXC container you want to enable Coral TPU support for.</p> <p>The script lists available LXC containers and prompts for selection.</p>
</Steps.Step> </Steps.Step>
<Steps.Step title="Container Configuration"> <Steps.Step title="Modify Container Configuration">
<p>The script modifies the container's configuration to allow Coral TPU and iGPU access. This includes:</p> <p>The script applies necessary changes to enable Coral TPU:</p>
<ul className="list-disc pl-6 space-y-1 mt-2"> <ul className="list-disc pl-6 space-y-1 mt-2">
<li>Ensuring the container is privileged (for necessary permissions)</li> <li>Switches the container to privileged mode if required.</li>
<li>Enabling nesting feature</li> <li>Enables nesting to allow GPU and TPU usage.</li>
<li>Adding device permissions for TPU and GPU access</li> <li>Sets device permissions for TPU and iGPU.</li>
<li>Setting up proper mounts for TPU and GPU devices</li> <li>Configures proper device mounts.</li>
</ul> </ul>
</Steps.Step> </Steps.Step>
<Steps.Step title="Driver Installation"> <Steps.Step title="Install Required Drivers">
<p>Inside the container, the script installs required packages:</p> <p>The script installs the necessary components inside the container:</p>
<ul className="list-disc pl-6 space-y-1 mt-2"> <ul className="list-disc pl-6 space-y-1 mt-2">
<li>GPU drivers (va-driver-all, intel-opencl-icd)</li> <li>GPU drivers (va-driver-all, intel-opencl-icd).</li>
<li>Coral TPU dependencies and drivers</li> <li>Coral TPU dependencies (Python, GPG keys, repository setup).</li>
<li>Python and necessary libraries</li> <li>Coral TPU drivers (USB and M.2 support).</li>
</ul> </ul>
</Steps.Step> </Steps.Step>
<Steps.Step title="Coral TPU Driver Selection"> <Steps.Step title="Select Coral TPU Driver Version">
<p> <p>If a Coral M.2 device is detected, the script prompts the user to select:</p>
If a Coral M.2 device is detected, you'll be prompted to choose between standard and maximum performance <ul className="list-disc pl-6 space-y-1 mt-2">
drivers. <li><strong>Standard mode</strong> - balanced performance.</li>
</p> <li><strong>Maximum performance mode</strong> - higher speed, increased power usage.</li>
</ul>
</Steps.Step> </Steps.Step>
</Steps> </Steps>
<h2 className="text-2xl font-semibold mt-8 mb-4">What to Expect</h2> <h2 className="text-2xl font-semibold mt-8 mb-4">Expected Results</h2>
<ul className="list-disc pl-6 space-y-2 mb-6"> <ul className="list-disc pl-6 space-y-2 mb-6">
<li>The script will guide you through the process with clear prompts.</li> <li>The selected container is correctly configured for TPU and iGPU usage.</li>
<li>Your selected container will be stopped briefly during configuration.</li> <li>Required drivers and dependencies are installed inside the container.</li>
<li>The entire process usually takes a few minutes to complete.</li> <li>The container will restart as needed during the process.</li>
<li>After completion, your container will be ready to use both Coral TPU and the host's iGPU.</li> <li>After completion, applications inside the container can utilize Coral TPU acceleration.</li>
</ul> </ul>
<h2 className="text-2xl font-semibold mt-8 mb-4">Important Notes</h2> <h2 className="text-2xl font-semibold mt-8 mb-4">Important Considerations</h2>
<ul className="list-disc pl-6 space-y-2 mb-6"> <ul className="list-disc pl-6 space-y-2 mb-6">
<li>This script supports both USB and M.2 versions of Coral TPU.</li> <li>The script supports both USB and M.2 Coral TPU devices.</li>
<li>The container will be changed to privileged mode if it wasn't already.</li> <li>The container must be privileged to access TPU hardware.</li>
<li>Ensure your Proxmox host has the necessary Coral TPU and Intel GPU drivers installed.</li> <li>The Proxmox host must have the required Coral TPU and Intel GPU drivers installed.</li>
<li> <li>Additional application-specific configurations may be required inside the container.</li>
For M.2 Coral TPUs, you can choose between standard and maximum performance modes. The maximum performance
mode may generate more heat.
</li>
<li>Some applications inside the container may require additional setup to utilize the Coral TPU.</li>
</ul> </ul>
<p className="mt-6 italic"> <p className="mt-6 italic">
This script simplifies the process of enabling Coral TPU and iGPU acceleration in your LXC containers without By using ProxMenux, Coral TPU and iGPU support can be enabled in LXC containers efficiently, avoiding manual configuration steps.
the need for manual configuration file editing or running complex commands. This setup is ideal for AI and
machine learning workloads that can benefit from hardware acceleration.
</p> </p>
</div> </div>
) )
} }

View File

@ -65,13 +65,9 @@ export default function IGPUAccelerationLXC() {
<h2 className="text-2xl font-semibold mt-8 mb-4">Important Notes</h2> <h2 className="text-2xl font-semibold mt-8 mb-4">Important Notes</h2>
<ul className="list-disc pl-6 space-y-2 mb-6"> <ul className="list-disc pl-6 space-y-2 mb-6">
<li>This script is designed specifically for Intel iGPUs.</li> <li>This script is designed specifically for Intel iGPUs.</li>
<li>Make sure your Proxmox host has Intel GPU drivers installed.</li>
<li>Some applications inside the container may need additional setup to use the GPU.</li> <li>Some applications inside the container may need additional setup to use the GPU.</li>
</ul> </ul>
<p className="mt-6 italic">
By using ProxMenux, you can enable iGPU acceleration in your LXC containers easily, without manual configuration.
</p>
</div> </div>
) )
} }