Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
OpenCL on AMDGPU segfaults
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
dr_wulsen
Tux's lil' helper
Tux's lil' helper


Joined: 21 Aug 2013
Posts: 146
Location: Austria

PostPosted: Thu Oct 22, 2020 2:45 pm    Post subject: OpenCL on AMDGPU segfaults Reply with quote

Good evening,
I hope that someone smarter than me can guide me in the right direction.

OpenCL applications (darktable, darktable-cltest, clinfo) segfault. It can be 100% repeated.
Best example is darktable, which I can start without OpenCL, but with OpenCL it will not start and segfault.

My setup is:
Core i3 8350-K
AMD RX Vega 56 with x11-drivers/xf86-video-amdgpu
Gentoo default/linux/amd64/17.1/no-multilib (stable)
~amd64 keyword for the whole system.
Up-to-date per today
MATE desktop (which shouldn't matter here)

I've already tried:
  • Re-emerge dev-libs/rocm-comgr-3.8.0
    dev-libs/rocm-device-libs-3.8.0
    dev-libs/rocm-opencl-runtime-3.8.0
    dev-util/rocm-cmake-3.8.0
    dev-util/rocminfo-3.8.0
    sys-devel/llvm-roc-3.8.0
    only with CFLAGS="march=native -pipe -g" to produce a debug build.
  • Run gdb on darktable-cltest
    as it would give me the shortest but most informative output of above named commands.
  • Read half the internet and found a few issues on github, which looked promising, but unfortunately did not get me anywhere.
    a-repko says here that the issue could be fixed by downgrading ROCm to 3.5 or lower.
    However, I can't find any ebuild for that.

The output of my GDB session points me to sys-devel/llvm-roc
Code:
Thread 6 "Command Queue T" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe80dd640 (LWP 32626)]
0x00007ffff1bbc514 in ?? () from /usr/lib/llvm/roc/lib/liblldELF.so.11roc
Full paste is here: https://pastebin.com/u48w6WEQ
So I re-emerged llvm-roc with the debug flags as well, and without any optimizations to be safe. Nothing changed.
Strace gave me this output

So what I could see is, that in stdout, strace and gdb it always shows up similar to
LoadLib(libhsa-amd-aqlprofile64.so) failed: libhsa-amd-aqlprofile64.so: cannot open shared object file: No such file or directory
However, I got a copy of the library from here and installed it, the message disappeared, but the error remains the same.
I found out, that the message is just a debug info about optional tools/plugins not being available - but not the root of my problem, just some random noise.

rocminfo does not segfault, its output can be found here

Kernel options are set as the Gentoo wiki told me to do.

I've had an nvidia card for long years, just switched to AMD and I'm new to this ROCm thingy, but willing to learn.

My only use for it would be editing my RAW shots in darktable, so I can bypass OpenCL for the time being and since I'm a hobbyist, not a professional, I don't really have any drawbacks doing so.
However, my reason for using gentoo for more than 10 years already was and still is: My old machine has got potential, let's tap into it. And that's what I'd love to do here as well.

With little to no experience in AMD OpenCL runtimes, a walkthrough from the very beginning is pretty much what I need :D
Any feedback is welcome, any guidance appreciated
_________________
There's no stupid questions, only stupid answers.
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6920

PostPosted: Fri Oct 23, 2020 6:31 am    Post subject: Reply with quote

ROCm's extremely buggy garbage. Forget it for now and just use dev-libs/amdgpu-pro-opencl, it'll spare you all the weird intractible kernel hangs, slow corruptions and screen flicker.
Back to top
View user's profile Send private message
Chiitoo
Administrator
Administrator


Joined: 28 Feb 2010
Posts: 2551
Location: Here and Away Again

PostPosted: Sat Oct 24, 2020 7:39 pm    Post subject: Reply with quote

I've been meaning to create a topic about my OpenCL ventures for a time now, but before I do so, it will be interesting to know if 'dev-libs/amdgpu-pro-opencl' just works for you, dr_wulsen?

My device is probably enjoying a little less support than a Vega at this time, but it's kind of close, being Navi (RX 5700 XT).

I managed to get 'clinfo' to list stuff with 'media-libs/mesa[opencl]', but that's only OpenCL <2.0, and it wouldn't work anyblue (no surprises here really).

I finally got some output with ROCm as well (that is, 'clinfo' still works) after I enabled the kernel settings mentioned on the Gentoo OpenCL wiki page (not sure how I missed those in the past), but indeed, no joy with Blender:

Code:
mesa: CommandLine Error: Option 'help-list' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
Aborted

Curiously, I believe I saw 40 compute devices with mesa, but only 20 with ROCm.

Now for the third option, is there any magic needed with 'dev-libs/amdgpu-pro-opencl'?

All I get with it is the following:

Code:
Number of platforms                               1
  Platform Name                                   AMD Accelerated Parallel Processing
  Platform Vendor                                 Advanced Micro Devices, Inc.
  Platform Version                                OpenCL 2.1 AMD-APP (2906.7)
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_icd cl_amd_event_callback cl_amd_offline_devices
  Platform Host timer resolution                  1ns
  Platform Extensions function suffix             AMD

  Platform Name                                   AMD Accelerated Parallel Processing
