

# G4ad Linux インスタンスでデュアル 4K ディスプレイをセットアップする
<a name="activate_g4ad_4k"></a>

G4ad インスタンスを起動すると、デュアル 4K ディスプレイをセットアップできます。

**AMD ドライバーをインストールしてデュアル画面を設定するには**

1. Linux インスタンスに接続して、デュアル 4K (2x4k) 向けにターゲットとする GPU の PCI Bus アドレスを取得します。

   ```
   lspci -vv | grep -i amd
   ```

   以下のような出力結果が取得できます。

   ```
   00:1e.0 Display controller: Advanced Micro Devices, Inc. [*AMD*/ATI] Device 7362 (rev c3)
   Subsystem: Advanced Micro Devices, Inc. [AMD/ATI] Device 0a34
   ```

1. 上記の出力では、PCI バスアドレスは 00:1e.0 であることに注意してください。`/etc/modprobe.d/amdgpu.conf` という名前のファイルを作成して追加します。

   ```
   options amdgpu virtual_display=0000:00:1e.0,2
   ```

1. Linux に AMD ドライバーをインストールするには、「[EC2 インスタンス用の AMD ドライバー](install-amd-driver.md)」を参照してください。AMD GPU ドライバーが既にインストールされている場合は、dkms を通じて amdgpu カーネルモジュールを再構築する必要があります。

1. 以下の xorg.conf ファイルを使用して、デュアル (2x4K) スクリーントポロジを定義し、`/etc/X11/xorg.conf:` のファイルに保存します。

   ```
   ~$ cat /etc/X11/xorg.conf
   Section "ServerLayout"
       Identifier     "Layout0"
       Screen          0 "Screen0"
       Screen        1 "Screen1"
       InputDevice     "Keyboard0" "CoreKeyboard"
       InputDevice     "Mouse0" "CorePointer"
       Option          "Xinerama" "1"
   EndSection
   Section "Files"
       ModulePath "/opt/amdgpu/lib64/xorg/modules/drivers"
       ModulePath "/opt/amdgpu/lib/xorg/modules"
       ModulePath "/opt/amdgpu-pro/lib/xorg/modules/extensions"
       ModulePath "/opt/amdgpu-pro/lib64/xorg/modules/extensions"
       ModulePath "/usr/lib64/xorg/modules"
       ModulePath "/usr/lib/xorg/modules"
   EndSection
   Section "InputDevice"
       # generated from default
       Identifier     "Mouse0"
       Driver         "mouse"
       Option         "Protocol" "auto"
       Option         "Device" "/dev/psaux"
       Option         "Emulate3Buttons" "no"
       Option         "ZAxisMapping" "4 5"
   EndSection
   Section "InputDevice"
       # generated from default
       Identifier     "Keyboard0"
       Driver         "kbd"
   EndSection
   
   Section "Monitor"
       Identifier     "Virtual"
       VendorName     "Unknown"
       ModelName      "Unknown"
       Option         "Primary" "true"
   EndSection
   
   Section "Monitor"
       Identifier     "Virtual-1"
       VendorName     "Unknown"
       ModelName      "Unknown"
       Option         "RightOf" "Virtual"
   EndSection
   
   Section "Device"
       Identifier     "Device0"
       Driver         "amdgpu"
       VendorName     "AMD"
       BoardName      "Radeon MxGPU V520"
       BusID          "PCI:0:30:0"
   EndSection
   
   Section "Device"
       Identifier     "Device1"
       Driver         "amdgpu"
       VendorName     "AMD"
       BoardName      "Radeon MxGPU V520"
       BusID          "PCI:0:30:0"
   EndSection
   
   Section "Extensions"
       Option         "DPMS" "Disable"
   EndSection
   
   Section "Screen"
       Identifier     "Screen0"
       Device         "Device0"
       Monitor        "Virtual"
       DefaultDepth   24
       Option         "AllowEmptyInitialConfiguration" "True"
       SubSection "Display"
           Virtual    3840 2160
           Depth      32
       EndSubSection
   EndSection
   
   Section "Screen"
       Identifier     "Screen1"
       Device         "Device1"
       Monitor        "Virtual"
       DefaultDepth   24
       Option         "AllowEmptyInitialConfiguration" "True"
       SubSection "Display"
           Virtual    3840 2160
           Depth      32
       EndSubSection
   EndSection
   ```

1. [インタラクティブデスクトップ](#amd-interactive-desktop)の設定手順に従って、DCV を設定します。

1. DCV の設定が完了したら、再起動します。

1. ドライバーが機能していることを確認します。

   ```
   dmesg | grep amdgpu
   ```

   レスポンスは次のようになります。

   ```
   Initialized amdgpu
   ```

1. `DISPLAY=:0 xrandr -q` の出力で、2 つの仮想ディスプレイが接続されていることを確認できます。

   ```
   ~$ DISPLAY=:0 xrandr -q
   Screen 0: minimum 320 x 200, current 3840 x 1080, maximum 16384 x 16384
   Virtual connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
    4096x3112  60.00
    3656x2664  59.99
    4096x2160  60.00
    3840x2160  60.00
    1920x1200  59.95
    1920x1080  60.00
    1600x1200  59.95
    1680x1050  60.00
    1400x1050  60.00
    1280x1024  59.95
    1440x900 59.99
    1280x960 59.99
    1280x854 59.95
    1280x800 59.96
    1280x720 59.97
    1152x768 59.95
    1024x768 60.00 59.95
    800x600  60.32 59.96 56.25
    848x480  60.00 59.94
    720x480  59.94
    640x480  59.94 59.94
   Virtual-1 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 0mm x 0mm
    4096x3112  60.00
    3656x2664  59.99
    4096x2160  60.00
    3840x2160  60.00
    1920x1200  59.95
    1920x1080  60.00
    1600x1200  59.95
    1680x1050  60.00
    1400x1050  60.00
    1280x1024  59.95
    1440x900 59.99
    1280x960 59.99
    1280x854 59.95
    1280x800 59.96
    1280x720 59.97
    1152x768 59.95
    1024x768 60.00 59.95
    800x600  60.32 59.96 56.25
    848x480  60.00 59.94
    720x480  59.94
   640x480  59.94 59.94
   ```

1. DCV に接続するときは、解像度を 2x4K に変更し、デュアルモニタのサポートが DCV によって登録されていることを確認します。  
![\[DCV 解像度の変更\]](http://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/images/dm-dcv-example.png)

## Linux のインタラクティブデスクトップをセットアップする
<a name="amd-interactive-desktop"></a>

Linux インスタンスに AMD GPU ドライバーがインストールされ、amdgpu が使用されていることを確認したら、インタラクティブデスクトップマネージャーをインストールできます。最高の互換性とパフォーマンスを得るには、MATE デスクトップ環境をお勧めします。

**前提条件**  
テキストエディタを開き、次のファイルを`xorg.conf`という名前のファイルとして保存します。このファイルはインスタンスで必要になります。

```
Section "ServerLayout"
Identifier     "Layout0"
Screen          0 "Screen0"
InputDevice     "Keyboard0" "CoreKeyboard"
InputDevice     "Mouse0" "CorePointer"
EndSection
Section "Files"
ModulePath "/opt/amdgpu/lib64/xorg/modules/drivers"
ModulePath "/opt/amdgpu/lib/xorg/modules"
ModulePath "/opt/amdgpu-pro/lib/xorg/modules/extensions"
ModulePath "/opt/amdgpu-pro/lib64/xorg/modules/extensions"
ModulePath "/usr/lib64/xorg/modules"
ModulePath "/usr/lib/xorg/modules"
EndSection
Section "InputDevice"
# generated from default
Identifier     "Mouse0"
Driver         "mouse"
Option         "Protocol" "auto"
Option         "Device" "/dev/psaux"
Option         "Emulate3Buttons" "no"
Option         "ZAxisMapping" "4 5"
EndSection
Section "InputDevice"
# generated from default
Identifier     "Keyboard0"
Driver         "kbd"
EndSection
Section "Monitor"
Identifier     "Monitor0"
VendorName     "Unknown"
ModelName      "Unknown"
EndSection
Section "Device"
Identifier     "Device0"
Driver         "amdgpu"
VendorName     "AMD"
BoardName      "Radeon MxGPU V520"
BusID          "PCI:0:30:0"
EndSection
Section "Extensions"
Option         "DPMS" "Disable"
EndSection
Section "Screen"
Identifier     "Screen0"
Device         "Device0"
Monitor        "Monitor0"
DefaultDepth   24
Option         "AllowEmptyInitialConfiguration" "True"
SubSection "Display"
    Virtual    3840 2160
    Depth      32
EndSubSection
EndSection
```

**Amazon Linux 2 でインタラクティブデスクトップをセットアップするには**

1. EPEL リポジトリをインストールします。

   ```
   [ec2-user ~]$ sudo amazon-linux-extras install epel -y
   ```

1. MATE デスクトップをインストールします。

   ```
   [ec2-user ~]$ sudo amazon-linux-extras install mate-desktop1.x -y
   [ec2-user ~]$ sudo yum groupinstall "MATE Desktop" -y
   [ec2-user ~]$ sudo systemctl disable firewalld
   ```

1. `xorg.conf` ファイルを `/etc/X11/xorg.conf` にコピーします。

1. インスタンスを再起動します。

   ```
   [ec2-user ~]$ sudo reboot
   ```

1. (オプション) [Amazon DCV サーバーをインストールして](https://docs.aws.amazon.com/dcv/latest/adminguide/setting-up-installing.html)、Amazon DCV を高パフォーマンスの表示プロトコルとして使用してから、お好みのクライアントを使用して [Amazon DCV セッションに接続します](https://docs.aws.amazon.com/dcv/latest/userguide/using-connecting.html)。

**Ubuntu でインタラクティブデスクトップをセットアップするには**

1. MATE デスクトップをインストールします。

   ```
   $ sudo apt install xorg-dev ubuntu-mate-desktop -y
   $ sudo apt purge ifupdown -y
   ```

1. `xorg.conf` ファイルを `/etc/X11/xorg.conf` にコピーします。

1. インスタンスを再起動します。

   ```
   $ sudo reboot
   ```

1. 適切なバージョンの Ubuntu 用の AMF エンコーダーをインストールします。

   ```
   $ sudo apt install ./amdgpu-pro-20.20-*/amf-amdgpu-pro_20.20-*_amd64.deb
   ```

1. (オプション) [Amazon DCV サーバーをインストールして](https://docs.aws.amazon.com/dcv/latest/adminguide/setting-up-installing.html)、Amazon DCV を高パフォーマンスの表示プロトコルとして使用してから、お好みのクライアントを使用して [Amazon DCV セッションに接続します](https://docs.aws.amazon.com/dcv/latest/userguide/using-connecting.html)。

1. DCV のインストール後、DCV ユーザーに動画のアクセス権限を付与します。

   ```
   $ sudo usermod -aG video dcv
   ```

**CentOS で対話型デスクトップをセットアップするには**

1. EPEL リポジトリをインストールします。

   ```
   $ sudo yum update -y
   $ sudo yum install epel-release -y
   ```

1. MATE デスクトップをインストールします。

   ```
   $ sudo yum groupinstall "MATE Desktop" -y
   $ sudo systemctl disable firewalld
   ```

1. `xorg.conf` ファイルを `/etc/X11/xorg.conf` にコピーします。

1. インスタンスを再起動します。

   ```
   $ sudo reboot
   ```

1. (オプション) [Amazon DCV サーバーをインストールして](https://docs.aws.amazon.com/dcv/latest/adminguide/setting-up-installing.html)、Amazon DCV を高パフォーマンスの表示プロトコルとして使用してから、お好みのクライアントを使用して [Amazon DCV セッションに接続します](https://docs.aws.amazon.com/dcv/latest/userguide/using-connecting.html)。

   