每次我尝试调用nvidia-smi
它时,它都要花很长时间才能显示出来;事实证明应该启用持久模式,一种简单的方法就是调用nvidia-smi -pm 1
。但这并不能启用它进行启动。
我怎样才能让它在启动时工作?我尝试运行,sudo nvidia-persistenced
但系统日志显示以下内容:
kernel: [ 949.165626] NVRM: Persistence mode is deprecated and will be removed in a future release. Please use nvidia-persistenced instead.
nvidia-persistenced: Started (1994)
nvidia-persistenced: Failed to open libnvidia-cfg.so.1: libnvidia-cfg.so.1: cannot open shared object file: No such file or directory
nvidia-persistenced: Shutdown (1994)
nvidia-persistenced: Started (1997)
nvidia-persistenced: Failed to open libnvidia-cfg.so.1: libnvidia-cfg.so.1: cannot open shared object file: No such file or directory
nvidia-persistenced: Shutdown (1997)
nvidia-persistenced: Started (2041)
nvidia-persistenced: Failed to open libnvidia-cfg.so.1: libnvidia-cfg.so.1: cannot open shared object file: No such file or directory
nvidia-persistenced: Shutdown (2041)
答案1
从默认的 Ubuntu 存储库安装nvidia-driver-$version
软件包。它将安装 nvidia 驱动程序、二进制文件nvidia-persistenced
并通过nvidia-persistenced.service
启动systemd
。
跑步:
systemctl edit nvidia-persistenced.service
这将创建一个覆盖文件,该文件会更改默认文件的行为/lib/systemd/system/nvidia-persistenced.service
。这将打开默认编辑器,可能nano
没有任何内容。粘贴以下内容:
[Service]
ExecStart=
ExecStart=/usr/bin/nvidia-persistenced --user nvidia-persistenced --persistence-mode --verbose
保存文件,它将自动创建为/etc/systemd/system/nvidia-persistenced.service.d/override.conf
。最后,重新启动守护进程:
systemctl restart nvidia-persistenced.service
答案2
以下内容帮助我解决错误并创建持久守护进程:
sudo apt install libnvidia-cfg1-510 #replace 510 with your driver version
然后运行以下命令:
sudo nvidia-persistenced --user USER #replace USER with your username
如果你只是想让它持续存在仅有的你当前的会话只需运行这个:
sudo nvidia-smi -pm 1
答案3
我个人使用 crontab 来在开机时启动它。
sudo crontab -e
我使用 Vim。使用您觉得最舒服的文本编辑器。在文件末尾添加以下内容:
@reboot sudo nvidia-smi -pm 1 &
保存并退出 crontab。重启,登录,打开终端并输入:
nvidia-smi
如果出现提示说你的 GPU 已打开,那么就可以开始了。