pseudowire

調べたことを書き残す

ひさびさにGeForceを積んだUbuntu20.04のノートPCを使ってみようとしたら、リモート接続できずに苦戦した話

nvidia-smi

Sat Apr 27 16:49:02 2024
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 515.48.07    Driver Version: 515.48.07    CUDA Version: 11.7     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   47C    P8    10W /  N/A |      5MiB /  6144MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A       951      G   /usr/lib/xorg/Xorg                  4MiB |
+-----------------------------------------------------------------------------+

リモート接続

  • xrdpを試してみた →キーボードが効かない
  • x11vncを試しみた →認証が失敗する
  • 下記参考記事の通り、VirtualGL+TurboVNCを試した →成功!
$ /opt/TurboVNC/bin/vncserver -depth 24

Suspend対策

  • 変更前の状態
$ systemctl list-unit-files --type=service | grep nvidia
nvidia-hibernate.service                   enabled         enabled      
nvidia-persistenced.service                static          enabled      
nvidia-resume.service                      enabled         enabled      
nvidia-suspend.service                     enabled         enabled      
  • 実行コマンド
$ systemctl disable nvidia-hibernate.service nvidia-resume.service  nvidia-suspend.service
Removed /etc/systemd/system/systemd-suspend.service.wants/nvidia-suspend.service.
Removed /etc/systemd/system/systemd-suspend.service.wants/nvidia-resume.service.
Removed /etc/systemd/system/systemd-hibernate.service.wants/nvidia-hibernate.service.
Removed /etc/systemd/system/systemd-hibernate.service.wants/nvidia-resume.service.
  • 変更後の状態
$ systemctl list-unit-files --type=service | grep nvidia
nvidia-hibernate.service                   disabled        enabled      
nvidia-persistenced.service                static          enabled      
nvidia-resume.service                      disabled        enabled      
nvidia-suspend.service                     disabled        enabled      
  • 実行コマンド
$ sudo rm /lib/systemd/system-sleep/nvidia
  • 削除したファイルの内容
$ cat  /lib/systemd/system-sleep/nvidia
#!/bin/sh

case "$1" in
    post)
        /usr/bin/nvidia-sleep.sh "resume"
        ;;
esac


$ cat /usr/bin/nvidia-sleep.sh
#!/bin/bash

if [ ! -f /proc/driver/nvidia/suspend ]; then
    exit 0
fi

RUN_DIR="/var/run/nvidia-sleep"
XORG_VT_FILE="${RUN_DIR}"/Xorg.vt_number

PATH="/bin:/usr/bin"

case "$1" in
    suspend|hibernate)
        mkdir -p "${RUN_DIR}"
        fgconsole > "${XORG_VT_FILE}"
        chvt 63
        if [[ $? -ne 0 ]]; then
            exit $?
        fi
        echo "$1" > /proc/driver/nvidia/suspend
        exit $?
        ;;
    resume)
        echo "$1" > /proc/driver/nvidia/suspend 
        #
        # Check if Xorg was determined to be running at the time
        # of suspend, and whether its VT was recorded.  If so,
        # attempt to switch back to this VT.
        #
        if [[ -f "${XORG_VT_FILE}" ]]; then
            XORG_PID=$(cat "${XORG_VT_FILE}")
            rm "${XORG_VT_FILE}"
            chvt "${XORG_PID}"
        fi
        exit 0
        ;;
    *)
        exit 1
esac
  • 実行コマンド
$ sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
Created symlink /etc/systemd/system/sleep.target → /dev/null.
Created symlink /etc/systemd/system/suspend.target → /dev/null.
Created symlink /etc/systemd/system/hibernate.target → /dev/null.
Created symlink /etc/systemd/system/hybrid-sleep.target → /dev/null.

Ref

qiita.com

github.com

note.com

forums.developer.nvidia.com

ericmjl.github.io