少女祈祷中...

尝试增强游戏本续航的折腾记录.

环境:

  • Ubuntu22.04
  • 华硕天选三
  • 0000:01:00.0 VGA compatible controller: NVIDIA Corporation GA107M [GeForce RTX 3050 Mobile] (rev a1)

ubuntu查看显卡的命令

1
lspci | grep -i vga

或者(watch -n 表示每隔n秒刷新)

1
2
nvidia-smi
watch -n 2 nvidia-smi #每两秒刷新一次

或者安装

1
sudo apt install gpustat

进行查看

1
2
3
gpustat -i
gpustat -cpu
gpustat --json

查看驱动版本号

1
cat /proc/driver/nvidia/version

TLP and others

https://cloud.tencent.com/developer/article/1837446
可以参考这个文章. 里面讲了很多关于提高续航的操作, 如:

  1. 系统电源设置
  2. 关闭蓝牙
  3. 调低屏幕亮度
  4. 安装TLP.

其中, 前三个设置都是很常见的选择.

第四个方法中, TLP的安装也比较简单. 直接进行PPA安装即可. 具体过程可参考官网的手册

1
2
sudo add-apt-repository ppa:linrunner/tlp
sudo apt update

tlp一般是开机自启动的, 不需要额外的设置. 之后通过

1
tlp-stat -s

来查看相关的信息.

更多操作可参考tlp的官方文档
https://linrunner.de/tlp/usage/index.html

可参考这篇文章来完成对TLP的进一步配置 (其实原本的配置已经很不错了. )

https://www.meow-2.com/posts/linux/tlp-for-power-saving


bumblebee / bbswitch

之后尝试禁用笔记本上的独显, 让它在平时不要那么耗电.

在网上找了找, 找到的是基于bumblebee的解决方案比较省事.

但是后来发现bb在Ubuntu22.04上好像是没有对应版本的, 所以安装会报Error. 最后还是卸掉了. 但是过程还是放在这里. 大家自行参考.

BB的官方文档
https://wiki.ubuntu.com/Bumblebee

里面有相关的安装方法.

也可以按照下面的步骤安装

1
sudo add-apt-repository ppa:bumblebee/stable

会报一个这个提示.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
To report issues, please read http://wiki.Bumblebee-Project.org/Reporting-Issues

You may use any nvidia driver flavor, like -updates, -experimental or -nnn ones.

After installation, reboot to let changes apply.

To see if it works, run during around 30s: glxspheres
Then, run it with optirun, and compare: optirun glxspheres

If you want to use primus, you need to install it and set Bridge=primus in bumblebee.conf or use optirun -b primus. You also need to install primus-libs-ia32 if you want to run 32-bit apps.

Be aware that as Bumblebee is using low-level hardware informations, it is impossible to run it in a VM.
More info: https://launchpad.net/~bumblebee/+archive/ubuntu/stable
Adding repository.
Press [ENTER] to continue or Ctrl-c to cancel.

正常Enter. 然后会在终端里出现一个图形化界面和一些说明. 此时按ctrl + 下键(PGDN), 进行下一步操作. 之后就可以正常进入下一步设定密码的流程了.

参考:
关于BB运行PPA命令时, 出现一个图形化界面然后卡住的问题:
https://askubuntu.com/questions/1063282/stuck-in-terminal-at-configuring-secure-boot

之后再

1
2
sudo apt-get update
sudo apt-get install bumblebee bumblebee-nvidia primus linux-headers-generic

然后再重启电脑即可.

要注意的是Enable the [Universe and Multiverse](https://help.ubuntu.com/community/Repositories/Ubuntu) repositories in order to allow the bumblebee and nvidia packages to be installed
即, 我们需要在设置里操作一下, 允许类型为Universe and Multiverse的软件源进行安装. (这些软件源不那么官方, 所以从这里进行安装需要确认. )

后面发现希望基于bbswitch禁用独显的方案是用不了的.

基于 bbswitch 的解决方案: 不可用. 没有对应的版本
https://www.joxrays.com/linux-ban-nvidia/
https://forum.ubuntu.org.cn/viewtopic.php?t=370156
https://www.cnblogs.com/lijihong/p/3628628.html


其他一些尝试

BB好像用不了.
https://askubuntu.com/questions/866901/what-can-i-do-if-a-repository-ppa-does-not-have-a-release-file

按照这个方法尝试禁用了3050. 发现只能管用一会.
https://cloud.tencent.com/developer/article/2046885

方法流程如下:

  1. 安装NVIDIA PRIME:
1
sudo apt install nvidia-prime
  1. 切换至独显模式:
1
sudo prime-select nvidia

然后等待切换,提示Done的时候i即代表切换完成,然后重启系统即可

  1. 如果未来想要切换到集显模式,也可以使用:
1
sudo prime-select intel

照做之后, 发现确实切成了核显, 但是调节不了亮度了, 基于的图像引擎也不再是X11, 需要重新切回来.

为了搞回来亮度, 试着设置了TLP, 发现不是TLP的问题.

折腾了老半天. 猜测可能是核显的驱动有问题导致了亮度无法调节. 尝试安装核显的驱动, 到处查找, 找了很久都没有找到不错的方法. (最后发现把设备型号搞错了, 把音频文件当成显卡了. )

于是重新运行命令行, 将独显启用了. 于是一切问题都解决了. 但是耗电问题没法解决.

(再次研究了一会, 发现实际上是Ubuntu识别不了电脑上的集成显卡. 在BIOS中可以看到显卡的型号, 但是在禁用了Nvidia卡之后, 电脑运行的显卡就显示为llvmpipe (LLVM 15.0.7, 256 bits), 说明Ubuntu根本没有识别到集成显卡, 而是当成没有显卡的情况在处理. )

(所以禁用独显其实是个伪命题, 如果我没有找到能够让集成显卡发挥作用的方法的话. 总之先放在这里吧. 有时间再继续折腾. )

总结

总之现在先试试但用TLP和其他工具, 不禁用独显的耗电情况, 再考虑其他的事情吧.

如果之后想要继续折腾, 下面是一些相关的信息, 也许可以尝试这些方法

https://askubuntu.com/questions/1242866/cannot-turn-off-nvidia-gpu-using-bbswitch

https://www.cnblogs.com/tonyc/p/9561926.html

https://www.cnblogs.com/ggaaooppeennngg/p/3652650.html

感觉折腾这个东西真是没事找事. 有钱了买个MacBook 😄 .

参考文章

https://cloud.tencent.com/developer/article/1837446
https://linrunner.de/tlp/usage/index.html
https://www.meow-2.com/posts/linux/tlp-for-power-saving
https://wiki.ubuntu.com/Bumblebee
https://askubuntu.com/questions/1063282/stuck-in-terminal-at-configuring-secure-boot
https://www.joxrays.com/linux-ban-nvidia/
https://forum.ubuntu.org.cn/viewtopic.php?t=370156
https://www.cnblogs.com/lijihong/p/3628628.html
https://askubuntu.com/questions/866901/what-can-i-do-if-a-repository-ppa-does-not-have-a-release-file
https://cloud.tencent.com/developer/article/2046885
https://askubuntu.com/questions/1242866/cannot-turn-off-nvidia-gpu-using-bbswitch
https://www.cnblogs.com/tonyc/p/9561926.html
https://www.cnblogs.com/ggaaooppeennngg/p/3652650.html