Skip to content

clinfo segfaults with AMD ROCm OpenCL stuff installed #97311

Closed

Description

Describe the bug
Installing opencl stuff for AMD:

hardware.opengl.extraPackages = [
  rocm-opencl-icd
  rocm-runtime-ext
];

and running clinfo results in a segfault.

To Reproduce
Steps to reproduce the behavior:

  1. Have a AMD GPU (I have Radeon VII)
  2. Follow the steps here for AMD: https://hydra.nixos.org/build/124333142/download/2/nixos/index.html#sec-gpu-accel (rocm-runtime instead of rocm-runtime-ext since it was removed)
  3. sudo nixos-rebuild switch
  4. clinfo
  5. segfault

Expected behavior
clinfo should not segfault

Notify maintainers

@danieldk

Metadata

  • system: "x86_64-linux"
  • host os: Linux 5.4.60, NixOS, 20.03.20200822.ebf5991 (Markhor)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.4pre20200721_ff314f1
  • channels(root): "nixos-20.03.2668.7c85b915892, nixpkgs"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:

Activity

  1. ghost added
    0.kind: bug
    on Sep 6, 2020
  2. danieldk commented on Sep 7, 2020

    @danieldk
    Contributor

    Thanks for your bug report!

    Odd, works here on a Radeon VII:

    % result/bin/clinfo | grep "Device Name" | head -n1
      Device Name                                     gfx906
    

    Could you give the output of?

    $ ldd `which clinfo`
    $ ldd `cat /run/opengl-driver/etc/OpenCL/vendors/amdocl64.icd`
    

    Also, it would be useful to get a backtrace of the segmentation fault:

    $ gdb clinfo
    run
    bt
    
  3. danieldk commented on Sep 7, 2020

    @danieldk
    Contributor
    * channels(root): `"nixos-20.03.2668.7c85b915892, nixpkgs"`
    

    I see that you are running release 20.03. So, I should ask in addition if you are mixing packages from different nixpkgs revisions. Because e.g. using clinfo from NixOS 20.03 with ROCm from unstable will not work. The OpenCL ICD mechanism relies on dlopen()ing libraries and this does not work well when there is a mixture of e.g. glibc versions.

  4. danieldk commented on Sep 7, 2020

    @danieldk
    Contributor
    libc.so.6 => /nix/store/bqbg6hb2jsl3kvf6jgmgfdqy06fpjrrn-glibc-2.30/lib/libc.so.6 (0x00007f4909183000)
    [...]
    libpthread.so.0 => /nix/store/2pi6zgkwnr3zdslvlv16nixpzvbyjx1n-glibc-2.31/lib/libpthread.so.0 (0x00007fb7c8d43000)
    

    Thanks! This is where it blows up, the ICD loader mechanism is built against a different version of glibc than the OpenCL runtime.

    When the ICD library is loaded, it dynamically links against glibc 2.30. The ICD loader then dlopens the ROCm OpenCL runtime which results in loading libpthread from glibc 2.31. However, libpthread is tightly coupled to glibc and uses private symbols, so it fails with the older glibc.

    This is something that is never going to work well in general, because the ROCm OpenCL runtime (or one of its dependencies) may also depend on symbols that are not available in older glibc versions.

    To make things work correctly, the vendor-specific OpenCL runtime and the ICD loader should always be from the same nixpkgs revision.

    This issue is has also recently been added to the NixOS manual:

    https://hydra.nixos.org/build/126561910/download/2/nixos/index.html#sec-gpu-accel-common-issues

  5. ghost closed this as completedon Sep 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions