---
# System prepended metadata

title: How to recover your xorg after install rocm

---

# How to recover your gnome-desktop after install rocm on ubuntu 24.04 LTS
## 緣由
安裝rocm後gnome-Shell.desktop沒辦法顯示

## 原因
觀察`/var/log/syslog`會發現gnome-shell沒辦法登入
```
2024-07-25T17:26:23.290223+08:00 hychang-MS-7A40 snapd-desktop-integration.snapd-desktop-integration[3799]: Sorry, home directories outside of /home needs configuration.
2024-07-25T17:26:23.291203+08:00 hychang-MS-7A40 snapd-desktop-integration.snapd-desktop-integration[3799]: See https://forum.snapcraft.io/t/11209 for details.
2024-07-25T17:26:23.291508+08:00 hychang-MS-7A40 systemd[3780]: snap.snapd-desktop-integration.snapd-desktop-integration.service: Main process exited, code=exited, status=1/FAILURE
2024-07-25T17:26:23.291655+08:00 hychang-MS-7A40 systemd[3780]: snap.snapd-desktop-integration.snapd-desktop-integration.service: Failed with result 'exit-code'.
2024-07-25T17:26:23.421858+08:00 hychang-MS-7A40 systemd[1]: Cannot find unit for notify message of PID 3909, ignoring.
2024-07-25T17:26:23.425273+08:00 hychang-MS-7A40 gnome-shell[3883]: Running GNOME Shell (using mutter 46.0) as a Wayland display server
2024-07-25T17:26:23.522775+08:00 hychang-MS-7A40 rtkit-daemon[3828]: Supervising 7 threads of 4 processes of 1 users.
2024-07-25T17:26:23.523419+08:00 hychang-MS-7A40 rtkit-daemon[3828]: Supervising 7 threads of 4 processes of 1 users.
2024-07-25T17:26:23.528451+08:00 hychang-MS-7A40 rtkit-daemon[3828]: Successfully made thread 3910 of process 3883 owned by '128' RT at priority 20.
2024-07-25T17:26:23.528595+08:00 hychang-MS-7A40 rtkit-daemon[3828]: Supervising 8 threads of 5 processes of 1 users.
2024-07-25T17:26:23.528762+08:00 hychang-MS-7A40 org.gnome.Shell.desktop[3883]: MESA-LOADER: failed to open simpledrm: /usr/lib/dri/simpledrm_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
2024-07-25T17:26:23.528990+08:00 hychang-MS-7A40 gnome-shell[3883]: Made thread 'KMS thread' realtime scheduled
2024-07-25T17:26:23.530020+08:00 hychang-MS-7A40 org.gnome.Shell.desktop[3883]: MESA-LOADER: failed to open kms_swrast: /usr/lib/dri/kms_swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
2024-07-25T17:26:23.530079+08:00 hychang-MS-7A40 org.gnome.Shell.desktop[3883]: MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
2024-07-25T17:26:23.531063+08:00 hychang-MS-7A40 gnome-shell[3883]: Failed to open gpu '/dev/dri/card0': Failed to initialize render device for /dev/dri/card0: Failed to create gbm device: No such file or directory, Missing required EGLDevice extension EGL_EXT_device_drm
2024-07-25T17:26:23.531583+08:00 hychang-MS-7A40 org.gnome.Shell.desktop[3883]: Failed to setup: No GPUs found
2024-07-25T17:26:23.544693+08:00 hychang-MS-7A40 gnome-session[3835]: gnome-session-binary[3835]: WARNING: App 'org.gnome.Shell.desktop' exited with code 1
2024-07-25T17:26:23.544753+08:00 hychang-MS-7A40 gnome-session-binary[3835]: WARNING: App 'org.gnome.Shell.desktop' exited with code 1
```
原因在`MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)`

cd 到`/usr/lib/x86_64-linux-gnu/dri`會發現swrast_dri.so指向`/opt/amdgpu/lib/x86_64-linux-gnu/dri/swrast_dri.so`
如果`/opt/amdgpu/lib/x86_64-linux-gnu/dri/swrast_dri.so`不存在那麼gnome-shell-desktop就沒辦法正常啟動，也就沒辦法測試rocm(~~工人智慧實驗~~)

