I follow the installation guide of cuda on wsl2. I’ve tried both options but I get similar error:
simon@LAPTOP-1DR6GGES:~$ sudo dpkg -i cuda-repo-wsl-ubuntu-11-7-local_11.7.0-1_amd64.deb
(Reading database ... 44224 files and directories currently installed.)
Preparing to unpack cuda-repo-wsl-ubuntu-11-7-local_11.7.0-1_amd64.deb ...
Unpacking cuda-repo-wsl-ubuntu-11-7-local (11.7.0-1) over (11.7.0-1) ...
Setting up cuda-repo-wsl-ubuntu-11-7-local (11.7.0-1) ...
The public CUDA GPG key does not appear to be installed.
To install the key, run this command:
sudo cp /var/cuda-repo-wsl-ubuntu-11-7-local/cuda-B81839D3-keyring.gpg /usr/share/keyrings/
When I run the suggested command, nothing changes. I get the same error.
My Ubuntu is 18.04.5 LTS downloaded from Microsoft Store on WSL2 platform, Windows10 Pro(20H2), 19042.1706. Cuda driver is successfully installed on Windows.
The post-installer is throwing this error because it expects the keyring to be in a different file. This should work:
# Save they key because we will swap it back after installing.
sudo mv /usr/share/keyrings/cuda-archive-keyring.gpg \
/usr/share/keyrings/cuda-archive-keyring.gpg.bak
sudo cp /var/cuda-repo-wsl-ubuntu-11-7-local/cuda-B81839D3-keyring.gpg \
/usr/share/keyrings/cuda-archive-keyring.gpg
sudo dpkg -i cuda-keyring_1.0-1_all.deb
sudo mv /usr/share/keyrings/cuda-archive-keyring.gpg.bak \
/usr/share/keyrings/cuda-archive-keyring.gpg
How I went about debugging this:
Enable script debug messages with sudo dpkg -D2 -i cuda-repo-wsl-ubuntu-11-7-local_11.7.0-1_amd64.deb
Process forks to run post install script right before the error message: D000002: fork/exec /var/lib/dpkg/info/cuda-repo-wsl-ubuntu-11-7-local.postinst ( configure 11.7.0-1 )
Inspect the post installer script (cat /var/lib/dpkg/info/cuda-repo-wsl-ubuntu-11-7-local.postinst)
Post installer script thinks that the B81839D3 key should be located at /usr/share/keyrings/cuda-archive-keyring.gpgnot/usr/share/keyrings/cuda-B81839D3-keyring.gpg.
There is an issue with the post-installer – it expects the key to be in a different file. This was the workaround I did:
# Save the key because we will swap it back after installing.
sudo mv /usr/share/keyrings/cuda-archive-keyring.gpg \
/usr/share/keyrings/cuda-archive-keyring.gpg.bak
# Move the key to the right location.
sudo cp /var/cuda-repo-wsl-ubuntu-11-7-local/cuda-B81839D3-keyring.gpg \
/usr/share/keyrings/cuda-archive-keyring.gpg
# Install.
sudo dpkg -i cuda-repo-wsl-ubuntu-11-7-local_11.7.0-1_amd64.deb
# Swap the old key back!
sudo mv /usr/share/keyrings/cuda-archive-keyring.gpg.bak \
/usr/share/keyrings/cuda-archive-keyring.gpg
How I went about debugging this:
Run dpkg with installer script debug output: sudo dpkg -D2 -i cuda-repo-wsl-ubuntu-11-7-local_11.7.0-1_amd64.deb
dpkg tells us that we fork to a process right before the error is thrown: D000002: fork/exec /var/lib/dpkg/info/cuda-repo-wsl-ubuntu-11-7-local.postinst ( configure 11.7.0-1 )
Look inside the post-install script: cat /var/lib/dpkg/info/cuda-repo-wsl-ubuntu-11-7-local.postinst
The post-install script expects that the B81839D3 key is in /usr/share/keyrings/cuda-archive-keyring.gpgnot/usr/share/keyrings/cuda-B81839D3-keyring.gpg
Thanks. I was tried to install cuDNN to ubuntu 20.04- cuda 11.7 and got this error message
I didn’t have cuda-archive-keyring.gpg so I didn’t need the backup.
I simply perform:
This one worked for me.
To check if it worked I first looked in the directories using “dir” to make sure the folder and files were matching what I had.