Number of devices                                 0

NULL platform behavior
  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  No platform
  clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...)   No platform
  clCreateContext(NULL, ...) [default]            No platform
  clCreateContext(NULL, ...) [other]              No platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL)  No devices found in platform

I've seen some people post things around the internet about having OpenCL working with this card, so I know it's not impossible, but they tend to omit the details on /how/ (I imagine they're using the proprietary driver, which we don't have packaged at all).
_________________
Kindest of regardses.
Back to top
View user's profile Send private message
dr_wulsen
Tux's lil' helper
Tux's lil' helper


Joined: 21 Aug 2013
Posts: 146
Location: Austria

PostPosted: Sun Oct 25, 2020 9:58 am    Post subject: ...not working out as I hoped Reply with quote

@Ant P.
Thank you for your suggestion, I did try to use opencl-amdgpu-pro; but have not been able to get it up and running.
...which kind of answers the question of Chiitoo
Quote:
I've been meaning to create a topic about my OpenCL ventures for a time now, but before I do so, it will be interesting to know if 'dev-libs/amdgpu-pro-opencl' just works for you, dr_wulsen?
Unfortunately: no. I get the same output as you do
Code:
clinfo
Number of platforms                               1
  Platform Name                                   AMD Accelerated Parallel Processing
  Platform Vendor                                 Advanced Micro Devices, Inc.
  Platform Version                                OpenCL 2.1 AMD-APP (2906.7)
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_icd cl_amd_event_callback cl_amd_offline_devices
  Platform Host timer resolution                  1ns
  Platform Extensions function suffix             AMD

  Platform Name                                   AMD Accelerated Parallel Processing
Number of devices                                 0

NULL platform behavior
  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  AMD Accelerated Parallel Processing
  clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...)   ���]
  clCreateContext(NULL, ...) [default]            No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL)  No devices found in platform

ICD loader properties
  ICD loader Name                                 OpenCL ICD Loader
  ICD loader Vendor                               OCL Icd free software
  ICD loader Version                              2.2.12
  ICD loader Profile                              OpenCL 2.2
I've also tried with dev-libs/ocl-icd and dev-libs/opencl-icd-loader (for whatever their difference is, this OpenCL-Jungle is getting quite intransparent and frustrating. (Is there anything that just works about it?)

For your output of
Code:
mesa: CommandLine Error: Option 'help-list' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
Aborted
Could it be, that your mesa is compiled with [opencl] and this messes up between ROCm and mesa?
The wiki states, that mesa should be compiled with [-opencl] in this case....

I hope that we can get this to work, if there are any suggestions I'd be happy to try.
_________________
There's no stupid questions, only stupid answers.
Back to top
View user's profile Send private message
dr_wulsen
Tux's lil' helper
Tux's lil' helper


Joined: 21 Aug 2013
Posts: 146
Location: Austria

PostPosted: Sun Oct 25, 2020 11:59 am    Post subject: Reply with quote

...and somewhere on the forums, i read that a parallel install of llvm and llvm-roc messed up the start of libreoffice,
it may or may not he related - but mayve woth checking out.
_________________
There's no stupid questions, only stupid answers.
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6920

PostPosted: Sun Oct 25, 2020 2:49 pm    Post subject: Reply with quote

You might need to double-check your user has read-write access to /dev/kfd (group video), but I think that should be the default.

fwiw, I get a lot more output:
clinfo:
Number of platforms                               1
  Platform Name                                   AMD Accelerated Parallel Processing
  Platform Vendor                                 Advanced Micro Devices, Inc.
  Platform Version                                OpenCL 2.1 AMD-APP (2906.7)
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_icd cl_amd_event_callback cl_amd_offline_devices
  Platform Host timer resolution                  1ns
  Platform Extensions function suffix             AMD

  Platform Name                                   AMD Accelerated Parallel Processing
Number of devices                                 1
  Device Name                                     gfx804
  Device Vendor                                   Advanced Micro Devices, Inc.
  Device Vendor ID                                0x1002
  Device Version                                  OpenCL 1.2 AMD-APP (2906.7)
  Driver Version                                  2906.7
  Device OpenCL C Version                         OpenCL C 1.2
  Device Type                                     GPU
  Device Board Name (AMD)                         Radeon RX550/550 Series
[lots of consecutive nonblank lines snipped]
  printf() buffer size                            4194304 (4MiB)
  Built-in kernels                                (n/a)
  Device Extensions                               cl_khr_fp64 cl_amd_fp64 cl_khr_global_int32_base_atomics cl_khr_g
2_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_int64_base_atomics cl
_extended_atomics cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_fp16 cl_khr_gl_sharing cl_amd_device_
query cl_amd_vec3 cl_amd_printf cl_amd_media_ops cl_amd_media_ops2 cl_amd_popcnt cl_khr_image2d_from_buffer cl_amd_
sable_memory cl_khr_spir cl_khr_gl_event

NULL platform behavior
  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  No platform
  clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...)   No platform
  clCreateContext(NULL, ...) [default]            No platform
  clCreateContext(NULL, ...) [other]              Success [AMD]
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT)  Success (1)
    Platform Name                                 AMD Accelerated Parallel Processing
    Device Name                                   gfx804
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU)  Success (1)
    Platform Name                                 AMD Accelerated Parallel Processing
    Device Name                                   gfx804
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL)  Success (1)
    Platform Name                                 AMD Accelerated Parallel Processing
    Device Name                                   gfx804

I've got mesa[-opencl], opencl-icd-loader, and none of the rocm stuff installed. Having more than one at the same time confused it last time I tried.
Back to top
View user's profile Send private message
Chiitoo
Administrator
Administrator


Joined: 28 Feb 2010
Posts: 2551
Location: Here and Away Again

PostPosted: Mon Oct 26, 2020 8:34 pm    Post subject: Reply with quote

Yeah, I've read things regarding the ROCm/system-llvm conflict. Fun stuff, possibly making ROCm unusable for Blender at this time.

I've tried with and without 'opencl' enabled on mesa (currently 'mesa-9999' by the way, but have also tried with 20.2.1 and 'xf86-video-amdgpu-9999').

Also using 'dev-libs/opencl-icd-loader' here, though I've tried 'dev-libs/ocl-icd' in the not so distant past as well.

Hm, '/dev/kfd' looks okay:

Code:
crw-rw-rw- 1 root video 250, 0 Oct 24 20:28 /dev/kfd

I've always been bad at reading 'elog' (tend to miss them due to '--jobs' etc.):

dev-libs/amdgpu-pro-opencl-19.30.838629 wrote:
This package is now DEPRECATED on amd64 in favour of dev-libs/rocm-opencl-runtime.
Moreover, it only provides legacy AMDGPU-Pro OpenCL libraries which are not compatible with Vega 10 and newer GPUs.

Looks like the package doesn't have a maintainer currently, and support for Vega and Navi came in later on (not sure about the OpenCL status however).

I'm currently experimenting with version '20.40.1147286'. No luck yet after a quick ebuild update and install though.

See also: https://bugs.gentoo.org/706406
_________________
Kindest of regardses.
Back to top
View user's profile Send private message
Chiitoo
Administrator
Administrator


Joined: 28 Feb 2010
Posts: 2551
Location: Here and Away Again

PostPosted: Mon Oct 26, 2020 11:57 pm    Post subject: Reply with quote

Well I got 'dev-libs/amdgpu-pro-opencl' to work, I think.

Blender is quite unusable with it though, but that might be a known issue [1].

As the ebuild implies, it installs the files for legacy hardware, and I managed to use the upstream install script as a bit of a guide on what might be needed.

I don't have a clean ebuild for this yet, and I feel like I probably already put way too much time into it considering the card still doesn't work for rendering (random hangs and reboots are not helping, though that's not exactly new... but this is probably the first time I had so many within one day (I wonder if it's related to stressing the GPU in a specific way or something hmmm)).

Here's the current diff though, if anyone wants to play with it:

Code:
--- a/amdgpu-pro-opencl-19.30.838629.ebuild   2020-04-08 18:09:31.000000000 +0300
+++ b/amdgpu-pro-opencl-20.40.1147286.ebuild   2020-10-27 01:44:02.711984126 +0200
@@ -11,8 +11,8 @@
 MY_PV=$(ver_rs 2 '-')
 
 DESCRIPTION="Proprietary OpenCL implementation for AMD GPUs"
-HOMEPAGE="https://www.amd.com/en/support/kb/release-notes/rn-amdgpu-unified-navi-linux"
-SRC_URI="${SUPER_PN}-${MY_PV}-ubuntu-18.04.tar.xz"
+HOMEPAGE="https://www.amd.com/en/support/kb/release-notes/rn-amdgpu-unified-linux-20-40"
+SRC_URI="${SUPER_PN}-${MY_PV}-ubuntu-20.04.tar.xz"
 
 LICENSE="AMD-GPU-PRO-EULA"
 SLOT="0"
@@ -28,11 +28,11 @@
 
 QA_PREBUILT="/opt/amdgpu/lib*/*"
 
-S="${WORKDIR}/${SUPER_PN}-${MY_PV}-ubuntu-18.04"
+S="${WORKDIR}/${SUPER_PN}-${MY_PV}-ubuntu-20.04"
 
 pkg_nofetch() {
    local pkgver=$(ver_cut 1-2)
-   einfo "Please download Radeon Software for Linux version ${pkgver} for Ubuntu 18.04 from"
+   einfo "Please download Radeon Software for Linux version ${pkgver} for Ubuntu 20.04.1 from"
    einfo "    ${HOMEPAGE}"
    einfo "The archive should then be placed into your distfiles directory."
 }
@@ -48,15 +48,16 @@
 }
 
 multilib_src_unpack() {
-   local libdrm_ver="2.4.98"
+   local libdrm_ver="2.4.100"
    local patchlevel=$(ver_cut 3)
    local deb_abi
    [[ ${ABI} == x86 ]] && deb_abi=i386
 
    mkdir -p "${BUILD_DIR}" || die
    pushd "${BUILD_DIR}" >/dev/null || die
-   unpack_deb "${S}/opencl-orca-amdgpu-pro-icd_${MY_PV}_${deb_abi:-${ABI}}.deb"
-   unpack_deb "${S}/libdrm-amdgpu-amdgpu1_${libdrm_ver}-${patchlevel}_${deb_abi:-${ABI}}.deb"
+   unpack_deb "${S}/opencl-amdgpu-pro-icd_${MY_PV}_${deb_abi:-${ABI}}.deb"
+   unpack_deb "${S}/opencl-amdgpu-pro-comgr_${MY_PV}_${deb_abi:-${ABI}}.deb"
+   #unpack_deb "${S}/libdrm-amdgpu-amdgpu1_${libdrm_ver}-${patchlevel}_${deb_abi:-${ABI}}.deb"
    popd >/dev/null || die
 }
 
@@ -66,12 +67,12 @@
    [[ ${ABI} == amd64 ]] && dir_abi=x86_64-linux-gnu && short_abi=64
 
    into "/opt/amdgpu"
-   patchelf --set-rpath '$ORIGIN' "opt/${SUPER_PN}/lib/${dir_abi}"/libamdocl-orca${short_abi}.so || die "Failed to fix library rpath"
+   patchelf --set-rpath '$ORIGIN' "opt/${SUPER_PN}/lib/${dir_abi}"/libamdocl${short_abi}.so || die "Failed to fix library rpath"
    dolib.so "opt/${SUPER_PN}/lib/${dir_abi}"/*
-   dolib.so "opt/amdgpu/lib/${dir_abi}"/*
+   #dolib.so "opt/amdgpu/lib/${dir_abi}"/*
 
    insinto /etc/OpenCL/vendors
-   echo "/opt/amdgpu/$(get_libdir)/libamdocl-orca${short_abi}.so" \
+   echo "/opt/amdgpu/$(get_libdir)/libamdocl${short_abi}.so" \
       > "${T}/${SUPER_PN}-${ABI}.icd" || die "Failed to generate ICD file for ABI ${ABI}"
    doins "${T}/${SUPER_PN}-${ABI}.icd"
 }


This doesn't get things working quite yet, but as a quick test, I renamed 'libamd_comgr.so.1.7.0' to 'libamd_comgr.so.1' because I saw that was being looked for via 'strace', and after that things started happening.

I guess the ebuild should have some sort of USE-flags for installing things for legacy and/or non-legacy, since these files aren't exactly tiny.

1. https://developer.blender.org/T75319
_________________
Kindest of regardses.
Back to top
View user's profile Send private message
Reggae1
n00b
n00b


Joined: 23 Oct 2020
Posts: 1

PostPosted: Tue Oct 27, 2020 11:18 pm    Post subject: Rocm Reply with quote

Regarding the original post ( Rocm-3.8 ):
I can avoid the clinfo segfault by using the following trick: OCL_ICD_VENDORS=amdocl64.icd clinfo
With that clinfo doesn't crash, however, it doesn't detect any OpenCL devices for me (Ryzen 3700U APU with Vega 10 graphics)... Rocminfo works fine though. And Blender will crash just as clinfo does when trying to set it up for OpenCL... with the OCL_ICD... trick Blender will also run fine (i.e. not crash) but will not detect my hardware either. Really weird. I would think that Rocm only works for a very limited hardware combination and specific installation for that hardware. In other words nowhere near ready for general use... which is frustrating. :roll:
Back to top
View user's profile Send private message
leandrolnh
n00b
n00b


Joined: 28 Sep 2019
Posts: 20
Location: Brasil

PostPosted: Mon Jun 14, 2021 2:16 am    Post subject: Reply with quote

If anyone is still interested, I'm sharing my ebuild for Radeon Software for Linux 20.50, based off of Gentoo's ebuild and this script: https://gist.github.com/kytulendu/3351b5d0b4f947e19df36b1ea3c95cbe

It should work for PAL and ORCA, but for PAL it has only 64 bit.

Code:

amdgpu-pro-opencl-20.50.1234664.ebuild:

# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

MULTILIB_COMPAT=( abi_x86_{32,64} )

inherit unpacker multilib-minimal

SUPER_PN='amdgpu-pro'
MY_PV=$(ver_rs 2 '-')

DESCRIPTION="Proprietary OpenCL implementation for AMD GPUs"
HOMEPAGE="https://www.amd.com/en/support/kb/release-notes/rn-amdgpu-unified-linux-20-50"
SRC_URI="${SUPER_PN}-${MY_PV}-ubuntu-20.04.tar.xz"

LICENSE="AMD-GPU-PRO-EULA"
SLOT="0"
KEYWORDS="~amd64 ~x86"

RESTRICT="bindist mirror fetch strip"

BDEPEND="dev-util/patchelf"
COMMON="dev-libs/ocl-icd"
DEPEND="${COMMON}"
RDEPEND="${COMMON}
   !media-libs/mesa[opencl]
   >=x11-libs/libdrm-2.4.101"

QA_PREBUILT="/opt/amdgpu/lib*/*"

