Skip to content

Instantly share code, notes, and snippets.

@tonykero
Created October 28, 2020 23:37
Show Gist options
  • Save tonykero/8ceb62868378ee11e36b07f975731d26 to your computer and use it in GitHub Desktop.
Save tonykero/8ceb62868378ee11e36b07f975731d26 to your computer and use it in GitHub Desktop.
## Will successfully install amdgpu drivers and rocm,
## but pointless as there is no gpu device attached to WSL2 (only CUDA and DirectML is supported, not /dev/kfd or amd gpus)
## ROCM/HIP
sudo apt update
sudo apt dist-upgrade
sudo apt install libnuma-dev
wget -q -O - http://repo.radeon.com/rocm/rocm.gpg.key | sudo apt-key add -
echo 'deb [arch=amd64] http://repo.radeon.com/rocm/apt/debian/ xenial main' | sudo tee /etc/apt/sources.list.d/rocm.list
sudo apt update
sudo apt install rocm-dkms
sudo usermod -a -G video $LOGNAME
sudo usermod -a -G render $LOGNAME
## TEST
/opt/rocm/bin/rocminfo
/opt/rocm/opencl/bin/clinfo
## AMDGPU DRIVER
#http://cofal.work/2019/09/27/Ubuntu%E4%B8%8B%E5%AE%89%E8%A3%85ROCm%E8%BF%87%E7%A8%8B/
#https://askubuntu.com/questions/1097030/cant-install-amdgpu-pro-18-40-on-ubuntu-server-18-04-01
sudo apt update && sudo apt install -y build-essential clang clang-format clang-tidy cmake cmake-qt-gui ssh curl apt-utils pkg-config g++-multilib git libunwind-dev libfftw3-dev libelf-dev libncurses5-dev libpthread-stubs0-dev vim gfortran libboost-program-options-dev libssl-dev libboost-dev libboost-system-dev libboost-filesystem-dev rpm build-essential cdbs dh-make dkms execstack dh-modaliases
sudo apt-get install linux-headers-4.15.0-20-generic
sudo apt-add-repository universe
sudo dpkg --add-architecture i386
sudo ./amdgpu-install --opencl=legacy --no-dkms
sudo apt-get -o Dpkg::Options::="--force-overwrite" install amdgpu-dkms
# for amdgpu-pro-install (use previously downloaded files in cache)
amdgpu-uninstall
sudo ./amdgpu-pro-install --opencl=legacy
#https://askubuntu.com/questions/1040474/warning-amdgpu-dkms-failed-for-running-kernel-on-both-16-04-18-04
apt install amdgpu-dkms libdrm-amdgpu-amdgpu1 libdrm-amdgpu1 libdrm2-amdgpu
# ---
sudo apt-get -o Dpkg::Options::="--force-overwrite" dist-upgrade
## TEST
/opt/rocm/bin/rocminfo
/opt/rocm/opencl/bin/clinfo
@NickDeBeenSAE
Copy link

NickDeBeenSAE commented Jul 25, 2023

E: The repository 'http://repo.radeon.com/rocm/apt/debian xenial Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

This basically means that this is a dud package.

Please ensure that your using secure repositories.

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package rocm-dkms

This means that rocm-dkms does not exist.

I guess this package is also a dud:

sudo apt-get install linux-headers-4.15.0-20-generic
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package linux-headers-4.15.0-20-generic
E: Couldn't find any package by glob 'linux-headers-4.15.0-20-generic'
E: Couldn't find any package by regex 'linux-headers-4.15.0-20-generic'

This happens even if amdgpu and its -dkms package is installed:

sudo ./amdgpu-install --opencl=legacy --no-dkms
sudo: ./amdgpu-install: command not found

Again, after an attempt at installing amdgpu and its -dkms package:

sudo apt-get -o Dpkg::Options::="--force-overwrite" install amdgpu-dkms
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
amdgpu-dkms
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 0 B/9844 kB of archives.
After this operation, 428 MB of additional disk space will be used.
Selecting previously unselected package amdgpu-dkms.
dpkg: warning: files list file for package 'amdgpu-core' missing; assuming package has no files currently installed
(Reading database ... 230177 files and directories currently installed.)
Preparing to unpack .../amdgpu-dkms_1%3a5.18.13.50401-1520974.22.04_all.deb ...
Unpacking amdgpu-dkms (1:5.18.13.50401-1520974.22.04) ...
Setting up amdgpu-dkms (1:5.18.13.50401-1520974.22.04) ...
Loading new amdgpu-5.18.13-1520974.22.04 DKMS files...
It is likely that 5.15.90.1-microsoft-standard-WSL2 belongs to a chroot's host
Building for
Building for architecture x86_64
update-initramfs: Generating /boot/initrd.img-added
grep: /boot/config-added: No such file or directory
W: zstd compression (CONFIG_RD_ZSTD) not supported by kernel, using gzip
grep: /boot/config-added: No such file or directory
E: gzip compression (CONFIG_RD_GZIP) not supported by kernel
update-initramfs: failed for /boot/initrd.img-added with 1.
dpkg: error processing package amdgpu-dkms (--configure):
installed amdgpu-dkms package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
amdgpu-dkms
E: Sub-process /usr/bin/dpkg returned an error code (1)

I have AMD Pro drivers installed on the Windows 11's side, but, WSL2 comes back with this when I attempt to install the Linux version of the package:

sudo ./amdgpu-pro-install --opencl=legacy
sudo: ./amdgpu-pro-install: command not found

You made a mistake here:

apt install amdgpu-dkms libdrm-amdgpu-amdgpu1 libdrm-amdgpu1 libdrm2-amdgpu
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

You failed to include sudo in the above command.

Again, when attempting to process the same package:

sudo apt-get install amdgpu-dkms libdrm-amdgpu-amdgpu1 libdrm-amdgpu1 libdrm2-amdgpu
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
amdgpu-dkms is already the newest version (1:5.18.13.50401-1520974.22.04).
libdrm-amdgpu-amdgpu1 is already the newest version (1:2.4.115.50600-1609671.22.04).
libdrm-amdgpu-amdgpu1 set to manually installed.
libdrm-amdgpu1 is already the newest version (2.4.114-1).
libdrm-amdgpu1 set to manually installed.
libdrm2-amdgpu is already the newest version (1:2.4.115.50600-1609671.22.04).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up amdgpu-dkms (1:5.18.13.50401-1520974.22.04) ...
Removing old amdgpu-5.18.13-1520974.22.04 DKMS files...
Deleting module amdgpu-5.18.13-1520974.22.04 completely from the DKMS tree.
Loading new amdgpu-5.18.13-1520974.22.04 DKMS files...
It is likely that 5.15.90.1-microsoft-standard-WSL2 belongs to a chroot's host
Building for
Building for architecture x86_64
update-initramfs: Generating /boot/initrd.img-added
grep: /boot/config-added: No such file or directory
W: zstd compression (CONFIG_RD_ZSTD) not supported by kernel, using gzip
grep: /boot/config-added: No such file or directory
E: gzip compression (CONFIG_RD_GZIP) not supported by kernel
update-initramfs: failed for /boot/initrd.img-added with 1.
dpkg: error processing package amdgpu-dkms (--configure):
installed amdgpu-dkms package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
amdgpu-dkms
E: Sub-process /usr/bin/dpkg returned an error code (1)

Another command that continues to fail:

sudo apt-get -o Dpkg::Options::="--force-overwrite" dist-upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
linux-libc-dev
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 1540 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu lunar-updates/main amd64 linux-libc-dev amd64 6.2.0-26.26 [1540 kB]
Fetched 1540 kB in 3s (477 kB/s)
dpkg: warning: files list file for package 'amdgpu-core' missing; assuming package has no files currently installed
(Reading database ... 233064 files and directories currently installed.)
Preparing to unpack .../linux-libc-dev_6.2.0-26.26_amd64.deb ...
Unpacking linux-libc-dev:amd64 (6.2.0-26.26) over (6.2.0-25.25) ...
Setting up linux-libc-dev:amd64 (6.2.0-26.26) ...
Setting up amdgpu-dkms (1:5.18.13.50401-1520974.22.04) ...
Removing old amdgpu-5.18.13-1520974.22.04 DKMS files...
Deleting module amdgpu-5.18.13-1520974.22.04 completely from the DKMS tree.
Loading new amdgpu-5.18.13-1520974.22.04 DKMS files...
It is likely that 5.15.90.1-microsoft-standard-WSL2 belongs to a chroot's host
Building for
Building for architecture x86_64
update-initramfs: Generating /boot/initrd.img-added
grep: /boot/config-added: No such file or directory
W: zstd compression (CONFIG_RD_ZSTD) not supported by kernel, using gzip
grep: /boot/config-added: No such file or directory
E: gzip compression (CONFIG_RD_GZIP) not supported by kernel
update-initramfs: failed for /boot/initrd.img-added with 1.
dpkg: error processing package amdgpu-dkms (--configure):
installed amdgpu-dkms package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
amdgpu-dkms
E: Sub-process /usr/bin/dpkg returned an error code (1)

This is the entire list of failures because ROCm is not supported on WSL2, or WSL in general for this matter.

@tonykero
Copy link
Author

tonykero commented Jul 25, 2023

@NickDeBeenSAE I am really super sorry, I should probably hide or delete this gist, I did not think that someone would actually try my gist.

I did this 3 years ago and never clicked on it again, basically it installs but cannot do anything because as you mentioned it simply just does not work.

My use case at the time was for gpu accelerated machine learning on Windows, with an AMD GPU, but thanks to [PyTorch-DirectML] I don't need it anymore (https://learn.microsoft.com/en-us/windows/ai/directml/gpu-pytorch-windows)

But for SYCL with ROCm platform I think this is still blocking under Windows. (EDIT: actually this may have been my initial use case)

May I ask why are you trying to use ROCm for ?

Again really sorry for your loss of time, try to send a message under a gist to ask if it still works or something....

@NickDeBeenSAE
Copy link

I was unaware that PyTorch-DirectML existed 🤔🤔🤔 hmmmmm. I might try that.

Also, the use case for me when it comes to ROCm and CuDNN/Cuda Tookit would be Game Development and Remastering games via harnessing the full power of my GPU.

@tonykero
Copy link
Author

@NickDeBeenSAE

pytorch_directml is actually very cool: it's how stable diffusion project works on AMD GPUs: https://github.com/search?q=repo%3Alshqqytiger%2Fstable-diffusion-webui-directml%20torch_directml&type=code
(in a fork though)

For Game Development I feel like you could exploit Vulkan Compute Shaders, depends on the flexibility you need for GPGPU programming.

Otherwise, another portable solution with SYCL is DPC++ https://oneapi-src.github.io/oneDNN/v2.5/dev_guide_dpcpp_backends.html, they seem to have an OpenCL backend, didn't test though.

Then apart from that, I'm convinced that nothing is mature, or not fully portable, having to fight with ROCm or CUDA seems a bother to me...
personal preference

I can mention https://github.com/halide/Halide also, which is C++ Centric, but supports a load of backend.

Hope you get what you searched for.

@JavenLiPl
Copy link

ROCm support seems avialable for windows already last month. There might be more people wondering this topic(like me :)), just like nvidia provide a WSL2 based solution for a long time.

BTW, does ROCm windows release make any difference on this topic? I'm totally new to ML and just want to learn.

@timmyz
Copy link

timmyz commented Aug 11, 2023

same here, stuck at the accessing to /dev/kdf

@NickDeBeenSAE
Copy link

same here, stuck at the accessing to /dev/kdf

How the hell did you manage to install the drivers?

@yhd9487
Copy link

yhd9487 commented Nov 15, 2023

ROCm support seems avialable for windows already last month. There might be more people wondering this topic(like me :)), just like nvidia provide a WSL2 based solution for a long time.

BTW, does ROCm windows release make any difference on this topic? I'm totally new to ML and just want to learn.

pytorch and tenserflow did not release any distribution that supports ROCm on Windows right now, ROCm comes to windows is just "come", it did not have any actual support from DL&ML models, I think it still a long way to go.

@Headcrabed
Copy link

Seems amd is working on that wsl2 support now. In rocm 6.0.6 installer, there is a usecase option for wsl2, but I haven't tried that yet.

@codevladimir
Copy link

Seems amd is working on that wsl2 support now. In rocm 6.0.6 installer, there is a usecase option for wsl2, but I haven't tried that yet.

Where did you find 6.0.6 installer? I only see 6.0.2. I would like to test that out and see if it works

@Headcrabed
Copy link

Seems amd is working on that wsl2 support now. In rocm 6.0.6 installer, there is a usecase option for wsl2, but I haven't tried that yet.

Where did you find 6.0.6 installer? I only see 6.0.2. I would like to test that out and see if it works

https://rocm.docs.amd.com/projects/install-on-linux/en/latest/tutorial/quick-start.html

However apt reports can't locate hsa-runtime-rocr4wsl-amdgpu, so I think it is not opened to public now. Maybe we could see it working in rocm 6.1?

@yzsshen
Copy link

yzsshen commented Apr 4, 2024

I'm getting the same issue, is there a way to list all --usecase options?
sudo amdgpu-install --list-usecase has an option for wsl:

wsl             (for using ROCm in a WSL context)
  - ROCr WSL runtime library (Ubuntu 22.04 only)

sudo amdgpu-install --usecase=wsl gives me this:

Hit:1 https://repo.radeon.com/amdgpu/6.0.2/ubuntu jammy InRelease
Hit:2 http://archive.ubuntu.com/ubuntu jammy InRelease              
Hit:3 http://security.ubuntu.com/ubuntu jammy-security InRelease    
Get:4 https://dl.modular.com/public/installer/deb/ubuntu jammy InRelease [3672 B]
Hit:5 https://repo.radeon.com/rocm/apt/6.0.2 jammy InRelease                   
Hit:6 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:7 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Fetched 3672 B in 0s (8270 B/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package hsa-runtime-rocr4wsl-amdgpu

So the wsl option seems to be mapped to hsa-runtime-rocr4wsl-amdgpu. Do you think there's an error in the package name it's mapped to?

@Headcrabed
Copy link

I'm getting the same issue, is there a way to list all --usecase options? sudo amdgpu-install --list-usecase has an option for wsl:

wsl             (for using ROCm in a WSL context)
  - ROCr WSL runtime library (Ubuntu 22.04 only)

sudo amdgpu-install --usecase=wsl gives me this:

Hit:1 https://repo.radeon.com/amdgpu/6.0.2/ubuntu jammy InRelease
Hit:2 http://archive.ubuntu.com/ubuntu jammy InRelease              
Hit:3 http://security.ubuntu.com/ubuntu jammy-security InRelease    
Get:4 https://dl.modular.com/public/installer/deb/ubuntu jammy InRelease [3672 B]
Hit:5 https://repo.radeon.com/rocm/apt/6.0.2 jammy InRelease                   
Hit:6 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:7 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Fetched 3672 B in 0s (8270 B/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package hsa-runtime-rocr4wsl-amdgpu

So the wsl option seems to be mapped to hsa-runtime-rocr4wsl-amdgpu. Do you think there's an error in the package name it's mapped to?

Maybe it is just not ready for wsl yet, and will release in future versions?

@incense
Copy link

incense commented Apr 22, 2024

Same error with ROCm 6.1.
Opened an issue here: https://github.com/ROCm/ROCm/issues/3051

@unclemusclez
Copy link

where is this damn mythical hsa-runtime-rocr4wsl-amdgpu ???

@Headcrabed
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment