The new way of fixing this is by installing the Nvidia Container Toolkit as nvidia-docker is now deprecated.
Installation instructions here: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html#installation
One more thing, If you're running Docker Desktop and it does not pick up the new runtime even after install and running
sudo nvidia-ctk runtime configure --runtime=docker
- This command edits the config file used by the daemon
and then restarting docker, you have the option of manually adding the runtime via the settings in the GUI under Docker Engine
The config you need to append here is:
"runtimes": {
"nvidia": {
"args": [],
"path": "nvidia-container-runtime"
}
}