全部產品
Search
文件中心

Alibaba Cloud Linux:Alibaba Cloud Linux 4 LTS 64 bit Deb Edition鏡像實踐

更新時間:Jan 10, 2026

本文介紹如何使用 Alibaba Cloud Linux 4 LTS 64位 Deb Edition,涵蓋 KeenTune 與 Memboost 的配置與調優方法,以實現系統效能提升;同時說明在 GPU 執行個體上安裝 GPU驅動,CUDA工具鏈及eRDMA軟體棧等關鍵組件的操作步驟。

如何使用keentune

預設安裝調優工具keentune,該工具提供了多種情境下的調優,以下介紹如何開啟調優。

開啟keentune服務

systemctl stop tuned
systemctl disable tuned
systemctl enable keentune-target
systemctl enable keentuned
systemctl start keentune-target
systemctl start keentuned

按需設定profile

keentune支援多個情境調優,可通過keentune profile list查看profile列表以及當前使用的profile,以下是keentune支援的profile列表以及描述:

Profile

說明

ai_train_ubuntu.profile

適用於AI訓練情境,效能增強效果好於cpu_ubuntu_common.profile,但是對推理情境不友好。

cpu_ubuntu_common.profile

適用於AI通用情境,對訓練和推理都有一定效能增強。

ecs-guest.profile

適用於阿里雲ECS/EGS情境,對VM有一定效能增強。

ecs-performance.profile

適用於阿里雲裸金屬/host情境,能夠對裸金屬和運行在上面的VM帶來一定效能增強。

virtual-guest.profile

繼承自tuned,適用於普通VM情境的VM內。

virtual-host.profile

繼承自tuned,適用於普通VM情境的host內。

throughput-performance.profile

繼承自tuned,適用於通用關注吞吐效能的情境。

通過keentune profile set xxx來設定profile,設定需要重啟OS生效。

關閉keentune服務

如果想關閉keentune啟用的調優,執行keentune profile rollback即可,同樣需要重啟生效。

如果需要關閉keentune,切換回tuned,請按照如下步驟執行:

systemctl stop keentuned
systemctl stop keentune-target
systemctl disable keentuned
systemctl disable keentune-target
systemctl enable tuned
systemctl start tuned

如何使用memboost

memboost,一個使用者態記憶體最佳化組件,通過可配置策略實現記憶體效能、成本與穩定性的智能平衡,助力AI與高並發情境高效運行。

memboost 的使用需同時滿足以下約束條件,缺一不可:

  • 多 NUMA 架構環境:僅適用於具有多個 NUMA 節點的伺服器;

  • Kubernetes 容器運行環境:僅支援在 Kubernetes 管理的容器情境中部署;

  • NVIDIA GPU 環境:僅適用搭載 NVIDIA GPU 的執行個體;

  • cgroup v2 :必須啟用 cgroup v2。

確保滿足上述約束條件情況下,可安裝和開啟memboost服務。

apt update && apt install memboost -y
systemctl start memboost

GPU執行個體組件安裝

本章節介紹如何安裝使用GPU相關組件。

GPU驅動安裝

以下指令碼實現使用.run安裝包方式安裝Tesla驅動和nvidia-persistenced服務。

拷貝如下內容至install_gpu.sh,執行sudo bash install_gpu.sh進行安裝。

預設安裝570.133.20版本,按需修改。

#! /bin/bash
# 安裝驅動版本 570.133.20,按需設定
export nvidia_driver_version="570.133.20"

mkdir -p /tmp/NVIDIA
download_url_prefix=$(curl http://100.100.100.200/latest/meta-data/source-address | head -1)
wget -t 100 --timeout=10 "${download_url_prefix}/opsx/ecs/linux/binary/nvidia/driver/NVIDIA-Linux-x86_64-"${nvidia_driver_version}".run" -O /tmp/NVIDIA/NVIDIA-Linux-x86_64-"${nvidia_driver_version}".run
apt update && apt install -y dkms
chmod +x /tmp/NVIDIA/NVIDIA-Linux-x86_64-"${nvidia_driver_version}".run
/tmp/NVIDIA/NVIDIA-Linux-x86_64-"${nvidia_driver_version}".run --silent
# 檢查dkms狀態
dkms status
# 查看驅動狀態
nvidia-smi

# 可選,防止GPU進入低功耗模式
# enable nvidia-persistenced.service
apt update && apt install -y bzip2
pushd /usr/share/doc/NVIDIA_GLX-1.0/sample*
bunzip2  nvidia-persistenced-init.tar.bz2
tar xvf nvidia-persistenced-init.tar -C  /usr/share/doc/NVIDIA_GLX-1.0/sample*/
bash  /usr/share/doc/NVIDIA_GLX-1.0/sample*/nvidia-persistenced-init/install.sh -u root
systemctl is-enabled nvidia-persistenced.service
popd

安裝CUDA + cuDNN

如下指令碼介紹CUDA和cuDNN安裝步驟,CUDA安裝以.run安裝包方式安裝。

  1. 拷貝如下指令碼至install_cuda.sh,按需修改CUDA版本,目前推薦使用12.8.1。

    #! /bin/bash
    
    # 設定CUDA版本
    export cuda_version="12.8.1"
    export cudafile="cuda_12.8.1_570.124.06_linux.run"
    
    download_url_prefix=$(curl http://100.100.100.200/latest/meta-data/source-address | head -1)
    
    mkdir -p /tmp/NVIDIA/
    wget -t 100 --timeout=10 "${download_url_prefix}/opsx/ecs/linux/binary/nvidia/cuda/${cuda_version}/${cudafile}" -O /tmp/NVIDIA/${cudafile}
    chmod +x /tmp/NVIDIA/${cudafile}
    /tmp/NVIDIA/${cudafile} --silent --toolkit --samples --samplespath=/root
    
    # 設定CUDA環境變數
    cat > /etc/profile.d/cuda.sh <<- 'EOF'
    export PATH=/usr/local/cuda/bin:$PATH
    export CUDA_HOME=/usr/local/cuda
    export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
    EOF
    
  2. 執行sudo bash install_cuda.sh安裝CUDA。

  3. 指令碼執行完後,退出登入重新通過ssh登入後,可以通過nvcc -V查看版本號碼,驗證安裝結果。

cuDNN安裝則是通過tar包下載解壓安裝的方式。

  1. 拷貝如下內容至install_cudnn.sh

    #! /bin/bash
    
    # 設定cuDNN 9.8.0.87
    export cudnn_version="9.8.0.87"
    export cuda_big_version="12.x"
    export cudnn_file="cudnn-linux-x86_64-9.8.0.87_cuda12-archive.tar.xz"
    
    download_url_prefix=$(curl http://100.100.100.200/latest/meta-data/source-address | head -1)
    wget -t 100 --timeout=10 "${download_url_prefix}/opsx/ecs/linux/binary/nvidia/cudnn/${cuda_big_version}/${cudnn_file}" -O /tmp/NVIDIA/${cudnn_file}
    mkdir -p /tmp/NVIDIA/cudnn
    tar xvf /tmp/NVIDIA/${cudnn_file} -C /tmp/NVIDIA/cudnn
    cp /tmp/NVIDIA/cudnn/cudnn-*-archive/include/cudnn*.h /usr/local/cuda/include
    cp -P /tmp/NVIDIA/cudnn/cudnn-*-archive/lib/libcudnn* /usr/local/cuda/lib64
    chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*
  2. 執行sudo bash install_cudnn.sh安裝,預設安裝9.8.0.87版本,按需修改。

安裝 Fabric Manager

NVIDIA Fabric Manager是一個系統服務,用於集中管理和最佳化 NVIDIA GPU 叢集中的 NVSwitch 和 NVLink 拓撲結構,實現高效能多 GPU 通訊。以下介紹如何安裝,安裝過程需要訪問公網。

  1. 拷貝如下指令碼至install_fabricmanager.sh

    #! /bin/bash
    
    # fabric manager版本要與gpu版本對應,這裡是570.133.20
    export fm_file="nvidia-fabricmanager-570_570.133.20-1_amd64.deb"
    mkdir -p /tmp/NVIDIA
    pushd /tmp/NVIDIA
    wget -t 100 --timeout=10 "https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2404/x86_64/${fm_file}"
    dpkg -i ${fm_file}
    apt-mark hold nvidia-fabricmanager-570
    
    # 預設disable,按需開啟
    systemctl disable nvidia-fabricmanager
    popd
  2. 執行sudo bash install_fabricmanager.sh安裝。

安裝版本需要與NVIDIA驅動對應。

安裝eRDMA軟體棧

如果執行個體使用eRDMA網卡,需要安裝eRDMA軟體棧。

  1. 儲存如下指令碼至install_erdma.sh

    #!/bin/bash
    
    set -e
    download_url_prefix=$(curl -s http://100.100.100.200/latest/meta-data/source-address | head -1)
    
    # 1. 安裝 ofed
    mkdir -p /tmp/NVIDIA/ofed
    apt update && apt install -y pkg-config flex make libelf-dev sudo libmnl-dev autoconf autotools-dev dh-dkms bison dh-python libdb-dev quilt automake debhelper chrpath gcc libselinux1-dev python3
    
    pushd /tmp/NVIDIA/ofed
    wget -q ${download_url_prefix}/erdma/kernel-fix/deb/MLNX_OFED_SRC-debian-24.10-2.1.8.0.tgz
    tar -xvf MLNX_OFED_SRC-debian-24.10-2.1.8.0.tgz && cd MLNX_OFED_SRC-24.10-2.1.8.0 && curl -O ${download_url_prefix}/erdma/kernel-fix/deb/ofed_debian.conf
    rm -rf SOURCES/mlnx-ofed-kernel_24.10.OFED.24.10.2.1.8.1.orig.tar.gz
    wget -q  ${download_url_prefix}/erdma/kernel-fix/deb/mlnx-ofed-kernel_24.10.egs.OFED.24.10.2.1.8.1.orig.tar.gz -O SOURCES/mlnx-ofed-kernel_24.10.egs.OFED.24.10.2.1.8.1.orig.tar.gz
    ./install.pl --distro ubuntu24.04 --config ./ofed_debian.conf --without-dkms --build-only --kernel-only
    source /etc/os-release
    /usr/bin/dpkg -i --force-confmiss DEBS/ubuntu24.04/x86_64/*.deb
    ln -s /usr/src/ofa_kernel/default /usr/src/ofa_kernel/`uname -r`
    popd
    
    # 2. 安裝 eRDMA 1.4.3
    export erdma_file="erdma_installer-1.4.3.tar.gz"
    mkdir -p /tmp/NVIDIA/erdma
    
    ADAPT_SCRIPT="/tmp/NVIDIA/erdma/adapt_alinux_deb.sh"
    
    cat > "$ADAPT_SCRIPT" << 'EOF'
    #!/bin/bash
    set -e
    INSTALL_SH="$1"
    if [ ! -f "$INSTALL_SH" ]; then
        echo "Error: $INSTALL_SH not found." >&2
        exit 1
    fi
    
    if grep -q 'if \[ "\$DISTRO" = "alinux" \] && \[ "\$DIST_VER" = "4" \]; then' "$INSTALL_SH"; then
        echo "Info: Patch already applied. Skipping."
        exit 0
    fi
    
    TMPFILE=$(mktemp)
    cat > "$TMPFILE" << 'INNER_EOF'
    			if [ "$DISTRO" = "alinux" ] && [ "$DIST_VER" = "4" ]; then
    				source /etc/os-release
    				if [[ "$VARIANT_ID" == "deb" ]]; then
    					DISTRO=$(echo "$ID_LIKE" | awk '{print $1}' | tr '[:upper:]' '[:lower:]')
    					DIST_VER="$ALINUX_MINOR_ID"
    					BIN_DIR="DEBS/${DISTRO}${ALINUX_MINOR_ID:0:2}"
    				fi
    			else
    				BIN_DIR="DEBS/$DISTRO`lsb_release -s -r | awk -F. '{print $1}'`"
    			fi
    INNER_EOF
    
    sed -e "/^[[:space:]]*BIN_DIR=DEBS\/\$DISTRO\`lsb_release -s -r | awk -F\. '{print \$1}'\`$/{
        r $TMPFILE
        d
    }" "$INSTALL_SH" > "${INSTALL_SH}.new"
    
    if [ ! -s "${INSTALL_SH}.new" ]; then
        echo "Error: Failed to generate patched file." >&2
        rm -f "${INSTALL_SH}.new" "$TMPFILE"
        exit 1
    fi
    mv "${INSTALL_SH}.new" "$INSTALL_SH"
    rm -f "$TMPFILE"
    
    echo "Successfully modify $INSTALL_SH."
    EOF
    
    pushd /tmp/NVIDIA/erdma
    rm -rf /lib/modules/`uname -r`/updates/dkms/erdma.ko
    
    curl -O ${download_url_prefix}/erdma/env_setup.sh
    sed -i '/ex tar -xvf \$TOPDIR\/erdma_install\.tar\.gz -C \$TOPDIR/a\
    bash /tmp/NVIDIA/erdma/adapt_alinux_deb.sh "$TOPDIR/erdma_installer/install.sh"' env_setup.sh
    sed -i '/^collect_system_info$/d;/^print_system_info$/d' env_setup.sh
    
    bash env_setup.sh --url "${download_url_prefix}/erdma/${erdma_file}"
    
    popd
    
    # 列印版本
    eadm ver
    
    echo "Installation completed."
    
  2. 執行sudo bash install_erdma.sh安裝。

安裝Docker CE

  1. 拷貝如下指令碼至install_docker-ce.sh

    #! /bin/bash
    
    download_url_prefix=$(curl http://100.100.100.200/latest/meta-data/source-address | head -1)
    curl -fsSL ${download_url_prefix}/docker-ce/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
    tee /etc/apt/sources.list.d/docker.sources <<EOF
    Types: deb
    URIs: ${download_url_prefix}/docker-ce/linux/ubuntu
    Suites: noble
    Components: stable
    Signed-By: /etc/apt/keyrings/docker.asc
    EOF
    
    apt update && apt install docker-ce -y
  2. 執行sudo bash install_docker-ce.sh安裝docker-ce。

安裝NVIDIA Container Toolkit

如果需要在Docker容器中使用GPU,則需要安裝nvidia-container-toolkit,安裝過程需要訪問公網。

  1. 拷貝如下指令碼至install_nvidia_toolkit.sh

    #! /bin/bash
    
    # 安裝版本1.17.8-1
    export NVIDIA_CONTAINER_TOOLKIT_VERSION=1.17.8-1
    
    cat > /etc/apt/sources.list.d/nvidia-container-toolkit.list << EOF
    deb [trusted=yes] http://mirrors.ustc.edu.cn/libnvidia-container/stable/deb/amd64 /
    EOF
    
    apt update
    apt install -y \
      nvidia-container-toolkit=${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
      nvidia-container-toolkit-base=${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
      libnvidia-container-tools=${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
      libnvidia-container1=${NVIDIA_CONTAINER_TOOLKIT_VERSION}
    rm -vf /etc/apt/sources.list.d/nvidia-container-toolkit.list
    
    # configure
    nvidia-ctk runtime configure --runtime=docker
    systemctl restart docker
  2. 執行sudo bash install_nvidia_toolkit.sh安裝。按需修改組件版本。