docker: unrecognized service when installing CUDA
Matthew Harrington
WSL2 Ubuntu 20.04.3 LTS kernel image: 5.10.60.1-microsoft-standard-WSL2
I am trying to install CUDA according to the instructions here:
And I am getting a docker: unrecognized service message when running command sudo service docker stop. I did follow the instructions up to the point where this command is in the tutorial, and the results of running sudo apt update && sudo apt install -y nvidia-docker2 seem successful. I've also tried to check if the docker service is available at all using service --status-all and didn't see it in the results.
Please help me figure out how to properly install CUDA, I am trying to set up opencv with GPU support for a project I am working on in image processing.
Here are the outputs from the mentioned commands I ran:
service --status-allOutput:
[ - ] apparmor [ ? ] apport [ - ] atd [ - ] console-setup.sh [ - ] cron [ ? ] cryptdisks [ ? ] cryptdisks-early [ - ] dbus [ ? ] hwclock.sh [ + ] irqbalance [ - ] iscsid [ - ] keyboard-setup.sh [ ? ] kmod [ - ] lvm2 [ - ] lvm2-lvmpolld [ - ] multipath-tools [ + ] open-iscsi [ - ] open-vm-tools [ ? ] plymouth [ ? ] plymouth-log [ - ] procps [ - ] rsync [ - ] rsyslog [ - ] screen-cleanup [ - ] ssh [ ? ] ubuntu-fan [ + ] udev [ - ] ufw [ - ] unattended-upgrades [ - ] uuidd [ - ] x11-commonCommand:
sudo apt update && sudo apt install -y nvidia-docker2Output:
Hit:1 focal InRelease
Hit:2 focal-updates InRelease
Hit:3 InRelease
Hit:4 focal-backports InRelease
Hit:5 InRelease
Hit:6 focal-security InRelease
Hit:7 InRelease
Hit:8 InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree
Reading state information... Done
nvidia-docker2 is already the newest version (2.8.0-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 2 1 Answer
I've been able to reproduce this using the (apparently outdated) Canonical instructions you linked.
You can see the problem in /var/log/apt/term.log during the installation of the docker.io package:
invoke-rc.d: unknown initscript, /etc/init.d/docker not found.That's the same init script that the service command attempts to run. Presumably, it was removed from the docker.io package sometime between the time the instructions were written (and presumably valid) and now. That's no surprise, really. Ubuntu uses Systemd, and the docker.io installs the Systemd unit file for the Docker service. Many packages used to also provide the legacy init script.
However, WSL doesn't support Systemd (without a lot of hackery, at least). It's much better to have a Docker version that provides an init script for the service command. Either that, or one that knows how to start on its own under WSL.
So let's start by uninstalling docker.io and the dependencies it installed:
sudo apt remove docker.io
sudo apt autoremoveThen you have two options. Either:
Install Docker Desktop for Windows. Docker Desktop has tight integration with WSL, and provides some nice-to-have features that you don't get with the open-source Docker version:
- It can be shared amongst multiple WSL2 instances
- It can run from PowerShell and CMD
- It provides a GUI dashboard of containers and volumes
- It handles automatic upgrades (although some might not consider that necessarily an advantage)
- It's a convenience method that handles all of the other stuff below automatically for you.
There has been a license change recently that requires a paid subscription if you are using it in a large company. Some folks seem to be wanting to move away from it as a result, but I would propose (purely my opinion) that if you work for a large company, they will often pay for these sorts of tools. And that, in turn, helps fund Docker's open-source initiatives.
However, if you do want to use the open-source edition, you can do that using (mostly) the official Docker instructions for Ubuntu.
Those instructions do assume that the installation script will start the Docker daemon. However, it attempts to use Systemd, which fails on WSL. But now it does provide the init.d script, so you can now run
sudo service docker startas you originally tried.Alternatively, nVidia provides setup instructions which use the
get.docker.comscript.