https://cloud.google.com/compute/docs/gpus/install-drivers-gpu?hl=zh-cn
一.将 GPU 用于远程桌面上的硬件加速图形或用于游戏
apt install -y build-essential
yum group install "Development Tools"
--安装 Linux 内核标头
-- RHEL 9
dnf install kernel-devel-$(uname -r) kernel-headers-$(uname -r)
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
subscription-manager repos --enable=rhel-9-for-x86_64-appstream-rpms
subscription-manager repos --enable=rhel-9-for-x86_64-baseos-rpms
subscription-manager repos --enable=codeready-builder-for-rhel-9-x86_64-rpms
dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/$distro/$arch/cuda-$distro.repo
dnf clean expire-cache
dnf module install nvidia-driver:latest-dkms
dnf install cuda-toolkit
dnf install nvidia-gds
--
curl -O https://storage.googleapis.com/nvidia-drivers-us-public/GRID/vGPU17.0/NVIDIA-Linux-x86_64-550.54.14-grid.run
NVIDIA-Linux-x86_64-550.54.14-grid.run
-如果系统提示您安装 32 位二进制文件,请选择是。
-如果系统提示您修改 x.org 文件,请选择否。
--验证是否已安装驱动程序
nvidia-smi
二.使用安装脚本安装 GPU 驱动程序
curl https://raw.githubusercontent.com/GoogleCloudPlatform/compute-gpu-installation/main/linux/install_gpu_driver.py --output install_gpu_driver.py
python3 install_gpu_driver.py
三.安装 GPU 驱动程序(安全启动虚拟机)
NVIDIA_DRIVER_VERSION=$(sudo apt-cache search 'linux-modules-nvidia-[0-9]+-gcp$' | awk '{print $1}' | sort | tail -n 1 | head -n 1 | awk -F"-" '{print $4}')
apt install linux-modules-nvidia-${NVIDIA_DRIVER_VERSION}-gcp nvidia-driver-${NVIDIA_DRIVER_VERSION}
apt install software-properties-common
-对于 Ubuntu 22.04,请运行以下命令:
export UBUNTU_VERSION=ubuntu2204/x86_64
wget https://developer.download.nvidia.com/compute/cuda/repos/$UBUNTU_VERSION/cuda-keyring_1.0-1_all.deb
dpkg -i cuda-keyring_1.0-1_all.deb
add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/$UBUNTU_VERSION/ /"
-找到兼容的 CUDA 驱动程序版本
CUDA_DRIVER_VERSION=$(apt-cache madison cuda-drivers | awk '{print $3}' | sort -r | while read line; do
if dpkg --compare-versions $(dpkg-query -f='${Version}\n' -W nvidia-driver-${NVIDIA_DRIVER_VERSION}) ge $line ; then
echo "$line"
break
fi
done)-使用上一步中识别的版本安装 CUDA 驱动程序
apt install cuda-drivers-${NVIDIA_DRIVER_VERSION}=${CUDA_DRIVER_VERSION} cuda-drivers=${CUDA_DRIVER_VERSION}
-
apt-get remove dkms && sudo apt-mark hold dkms
-确定与我们刚刚安装的 CUDA 驱动程序兼容的最新 CUDA 版本
CUDA_VERSION=$(apt-cache showpkg cuda-drivers | grep -o 'cuda-runtime-[0-9][0-9]-[0-9],cuda-drivers [0-9\\.]*' | while read line; do
if dpkg --compare-versions ${CUDA_DRIVER_VERSION} ge $(echo $line | grep -Eo '[[:digit:]]+\.[[:digit:]]+') ; then
echo $(echo $line | grep -Eo '[[:digit:]]+-[[:digit:]]')
break
fi
done)apt install cuda-${CUDA_VERSION}
-验证 CUDA 安装
nvidia-smi
/usr/local/cuda/bin/nvcc --version
---
一、安装前的准备
1)在电脑重启中进入电脑的BIOS设置,在设置中将“Above 4G decoding”设置为启动,以便系统可以识别到显卡。
2) 禁用Ubuntu自带的nouveau驱动。
gedit /etc/modprobe.d/blacklist-nouveau.conf
然后输入以下两行:
blacklist nouveau
options nouveau modset=0
3)配置文件生效,在终端中输入
update-initramfs -u
4)重启系统
5)检测是否禁用nouveau成功
lsmod | grep nouveau
输入该命令后终端若无输出则表示禁用成功。
二、卸载干净之前的驱动
卸载nvidia,查看所有与nvidia有关的包
dpkg -l | grep -i nvidia
卸载包
apt-get --purge remove nvidia*
apt-get --purge remove libnvidia*
apt autoremove
三、驱动依赖安装:
apt update
apt install gcc
apt install dkms build-essential linux-headers-generic
四、正式安装驱动
1)授权驱动文件的安装权限
chmod a+x ./NVIDIA-Linux-x86_64-535.171.04.run
2)进行驱动程序的安装
./NVIDIA-Linux-x86_64-535.171.04.run --no-opengl-files --no-x-check --no-nouveau-check
3)过程中,遇见continue九点那个
4)是否安装32位兼容,否
5)是否注册新的kernel,否
6)检测安装是否成成功"
watch -n 1 nvidia-smi
如果出现显卡信息,代表安装成功
===
yum install -y kernel-devel
yum install -y dkms gcc make kernel-devel-$(uname -r)
yum install -y gcc
yum install -y mak
yum install -y elfutils-libelf-devel
yum install -y libglvnd-devel pkg-config
yum -y install gcc pciutils
lspci | grep -i vga
lspci
lspci | grep -i nvidia
vi /lib/modprobe.d/dist-blacklist.conf
# (3)将nvidiafb注释掉:
#blacklist nvidiafb
# (4)添加以下两句在blacklist.conf 文件中, :回到文件最底部,:w保存文件,:q退出文件
blacklist nouveau
options nouveau modeset=0
mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak
dracut /boot/initramfs-$(uname -r).img $(uname -r)
systemctl set-default multi-user.target
systemctl isolate multi-user.target
reboot
cd /opt
chmod -R 777 /opt/NVIDIA-Linux-x86_64-550.76.run
sh /opt/NVIDIA-Linux-x86_64-550.76.run -no-x-check -no-nouveau-check -k $(uname -r) --kernel-source-path=/usr/src/kernels/5.14.0-362.24.2.el9_3.x86_64
sh /opt/NVIDIA-Linux-x86_64-545.29.02.run -no-x-check -no-nouveau-check -no-opengl-files
1. Would you like to register the kernel module souces with DKMS? This will allow DKMS to automatically build a new module, if you install a different kernel later? 【No】
2. Nvidia’s 32-bit compatibility libraries? 【No】
3. Would you like to run the nvidia-xconfigutility to automatically update your x configuration so that the NVIDIA x driver will be used when you restart x? Any pre-existing x confile will be backed up. 【Yes】
https://developer.nvidia.com/cuda-downloads
wget https://developer.download.nvidia.com/compute/cuda/12.6.0/local_installers/cuda_12.6.0_560.28.03_linux.run
dracut --force
chmod -R 777 /opt/cuda_12.6.0_560.28.03_linux.run
sh /opt/cuda_12.6.0_560.28.03_linux.run --silent
nvidia-xconfig
yum -y install nvidia-driver-latest-dkms
yum -y install cuda
vi ~/.bashrc
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
source ~/.bashrc
-验证 CUDA 安装
nvidia-smi
/usr/local/cuda/bin/nvcc --version
===
#
docker启用GPU加速计算(显卡,gpu): https://abc.htmltoo.com/thread-46845.htm