刚从 win 转 arch,这两天搞 nvidia 的桌面环境给我整麻了,一直黑屏没法操作。其实我装过成功过一次,但网上的各种配置说一道二的,很杂乱,根本记不住哪些设置了,哪些没设置,搞得第二次安装的时候心里也没啥谱。
结果居然是偶然在 bing 上找到的答案,google 上相同的关键字反而没有那文章,还是不能小瞧你啊,bing。
首先安装自己的显卡驱动(这个网上大部分都没啥问题)。
然后根据参考链接中的内容设置自己的配置。
希望能帮助到一部分不知道如何设置的新手朋友。
离线
感谢楼主的分享,我总结后编写了一键配置脚本,方便以后的朋友使用:
#!/bin/bash
# 定义要写入 /etc/environment 的变量
nvidia_variables=(
"GBM_BACKEND=nvidia-drm"
"__GLX_VENDOR_LIBRARY_NAME=nvidia"
"ENABLE_VKBASALT=1"
"LIBVA_DRIVER_NAME=nvidia"
)
backup_file() {
local file=$1
sudo cp "$file" "$file.bak"
}
update_environment() {
local env_file="/etc/environment"
backup_file "$env_file"
for var in "${nvidia_variables[@]}"; do
if grep -q "^${var%%=*}" "$env_file"; then
sudo sed -i "s|^${var%%=*}.*|$var|" "$env_file"
else
echo "$var" | sudo tee -a "$env_file" > /dev/null
fi
done
echo "NVIDIA-specific options have been written to $env_file."
}
update_mkinitcpio_conf() {
local mkinitcpio_conf="/etc/mkinitcpio.conf"
backup_file "$mkinitcpio_conf"
sudo sed -i '/^MODULES=/ s/(\(.*\))/(\1 nvidia nvidia_modeset nvidia_uvm nvidia_drm)/' "$mkinitcpio_conf"
sudo sed -i '/^HOOKS=/ s/\(\s*kms\s*\)//g' "$mkinitcpio_conf"
echo "mkinitcpio.conf has been updated."
}
create_nvidia_conf() {
local nvidia_conf="/etc/modprobe.d/nvidia.conf"
sudo bash -c "cat > $nvidia_conf" <<EOL
blacklist nouveau
options nvidia_drm modeset=1 fbdev=1
EOL
echo "$nvidia_conf has been created."
}
regenerate_initramfs() {
sudo mkinitcpio -P
echo "initramfs has been regenerated."
}
create_nvidia_hook() {
local hook_dir="/etc/pacman.d/hooks"
local hook_file="$hook_dir/nvidia.hook"
sudo mkdir -p "$hook_dir"
sudo bash -c "cat > $hook_file" <<EOL
[Trigger]
Operation=Install
Operation=Upgrade
Operation=Remove
Type=Package
Target=nvidia
Target=linux
# Adjust line(6) above to match your driver, e.g. Target=nvidia-470xx-dkms
# Change line(7) above, if you are not using the regular kernel For example, Target=linux-lts
[Action]
Description=Update Nvidia module in initcpio
Depends=mkinitcpio
When=PostTransaction
NeedsTargets
Exec=/bin/sh -c 'while read -r trg; do case \$trg in linux) exit 0; esac; done; /usr/bin/mkinitcpio -P'
EOL
echo "nvidia.hook has been added to $hook_dir."
}
main() {
update_environment
update_mkinitcpio_conf
create_nvidia_conf
regenerate_initramfs
create_nvidia_hook
}
main
如果有兴趣,在我写的Arch 下 Walyland 使用 Nvidia 私有驱动有详细的手动步骤与参考
离线
请问Chrome动画什么的有无问题?我之前配置的一直不对,其他环境都很好,唯独plasma,Chrome放大缩小一直要卡死
感谢楼主的分享,我总结后编写了一键配置脚本,方便以后的朋友使用:
#!/bin/bash # 定义要写入 /etc/environment 的变量 nvidia_variables=( "GBM_BACKEND=nvidia-drm" "__GLX_VENDOR_LIBRARY_NAME=nvidia" "ENABLE_VKBASALT=1" "LIBVA_DRIVER_NAME=nvidia" ) backup_file() { local file=$1 sudo cp "$file" "$file.bak" } update_environment() { local env_file="/etc/environment" backup_file "$env_file" for var in "${nvidia_variables[@]}"; do if grep -q "^${var%%=*}" "$env_file"; then sudo sed -i "s|^${var%%=*}.*|$var|" "$env_file" else echo "$var" | sudo tee -a "$env_file" > /dev/null fi done echo "NVIDIA-specific options have been written to $env_file." } update_mkinitcpio_conf() { local mkinitcpio_conf="/etc/mkinitcpio.conf" backup_file "$mkinitcpio_conf" sudo sed -i '/^MODULES=/ s/(\(.*\))/(\1 nvidia nvidia_modeset nvidia_uvm nvidia_drm)/' "$mkinitcpio_conf" sudo sed -i '/^HOOKS=/ s/\(\s*kms\s*\)//g' "$mkinitcpio_conf" echo "mkinitcpio.conf has been updated." } create_nvidia_conf() { local nvidia_conf="/etc/modprobe.d/nvidia.conf" sudo bash -c "cat > $nvidia_conf" <<EOL blacklist nouveau options nvidia_drm modeset=1 fbdev=1 EOL echo "$nvidia_conf has been created." } regenerate_initramfs() { sudo mkinitcpio -P echo "initramfs has been regenerated." } create_nvidia_hook() { local hook_dir="/etc/pacman.d/hooks" local hook_file="$hook_dir/nvidia.hook" sudo mkdir -p "$hook_dir" sudo bash -c "cat > $hook_file" <<EOL [Trigger] Operation=Install Operation=Upgrade Operation=Remove Type=Package Target=nvidia Target=linux # Adjust line(6) above to match your driver, e.g. Target=nvidia-470xx-dkms # Change line(7) above, if you are not using the regular kernel For example, Target=linux-lts [Action] Description=Update Nvidia module in initcpio Depends=mkinitcpio When=PostTransaction NeedsTargets Exec=/bin/sh -c 'while read -r trg; do case \$trg in linux) exit 0; esac; done; /usr/bin/mkinitcpio -P' EOL echo "nvidia.hook has been added to $hook_dir." } main() { update_environment update_mkinitcpio_conf create_nvidia_conf regenerate_initramfs create_nvidia_hook } main
如果有兴趣,在我写的Arch 下 Walyland 使用 Nvidia 私有驱动有详细的手动步骤与参考
Never stop
离线
intel+nvidia的混合显卡怎么搞?
风吹又日晒,自由又自在
离线
intel+nvidia的混合显卡怎么搞?
intel+nvidia混合显卡如果采用nvidia-prime方案(日常使用intel显卡,手动调用nvidia显卡),那么不需要什么额外配置,根据archwiki正常安装驱动即可。因为包括桌面环境在内的大多数渲染工作都由intel显卡负责。
离线
firefox怎么调用nvidia显卡?
风吹又日晒,自由又自在
离线
firefox怎么调用nvidia显卡?
理论上可以通过prime-run firefox实现。
然而firefox似乎有bug,我看到不少报告称firefox无法在nvidia-prime下调用nvidia独显。如果prime-run firefox无效,那你可能必须放弃PRIME,将nvidia作为主显卡。
离线
There has a thing.
My friend sees a thing about Hyprland.
at config of Hyprland.
if write env=__GLX_VENDOR_LIBRARY_NAME,nvidia
then you can't load your Hyprland Desktop
i am a noob
离线