S="${WORKDIR}/${SUPER_PN}-${MY_PV}-ubuntu-20.04"

pkg_nofetch() {
   local pkgver=$(ver_cut 1-2)
   einfo "Please download Radeon Software for Linux version ${pkgver} for Ubuntu 20.04 from"
   einfo "    ${HOMEPAGE}"
   einfo "The archive should then be placed into your distfiles directory."
}

src_unpack() {
   default

   local ids_ver="1.0.0"
   local patchlevel=$(ver_cut 3)
   cd "${S}" || die
   unpack_deb "${S}/libdrm-amdgpu-common_${ids_ver}-${patchlevel}_all.deb"
   multilib_parallel_foreach_abi multilib_src_unpack
}

multilib_src_unpack() {
   local libdrm_ver="2.4.100"
   local comgr_ver="1.9.0"
   local libhsa_ver="1.2.0"
   local hsakmt_ver="1.0.9"
   local devlibs_ver="1.0.0"
   local patchlevel=$(ver_cut 3)
   local deb_abi
   [[ ${ABI} == x86 ]] && deb_abi=i386

   mkdir -p "${BUILD_DIR}" || die
   pushd "${BUILD_DIR}" >/dev/null || die
   unpack_deb "${S}/opencl-orca-amdgpu-pro-icd_${MY_PV}_${deb_abi:-${ABI}}.deb"
   unpack_deb "${S}/opencl-rocr-amdgpu-pro_${MY_PV}_${deb_abi:-${ABI}}.deb"
   unpack_deb "${S}/comgr-amdgpu-pro_${comgr_ver}-${patchlevel}_${deb_abi:-${ABI}}.deb"
   unpack_deb "${S}/hip-rocr-amdgpu-pro_${MY_PV}_${deb_abi:-${ABI}}.deb"
   unpack_deb "${S}/hsa-runtime-rocr-amdgpu_${libhsa_ver}-${patchlevel}_${deb_abi:-${ABI}}.deb"
   unpack_deb "${S}/hsakmt-roct-amdgpu_${hsakmt_ver}-${patchlevel}_${deb_abi:-${ABI}}.deb"
   unpack_deb "${S}/rocm-device-libs-amdgpu-pro_${devlibs_ver}-${patchlevel}_${deb_abi:-${ABI}}.deb"
   unpack_deb "${S}/libdrm-amdgpu-amdgpu1_${libdrm_ver}-${patchlevel}_${deb_abi:-${ABI}}.deb"
   popd >/dev/null || die
}

