No sound device detected

I just installed Ubuntu 16.04 LTE on a new Lenovo E470 machine. No sound device is detected, I mean:

enter image description here

And similarly, no input device is detected. Some information that may be helpful: aplay -l returns

**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 3: HDMI 0 [HDMI 0]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Anyhow, an audio device exists: sudo lspci -vreturns (among other things)

00:1f.3 Audio device: Intel Corporation Device 9d71 (rev 21)
    Subsystem: Lenovo Device 505b
    Flags: bus master, fast devsel, latency 64, IRQ 16
    Memory at f4420000 (64-bit, non-prefetchable) [size=16K]
    Memory at f4410000 (64-bit, non-prefetchable) [size=64K]
    Capabilities: [50] Power Management version 3
    Capabilities: [60] MSI: Enable- Count=1/1 Maskable- 64bit+
    Kernel driver in use: snd_hda_intel
    Kernel modules: snd_hda_intel

I tried to force the reload of alsa: sudo alsa force-reload returns

Terminating processes: 10509 (failed: processes still using sound devices: 30977(pulseaudio)).
Unloading ALSA sound driver modules: snd-seq-midi snd-seq-midi-event snd-seq snd-rawmidi snd-seq-device snd-hda-codec-hdmi snd-hda-intel snd-hda-codec snd-hda-core snd-hwdep snd-pcm snd-timer (failed: modules still loaded: snd-hda-codec-hdmi snd-hda-intel snd-hda-codec snd-hda-core snd-hwdep snd-pcm snd-timer).
Loading ALSA sound driver modules: snd-seq-midi snd-seq-midi-event snd-seq snd-rawmidi snd-seq-device snd-hda-codec-hdmi snd-hda-intel snd-hda-codec snd-hda-core snd-hwdep snd-pcm snd-timer.

Listing sinks in pacmd: pacmd

Welcome to PulseAudio 8.0! Use "help" for usage information.
>>> list-sinks

1 sink(s) available.
  * index: 0
    name: <alsa_output.pci-0000_00_1f.3.hdmi-stereo>
    driver: <module-alsa-card.c>
    flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
    state: IDLE
    suspend cause: 
    priority: 9950
    volume: front-left: 53740 /  82% / -5.17 dB,   front-right: 53740 /  82% / -5.17 dB
            balance 0.00
    base volume: 65536 / 100% / 0.00 dB
    volume steps: 65537
    muted: no
    current latency: 370.83 ms
    max request: 64 KiB
    max rewind: 64 KiB
    monitor source: 0
    sample spec: s16le 2ch 44100Hz
    channel map: front-left,front-right
                 Stereo
    used by: 0
    linked by: 0
    configured latency: 371.52 ms; range is 0.50 .. 371.52 ms
    card: 0 <alsa_card.pci-0000_00_1f.3>
    module: 6
    properties:
        alsa.resolution_bits = "16"
        device.api = "alsa"
        device.class = "sound"
        alsa.class = "generic"
        alsa.subclass = "generic-mix"
        alsa.name = "HDMI 0"
        alsa.id = "HDMI 0"
        alsa.subdevice = "0"
        alsa.subdevice_name = "subdevice #0"
        alsa.device = "3"
        alsa.card = "0"
        alsa.card_name = "HDA Intel"
        alsa.long_card_name = "HDA Intel at 0xf4420000 irq 126"
        alsa.driver_name = "snd_hda_intel"
        device.bus_path = "pci-0000:00:1f.3"
        sysfs.path = "/devices/pci0000:00/0000:00:1f.3/sound/card0"
        device.bus = "pci"
        device.vendor.id = "8086"
        device.vendor.name = "Intel Corporation"
        device.product.id = "9d71"
        device.form_factor = "internal"
        device.string = "hdmi:0"
        device.buffering.buffer_size = "65536"
        device.buffering.fragment_size = "32768"
        device.access_mode = "mmap+timer"
        device.profile.name = "hdmi-stereo"
        device.profile.description = "Digital Stereo (HDMI)"
        device.description = "Built-in Audio Digital Stereo (HDMI)"
        alsa.mixer_name = "Intel Kabylake HDMI"
        alsa.components = "HDA:8086280b,17aa505b,00100000"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card-pci"
    ports:
        hdmi-output-0: HDMI / DisplayPort (priority 5900, latency offset 0 usec, available: no)
            properties:
                device.icon_name = "video-display"
    active port: <hdmi-output-0>

I should mention that I haven't been able to produce any sound on this machine beforehand.

Thank you in advance for your time, and please let me know if I can give some more useful information.


Solution 1:

I realized I forgot to try to troubleshoot pulseaudio, as was possibly suggested by the reaction to sudo alsa force-reload. According to the pulseaudio page, I run

rm -r ~/.config/pulse; pulseaudio -k

and I rebooted. Now it works! :)

Solution 2:

I had the same issue and it turned out because I was logged into gdm using root and pulseaudio does not start correctly in this case but if you run the following command it works correctly:

pulseaudio -D

Solution 3:

Increasing the number of inotify watches fixed this for me.

Following guidance at https://wiki.archlinux.org/index.php/PulseAudio/Troubleshooting#Daemon_startup_failed

pulseaudio -v gave an error:

E: [pulseaudio] module-udev-detect.c: You apparently ran out of inotify watches, probably because Tracker/Beagle took them all away. I wished people would do their homework first and fix inotify before using it for watching whole directory trees which is something the current inotify is certainly not useful for. Please make sure to drop the Tracker/Beagle guys a line complaining about their broken use of inotify.

Adding a line to etc/sysctl.conf fixed this:

fs.inotify.max_user_watches = 524288