## 重新安裝
如果沒有amdgpu-install先重新安裝
```
sudo apt update
sudo apt install "linux-headers-$(uname -r)" "linux-modules-extra-$(uname -r)"
sudo usermod -a -G render,video $LOGNAME # Add the current user to the render and video groups
wget https://repo.radeon.com/amdgpu-install/6.1.2/ubuntu/jammy/amdgpu-install_6.1.60102-1_all.deb
sudo apt install ./amdgpu-install_6.1.60102-1_all.deb
sudo apt update
sudo apt install amdgpu-dkms rocm
```
再重裝rocm
```
amdgpu-install --usecase=graphics
amdgpu-install --usecase=rocm
```
檢查`/usr/lib/x86_64-linux-gnu/dri`連結有沒有重新連結到`/opt/amdgpu/lib/x86_64-linux-gnu/dri/`下的shared library，如果有的話重新開機應該就可以進入gnome-shell-desktop了。
```
root@hychang-MS-7A40:/var/log# ls -la /usr/lib/x86_64-linux-gnu/dri
total 582740
drwxr-xr-x   2 root root     4096 Jul 25 18:17 .
drwxr-xr-x 122 root root   135168 Jul 25 15:35 ..
-rw-r--r--  13 root root 33729832 Jun 11 00:07 crocus_dri.so
-rw-r--r--  13 root root 33729832 Jun 11 00:07 d3d12_dri.so
-rw-r--r--   5 root root 15982712 Jun 11 00:07 d3d12_drv_video.so
-rw-r--r--  13 root root 33729832 Jun 11 00:07 i915_dri.so
-rw-r--r--   4 root root 15693800 Apr  9 00:12 i965_dri.so
-rw-r--r--   1 root root  1772232 Apr 19 01:47 i965_drv_video.so
-rw-r--r--   1 root root 13589472 Dec 30  2023 iHD_drv_video.so
-rw-r--r--  13 root root 33729832 Jun 11 00:07 iris_dri.so
lrwxrwxrwx   1 root root       54 Jul 25 18:17 kms_swrast_dri.so -> /opt/amdgpu/lib/x86_64-linux-gnu/dri/kms_swrast_dri.so
-rw-r--r--  13 root root 33729832 Jun 11 00:07 kms_swrast_dri.so~
-rw-r--r--  13 root root 33729832 Jun 11 00:07 nouveau_dri.so
-rw-r--r--   5 root root 15982712 Jun 11 00:07 nouveau_drv_video.so
-rw-r--r--   4 root root 15693800 Apr  9 00:12 nouveau_vieux_dri.so
-rw-r--r--   4 root root 15693800 Apr  9 00:12 r200_dri.so
-rw-r--r--  13 root root 33729832 Jun 11 00:07 r300_dri.so
lrwxrwxrwx   1 root root       48 Jul 25 18:17 r600_dri.so -> /opt/amdgpu/lib/x86_64-linux-gnu/dri/r600_dri.so
-rw-r--r--  13 root root 33729832 Jun 11 00:07 r600_dri.so~
lrwxrwxrwx   1 root root       54 Jul 25 18:17 r600_drv_video.so -> /opt/amdgpu/lib/x86_64-linux-gnu/dri/r600_drv_video.so
-rw-r--r--   5 root root 15982712 Jun 11 00:07 r600_drv_video.so~
-rw-r--r--   4 root root 15693800 Apr  9 00:12 radeon_dri.so
lrwxrwxrwx   1 root root       52 Jul 25 18:17 radeonsi_dri.so -> /opt/amdgpu/lib/x86_64-linux-gnu/dri/radeonsi_dri.so
-rw-r--r--  13 root root 33729832 Jun 11 00:07 radeonsi_dri.so~
lrwxrwxrwx   1 root root       58 Jul 25 18:17 radeonsi_drv_video.so -> /opt/amdgpu/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so
-rw-r--r--   5 root root 15982712 Jun 11 00:07 radeonsi_drv_video.so~
lrwxrwxrwx   1 root root       50 Jul 25 18:17 swrast_dri.so -> /opt/amdgpu/lib/x86_64-linux-gnu/dri/swrast_dri.so
-rw-r--r--  13 root root 33729832 Jun 11 00:07 swrast_dri.so~
lrwxrwxrwx   1 root root       54 Jul 25 18:17 virtio_gpu_dri.so -> /opt/amdgpu/lib/x86_64-linux-gnu/dri/virtio_gpu_dri.so
-rw-r--r--  13 root root 33729832 Jun 11 00:07 virtio_gpu_dri.so~
lrwxrwxrwx   1 root root       60 Jul 25 18:17 virtio_gpu_drv_video.so -> /opt/amdgpu/lib/x86_64-linux-gnu/dri/virtio_gpu_drv_video.so
-rw-r--r--   5 root root 15982712 Jun 11 00:07 virtio_gpu_drv_video.so~
lrwxrwxrwx   1 root root       50 Jul 25 18:17 vmwgfx_dri.so -> /opt/amdgpu/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so
-rw-r--r--  13 root root 33729832 Jun 11 00:07 vmwgfx_dri.so~
-rw-r--r--  13 root root 33729832 Jun 11 00:07 zink_dri.so

```

# reference
https://bugzilla.redhat.com/show_bug.cgi?id=1964038
https://askubuntu.com/questions/1451610/mesa-loader-failed-to-open-swrast-ubuntu-20-04