multilib_src_install() {
   local dir_abi short_abi
   [[ ${ABI} == x86 ]] && dir_abi=i386-linux-gnu && short_abi=32
   [[ ${ABI} == amd64 ]] && dir_abi=x86_64-linux-gnu && short_abi=64

   into "/opt/amdgpu"
   patchelf --set-rpath '$ORIGIN' "opt/${SUPER_PN}/lib/${dir_abi}"/libamdocl-orca${short_abi}.so || die "Failed to fix library rpath orca"
   patchelf --set-rpath '$ORIGIN' "opt/${SUPER_PN}/lib/${dir_abi}"/libamdocl${short_abi}.so || die "Failed to fix library rpath PAL"
   dolib.so "opt/${SUPER_PN}/lib/${dir_abi}"/*
   dolib.so "opt/amdgpu/lib/${dir_abi}"/*

   insinto /etc/OpenCL/vendors
   echo "/opt/amdgpu/$(get_libdir)/libamdocl-orca${short_abi}.so" \
      > "${T}/${SUPER_PN}-${ABI}-orca.icd" || die "Failed to generate ICD file for ABI ${ABI} orca"
   echo "/opt/amdgpu/$(get_libdir)/libamdocl${short_abi}.so" \
      > "${T}/${SUPER_PN}-${ABI}-pal.icd" || die "Failed to generate ICD file for ABI ${ABI} PAL"
   doins "${T}/${SUPER_PN}-${ABI}-orca.icd"
   doins "${T}/${SUPER_PN}-${ABI}-pal.icd"
}

multilib_src_install_all() {
   insinto "/opt/amdgpu"
   doins -r opt/amdgpu/share
}

pkg_postinst() {
   local pkgver=$(ver_cut 1-2)
   if [[ -z "${REPLACING_VERSIONS}" ]]; then
      ewarn "Please note that using proprietary OpenCL libraries together with the"
      ewarn "Open Source amdgpu stack is not officially supported by AMD. Do not ask them"
      ewarn "for support in case of problems with this package."
      ewarn ""
      ewarn "Furthermore, if you have the whole AMDGPU-Pro stack installed this package"
      ewarn "will almost certainly conflict with it. This might change once AMDGPU-Pro"
      ewarn "has become officially supported by Gentoo."
   fi

   elog ""
   elog "This package was modified form gentoo repo to fit ${pkgver} driver and includes PAL."
   elog ""

}
Back to top
View user's profile Send private message
Dr. Banana
n00b
n00b


Joined: 04 Aug 2021
Posts: 46

PostPosted: Fri Aug 06, 2021 2:28 pm    Post subject: Reply with quote

leandrolnh wrote:
If anyone is still interested, I'm sharing my ebuild for Radeon Software for Linux 20.50, based off of Gentoo's ebuild and this script: https://gist.github.com/kytulendu/3351b5d0b4f947e19df36b1ea3c95cbe

It should work for PAL and ORCA, but for PAL it has only 64 bit.

Code:

amdgpu-pro-opencl-20.50.1234664.ebuild:

# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

MULTILIB_COMPAT=( abi_x86_{32,64} )

inherit unpacker multilib-minimal

SUPER_PN='amdgpu-pro'
MY_PV=$(ver_rs 2 '-')

DESCRIPTION="Proprietary OpenCL implementation for AMD GPUs"
HOMEPAGE="https://www.amd.com/en/support/kb/release-notes/rn-amdgpu-unified-linux-20-50"
SRC_URI="${SUPER_PN}-${MY_PV}-ubuntu-20.04.tar.xz"

LICENSE="AMD-GPU-PRO-EULA"
SLOT="0"
KEYWORDS="~amd64 ~x86"

RESTRICT="bindist mirror fetch strip"

BDEPEND="dev-util/patchelf"
COMMON="dev-libs/ocl-icd"
DEPEND="${COMMON}"
RDEPEND="${COMMON}
   !media-libs/mesa[opencl]
   >=x11-libs/libdrm-2.4.101"

QA_PREBUILT="/opt/amdgpu/lib*/*"

S="${WORKDIR}/${SUPER_PN}-${MY_PV}-ubuntu-20.04"

pkg_nofetch() {
   local pkgver=$(ver_cut 1-2)
   einfo "Please download Radeon Software for Linux version ${pkgver} for Ubuntu 20.04 from"
   einfo "    ${HOMEPAGE}"
   einfo "The archive should then be placed into your distfiles directory."
}

src_unpack() {
   default

   local ids_ver="1.0.0"
   local patchlevel=$(ver_cut 3)
   cd "${S}" || die
   unpack_deb "${S}/libdrm-amdgpu-common_${ids_ver}-${patchlevel}_all.deb"
   multilib_parallel_foreach_abi multilib_src_unpack
}

multilib_src_unpack() {
   local libdrm_ver="2.4.100"
   local comgr_ver="1.9.0"
   local libhsa_ver="1.2.0"
   local hsakmt_ver="1.0.9"
   local devlibs_ver="1.0.0"
   local patchlevel=$(ver_cut 3)
   local deb_abi
   [[ ${ABI} == x86 ]] && deb_abi=i386

   mkdir -p "${BUILD_DIR}" || die
   pushd "${BUILD_DIR}" >/dev/null || die
   unpack_deb "${S}/opencl-orca-amdgpu-pro-icd_${MY_PV}_${deb_abi:-${ABI}}.deb"
   unpack_deb "${S}/opencl-rocr-amdgpu-pro_${MY_PV}_${deb_abi:-${ABI}}.deb"
   unpack_deb "${S}/comgr-amdgpu-pro_${comgr_ver}-${patchlevel}_${deb_abi:-${ABI}}.deb"
   unpack_deb "${S}/hip-rocr-amdgpu-pro_${MY_PV}_${deb_abi:-${ABI}}.deb"
   unpack_deb "${S}/hsa-runtime-rocr-amdgpu_${libhsa_ver}-${patchlevel}_${deb_abi:-${ABI}}.deb"
   unpack_deb "${S}/hsakmt-roct-amdgpu_${hsakmt_ver}-${patchlevel}_${deb_abi:-${ABI}}.deb"
   unpack_deb "${S}/rocm-device-libs-amdgpu-pro_${devlibs_ver}-${patchlevel}_${deb_abi:-${ABI}}.deb"
   unpack_deb "${S}/libdrm-amdgpu-amdgpu1_${libdrm_ver}-${patchlevel}_${deb_abi:-${ABI}}.deb"
   popd >/dev/null || die
}

multilib_src_install() {
   local dir_abi short_abi
   [[ ${ABI} == x86 ]] && dir_abi=i386-linux-gnu && short_abi=32
   [[ ${ABI} == amd64 ]] && dir_abi=x86_64-linux-gnu && short_abi=64

   into "/opt/amdgpu"
   patchelf --set-rpath '$ORIGIN' "opt/${SUPER_PN}/lib/${dir_abi}"/libamdocl-orca${short_abi}.so || die "Failed to fix library rpath orca"
   patchelf --set-rpath '$ORIGIN' "opt/${SUPER_PN}/lib/${dir_abi}"/libamdocl${short_abi}.so || die "Failed to fix library rpath PAL"
   dolib.so "opt/${SUPER_PN}/lib/${dir_abi}"/*
   dolib.so "opt/amdgpu/lib/${dir_abi}"/*

   insinto /etc/OpenCL/vendors
   echo "/opt/amdgpu/$(get_libdir)/libamdocl-orca${short_abi}.so" \
      > "${T}/${SUPER_PN}-${ABI}-orca.icd" || die "Failed to generate ICD file for ABI ${ABI} orca"
   echo "/opt/amdgpu/$(get_libdir)/libamdocl${short_abi}.so" \
      > "${T}/${SUPER_PN}-${ABI}-pal.icd" || die "Failed to generate ICD file for ABI ${ABI} PAL"
   doins "${T}/${SUPER_PN}-${ABI}-orca.icd"
   doins "${T}/${SUPER_PN}-${ABI}-pal.icd"
}

multilib_src_install_all() {
   insinto "/opt/amdgpu"
   doins -r opt/amdgpu/share
}

pkg_postinst() {
   local pkgver=$(ver_cut 1-2)
   if [[ -z "${REPLACING_VERSIONS}" ]]; then
      ewarn "Please note that using proprietary OpenCL libraries together with the"
      ewarn "Open Source amdgpu stack is not officially supported by AMD. Do not ask them"
      ewarn "for support in case of problems with this package."
      ewarn ""
      ewarn "Furthermore, if you have the whole AMDGPU-Pro stack installed this package"
      ewarn "will almost certainly conflict with it. This might change once AMDGPU-Pro"
      ewarn "has become officially supported by Gentoo."
   fi

   elog ""
   elog "This package was modified form gentoo repo to fit ${pkgver} driver and includes PAL."
   elog ""

}


Can you tell me how to install your ebuild? I was following the https://wiki.gentoo.org/wiki/Custom_ebuild_repository page and issuing
Code:
repoman manifest
spits out this error:

Code:
* ERROR: dev-libs/amdgpu-pro-opencl-20.50.1234664::localrepo failed (depend phase):
 *   External commands disallowed while sourcing ebuild: amdgpu-pro-opencl-20.50.1234664.ebuild:
 *
 * Call stack:
 *                                ebuild.sh, line 645:  Called source '/var/db/repos/localrepo/dev-libs/amdgpu-pro-opencl/amdgpu-pro-opencl-20.50.1234664.ebuild'
 *   amdgpu-pro-opencl-20.50.1234664.ebuild, line   1:  Called command_not_found_handle 'amdgpu-pro-opencl-20.50.1234664.ebuild:'
 *                                ebuild.sh, line  91:  Called die
 * The specific snippet of code:
 *         die "External commands disallowed while sourcing ebuild: ${*}"
 *
 * If you need support, post the output of `emerge --info '=dev-libs/amdgpu-pro-opencl-20.50.1234664::localrepo'`,
 * the complete build log and the output of `emerge -pqv '=dev-libs/amdgpu-pro-opencl-20.50.1234664::localrepo'`.
 * Working directory: '/usr/lib/python3.9/site-packages'
 * S: '/var/tmp/portage/dev-libs/amdgpu-pro-opencl-20.50.1234664/work/amdgpu-pro-opencl-20.50.1234664'
!!! getFetchMap(): aux_get() error reading dev-libs/amdgpu-pro-opencl-20.50.1234664; aborting.
!!! Unable to generate manifest for '/var/db/repos/localrepo/dev-libs/amdgpu-pro-opencl'.
  manifest.bad [fatal]          1
   dev-libs/amdgpu-pro-opencl/Manifest

_________________
Haters gonna hate,
Potatoes gonna potate.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21490

PostPosted: Fri Aug 06, 2021 4:20 pm    Post subject: Reply with quote

The posted ebuild is incorrect as written. As shown in the forum, its filename is written as the first line in the file. You copied that, so the first step of the ebuild is to try, unsuccessfully, to search for a command of the same name. Remove the file's name from the file.
Back to top
View user's profile Send private message
leandrolnh
n00b
n00b


Joined: 28 Sep 2019
Posts: 20
Location: Brasil

PostPosted: Fri Sep 17, 2021 8:45 pm    Post subject: Reply with quote

Hu wrote:
The posted ebuild is incorrect as written. As shown in the forum, its filename is written as the first line in the file. You copied that, so the first step of the ebuild is to try, unsuccessfully, to search for a command of the same name. Remove the file's name from the file.


Sorry for that, I should have made it explicit.

The following ebuild was updated to match Radeon Software for Linux 21.30:
Filename should be:
Code:
amdgpu-pro-opencl-21.30.1290604.ebuild

The ebuild content:
Code:
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

MULTILIB_COMPAT=( abi_x86_{32,64} )

inherit unpacker multilib-minimal

SUPER_PN='amdgpu-pro'
MY_PV=$(ver_rs 2 '-')

DESCRIPTION="Proprietary OpenCL implementation for AMD GPUs"
HOMEPAGE="https://www.amd.com/en/support/kb/release-notes/rn-amdgpu-unified-linux-21-30"
SRC_URI="${SUPER_PN}-${MY_PV}-ubuntu-20.04.tar.xz"

LICENSE="AMD-GPU-PRO-EULA"
SLOT="0"
KEYWORDS="~amd64 ~x86"

RESTRICT="bindist mirror fetch strip"

BDEPEND="dev-util/patchelf"
COMMON="dev-libs/ocl-icd"
DEPEND="${COMMON}"
RDEPEND="${COMMON}
   !media-libs/mesa[opencl]
   >=x11-libs/libdrm-2.4.106"

QA_PREBUILT="/opt/amdgpu/lib*/*"

S="${WORKDIR}/${SUPER_PN}-${MY_PV}-ubuntu-20.04"

pkg_nofetch() {
   local pkgver=$(ver_cut 1-2)
   einfo "Please download Radeon Software for Linux version ${pkgver} for Ubuntu 20.04 from"
   einfo "    ${HOMEPAGE}"
   einfo "The archive should then be placed into your distfiles directory."
}

src_unpack() {
   default

   local ids_ver="1.0.0"
   local patchlevel=$(ver_cut 3)
   cd "${S}" || die
   unpack_deb "${S}/libdrm-amdgpu-common_${ids_ver}-${patchlevel}_all.deb"
   multilib_parallel_foreach_abi multilib_src_unpack
}

multilib_src_unpack() {
   local comgr_ver="2.1.0"
   local libhsa_ver="1.3.0"
   local hsakmt_ver="1.0.9"
   local libdrm_ver="2.4.106"
   local devlibs_ver="1.0.0"
   local patchlevel=$(ver_cut 3)
   local deb_abi
   [[ ${ABI} == x86 ]] && deb_abi=i386

   mkdir -p "${BUILD_DIR}" || die
   pushd "${BUILD_DIR}" >/dev/null || die
   unpack_deb "${S}/comgr-amdgpu-pro_${comgr_ver}-${patchlevel}_${deb_abi:-${ABI}}.deb"
   unpack_deb "${S}/hip-rocr-amdgpu-pro_${MY_PV}_${deb_abi:-${ABI}}.deb"
   unpack_deb "${S}/hsa-runtime-rocr-amdgpu_${libhsa_ver}-${patchlevel}_${deb_abi:-${ABI}}.deb"
   unpack_deb "${S}/hsakmt-roct-amdgpu_${hsakmt_ver}-${patchlevel}_${deb_abi:-${ABI}}.deb"
   unpack_deb "${S}/libdrm-amdgpu-amdgpu1_${libdrm_ver}-${patchlevel}_${deb_abi:-${ABI}}.deb"
   unpack_deb "${S}/opencl-orca-amdgpu-pro-icd_${MY_PV}_${deb_abi:-${ABI}}.deb"
   unpack_deb "${S}/opencl-rocr-amdgpu-pro_${MY_PV}_${deb_abi:-${ABI}}.deb"
   unpack_deb "${S}/rocm-device-libs-amdgpu-pro_${devlibs_ver}-${patchlevel}_${deb_abi:-${ABI}}.deb"
   popd >/dev/null || die
}

multilib_src_install() {
   local dir_abi short_abi
   [[ ${ABI} == x86 ]] && dir_abi=i386-linux-gnu && short_abi=32
   [[ ${ABI} == amd64 ]] && dir_abi=x86_64-linux-gnu && short_abi=64

   into "/opt/amdgpu"
   patchelf --set-rpath '$ORIGIN' "opt/${SUPER_PN}/lib/${dir_abi}"/libamdocl-orca${short_abi}.so || die "Failed to fix library rpath orca"
   patchelf --set-rpath '$ORIGIN' "opt/${SUPER_PN}/lib/${dir_abi}"/libamdocl${short_abi}.so || die "Failed to fix library rpath PAL"
   dolib.so "opt/${SUPER_PN}/lib/${dir_abi}"/*
   dolib.so "opt/amdgpu/lib/${dir_abi}"/*

   insinto /etc/OpenCL/vendors
   echo "/opt/amdgpu/$(get_libdir)/libamdocl-orca${short_abi}.so" \
      > "${T}/${SUPER_PN}-${ABI}-orca.icd" || die "Failed to generate ICD file for ABI ${ABI} orca"
   echo "/opt/amdgpu/$(get_libdir)/libamdocl${short_abi}.so" \
      > "${T}/${SUPER_PN}-${ABI}-pal.icd" || die "Failed to generate ICD file for ABI ${ABI} PAL"
   doins "${T}/${SUPER_PN}-${ABI}-orca.icd"
   doins "${T}/${SUPER_PN}-${ABI}-pal.icd"
}

multilib_src_install_all() {
   insinto "/opt/amdgpu"
   doins -r opt/amdgpu/share
}

pkg_postinst() {
   local pkgver=$(ver_cut 1-2)
   if [[ -z "${REPLACING_VERSIONS}" ]]; then
      ewarn "Please note that using proprietary OpenCL libraries together with the"
      ewarn "Open Source amdgpu stack is not officially supported by AMD. Do not ask them"
      ewarn "for support in case of problems with this package."
      ewarn ""
      ewarn "Furthermore, if you have the whole AMDGPU-Pro stack installed this package"
      ewarn "will almost certainly conflict with it. This might change once AMDGPU-Pro"
      ewarn "has become officially supported by Gentoo."
   fi

   elog ""
   elog "This package was modified form gentoo repo to fit ${pkgver} driver and includes PAL."
   elog ""

}
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum