# opencl is not working

## loopdeloop

I am new to gentoo, and this forum helloooo

I have installed gentoo following the amd64 handbook. everything works properly but opencl. i was using opencl for mining on arch linux but after moving to gentoo i cant mine anymore. i tried ethminer and teamredminer so far. ethminer recognizes the card but crashes, teamredminer on the other hand doesnt even see the card saying "Failed to list OpenCL platforms."

```
ethminer 0.18.0

Build: linux/release/gnu

 i 16:01:59 ethminer Configured pool eu1.ethermine.org:4444

 i 16:01:59 ethminer Selected pool eu1.ethermine.org:4444

 i 16:01:59 ethminer Stratum mode : Eth-Proxy compatible

 i 16:01:59 ethminer Established connection to eu1.ethermine.org [172.65.207.106:4444]

 i 16:01:59 ethminer Spinning up miners...

cl 16:01:59 cl-0     OpenCL OpenCL 1.1 Mesa 20.2.6 not supported, but platform Clover might work nevertheless. USE AT OWN RISK!

cl 16:01:59 cl-0     Using PciId :  AMD Radeon RX 5700 (NAVI10, DRM 3.35.0, 5.4.97-gentoo, LLVM 11.0.1) OpenCL 1.1 Mesa 20.2.6 Memory : 8.00 GB

 i 16:01:59 ethminer Epoch : 399 Difficulty : 4.00 Gh

 i 16:01:59 ethminer Job: 08191eda… block 11998024 eu1.ethermine.org [172.65.207.106:4444]

cl 16:02:03 cl-0     Generating DAG + Light : 4.18 GB

cl 16:02:03 cl-0     OpenCL kernel

 X 16:02:03 cl-0     OpenCL kernel build log:

fatal error: cannot open file '/usr/share/clc/gfx1010-amdgcn-mesa-mesa3d.bc': No such file or directory

 X 16:02:03 cl-0     OpenCL kernel build error (-11):
```

i have a rx 5700, anybody here mining on gentoo? how did you do it?

I am currently trying to install amdgpu-pro-opencl and getting this on emerge:

```
These are the packages that would be merged, in order:

Calculating dependencies... done!

[ebuild  N F  ~] dev-libs/amdgpu-pro-opencl-20.40.1147286  ABI_X86="(64) -32"

Fetch instructions for dev-libs/amdgpu-pro-opencl-20.40.1147286:

 * Please download Radeon Software for Linux version 20.40 for Ubuntu 20.04.1 from

 *     https://www.amd.com/en/support/kb/release-notes/rn-amdgpu-unified-linux-20-40

 * The archive should then be placed into your distfiles directory.

Would you like to merge these packages? [Yes/No]

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) dev-libs/amdgpu-pro-opencl-20.40.1147286::gentoo

>>> Failed to emerge dev-libs/amdgpu-pro-opencl-20.40.1147286, Log file:

>>>  '/var/tmp/portage/dev-libs/amdgpu-pro-opencl-20.40.1147286/temp/build.log'

>>> Jobs: 0 of 1 complete, 1 failed                 Load avg: 3.8, 13.1, 17.0

!!! dev-libs/amdgpu-pro-opencl-20.40.1147286 has fetch restriction turned on.

!!! This probably means that this ebuild's files must be downloaded

!!! manually.  See the comments in the ebuild for more information.

 * Fetch failed for 'dev-libs/amdgpu-pro-opencl-20.40.1147286', Log file:

 *  '/var/tmp/portage/dev-libs/amdgpu-pro-opencl-20.40.1147286/temp/build.log'

 * Package:    dev-libs/amdgpu-pro-opencl-20.40.1147286

 * Repository: gentoo

 * USE:        abi_x86_64 amd64 elibc_glibc kernel_linux userland_GNU

 * FEATURES:   network-sandbox preserve-libs sandbox userpriv usersandbox

 * Please download Radeon Software for Linux version 20.40 for Ubuntu 20.04.1 from

 *     https://www.amd.com/en/support/kb/release-notes/rn-amdgpu-unified-linux-20-40

 * The archive should then be placed into your distfiles directory.

 * Messages for package dev-libs/amdgpu-pro-opencl-20.40.1147286:

 * Fetch failed for 'dev-libs/amdgpu-pro-opencl-20.40.1147286', Log file:

 *  '/var/tmp/portage/dev-libs/amdgpu-pro-opencl-20.40.1147286/temp/build.log'
```

I downloaded the driver from amd's website as the emerge said, but i couldnt figure out where to put it. i am kind of lost. any help would be appreciated

I also tried a new arch install after this which gave the same errors. i am quite frustrated right now lol

edit: also i did enable kernel parameters needed for opencl following its wiki page. clinfo gives correct info as well

----------

## DaggyStyle

put it in /usr/portage/distfiles

----------

## loopdeloop

 *DaggyStyle wrote:*   

> put it in /usr/portage/distfiles

 

thank you for the response, i placed the archive i downloaded to /usr/portage/distfiles as you said, it still didnt work. after some reading i pointed DISTDIR to the location on make.conf it still didnt work.

```
These are the packages that would be merged, in order:

Calculating dependencies... done!

[ebuild  N F  ~] dev-libs/amdgpu-pro-opencl-20.40.1147286  ABI_X86="(64) -32"

Fetch instructions for dev-libs/amdgpu-pro-opencl-20.40.1147286:

 * Please download Radeon Software for Linux version 20.40 for Ubuntu 20.04.1 from

 *     https://www.amd.com/en/support/kb/release-notes/rn-amdgpu-unified-linux-20-40

 * The archive should then be placed into your distfiles directory.

Would you like to merge these packages? [Yes/No]

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) dev-libs/amdgpu-pro-opencl-20.40.1147286::gentoo

>>> Failed to emerge dev-libs/amdgpu-pro-opencl-20.40.1147286, Log file:

>>>  '/var/tmp/portage/dev-libs/amdgpu-pro-opencl-20.40.1147286/temp/build.log'

>>> Jobs: 0 of 1 complete, 1 failed                 Load avg: 0.56, 0.96, 3.79

!!! dev-libs/amdgpu-pro-opencl-20.40.1147286 has fetch restriction turned on.

!!! This probably means that this ebuild's files must be downloaded

!!! manually.  See the comments in the ebuild for more information.

 * Fetch failed for 'dev-libs/amdgpu-pro-opencl-20.40.1147286', Log file:

 *  '/var/tmp/portage/dev-libs/amdgpu-pro-opencl-20.40.1147286/temp/build.log'

 * Package:    dev-libs/amdgpu-pro-opencl-20.40.1147286

 * Repository: gentoo

 * USE:        abi_x86_64 amd64 elibc_glibc kernel_linux userland_GNU

 * FEATURES:   network-sandbox preserve-libs sandbox userpriv usersandbox

 * Please download Radeon Software for Linux version 20.40 for Ubuntu 20.04.1 from

 *     https://www.amd.com/en/support/kb/release-notes/rn-amdgpu-unified-linux-20-40

 * The archive should then be placed into your distfiles directory.

 * Messages for package dev-libs/amdgpu-pro-opencl-20.40.1147286:

 * Fetch failed for 'dev-libs/amdgpu-pro-opencl-20.40.1147286', Log file:

 *  '/var/tmp/portage/dev-libs/amdgpu-pro-opencl-20.40.1147286/temp/build.log'
```

----------

## DaggyStyle

 *loopdeloop wrote:*   

>  *DaggyStyle wrote:*   put it in /usr/portage/distfiles 
> 
> thank you for the response, i placed the archive i downloaded to /usr/portage/distfiles as you said, it still didnt work. after some reading i pointed DISTDIR to the location on make.conf it still didnt work.
> 
> ```
> ...

 

can you please list the content of DISTDIR?

----------

## Hu

If you do not set DISTDIR in /etc/portage/make.conf, where does it default to for you?  Run emerge --info to see that and many other potentially useful things.  It might be best just to post here the output of emerge --info.  What is the output of namei -l /usr/portage/distfiles?

----------

## loopdeloop

 *Hu wrote:*   

> If you do not set DISTDIR in /etc/portage/make.conf, where does it default to for you?  Run emerge --info to see that and many other potentially useful things.  It might be best just to post here the output of emerge --info.  What is the output of namei -l /usr/portage/distfiles?

 

i managed to install it, i put it in /var/cache/distfiles without DISTDIR and it worked but even after i install amdgpu-pro-opencl miners still do not work. i am on arch again and it is the exact same problem. but if i install opencl-amd package from AUR it works just fine. opencl-amd is basically amdgpu-pro's opencl that works with amdgpu. so if this package were to exist on gentoo i think it would work.

opencl-amd https://aur.archlinux.org/packages/opencl-amd/

is there a way to port packages? lol

----------

## DaggyStyle

 *loopdeloop wrote:*   

>  *Hu wrote:*   If you do not set DISTDIR in /etc/portage/make.conf, where does it default to for you?  Run emerge --info to see that and many other potentially useful things.  It might be best just to post here the output of emerge --info.  What is the output of namei -l /usr/portage/distfiles? 
> 
> i managed to install it, i put it in /var/cache/distfiles without DISTDIR and it worked but even after i install amdgpu-pro-opencl miners still do not work. i am on arch again and it is the exact same problem. but if i install opencl-amd package from AUR it works just fine. opencl-amd is basically amdgpu-pro's opencl that works with amdgpu. so if this package were to exist on gentoo i think it would work.
> 
> opencl-amd https://aur.archlinux.org/packages/opencl-amd/
> ...

 

we don't know what does "not working" means. nor why AUR works, most probably versions. I'd suggest you look at the versions

----------

## loopdeloop

 *DaggyStyle wrote:*   

>  *loopdeloop wrote:*    *Hu wrote:*   If you do not set DISTDIR in /etc/portage/make.conf, where does it default to for you?  Run emerge --info to see that and many other potentially useful things.  It might be best just to post here the output of emerge --info.  What is the output of namei -l /usr/portage/distfiles? 
> 
> i managed to install it, i put it in /var/cache/distfiles without DISTDIR and it worked but even after i install amdgpu-pro-opencl miners still do not work. i am on arch again and it is the exact same problem. but if i install opencl-amd package from AUR it works just fine. opencl-amd is basically amdgpu-pro's opencl that works with amdgpu. so if this package were to exist on gentoo i think it would work.
> 
> opencl-amd https://aur.archlinux.org/packages/opencl-amd/
> ...

 

I guess i will compare both packages soon to see whats the difference. Could the reason of amdgpu-pro not working on gentoo because of the distro differences? amdgpu-pro is mainly for ubuntu. Would making a  package similar to the one in the AUR be too hard? if its feasible i might try.

----------

## DaggyStyle

 *loopdeloop wrote:*   

>  *DaggyStyle wrote:*    *loopdeloop wrote:*    *Hu wrote:*   If you do not set DISTDIR in /etc/portage/make.conf, where does it default to for you?  Run emerge --info to see that and many other potentially useful things.  It might be best just to post here the output of emerge --info.  What is the output of namei -l /usr/portage/distfiles? 
> 
> i managed to install it, i put it in /var/cache/distfiles without DISTDIR and it worked but even after i install amdgpu-pro-opencl miners still do not work. i am on arch again and it is the exact same problem. but if i install opencl-amd package from AUR it works just fine. opencl-amd is basically amdgpu-pro's opencl that works with amdgpu. so if this package were to exist on gentoo i think it would work.
> 
> opencl-amd https://aur.archlinux.org/packages/opencl-amd/
> ...

 

create a local repo (ask google how), cp the entire dev-libs/amdgpu-pro-opencl folder into the local repo, cp amdgpu-pro-opencl-20.40.1147286.ebuild to amdgpu-pro-opencl-20.45.1164792.ebuild, download amdgpu-pro-opencl-20.45.1164792 src into distfiles, digest it and try to emerge, maybe it will work.

----------

## ali3nx

afaik the amdgpu-pro-opencl package has been obsolete for several years and rocm-opencl-runtime is now preferred. 

Craig Andrews gentoo dev introduced and used to maintain the amdgpu-pro-opencl package before rocm-opencl-runtime was added to gentoo's main repo and emerging amdgpu-pro-opencl used to print a post emerge warning about the planned obsolescence of that package.

That mentioned rocm-opencl-runtime does work well but your pc motherboard must support pci express atomics capabilities or rocm opencl will refuse to function.

https://rocmdocs.amd.com/en/latest/Installation_Guide/More-about-how-ROCm-uses-PCIe-Atomics.html

There's an unlisted gentoo git overlay that offers some more insight into the state of rocm-opencl support for gentoo. I'm not aware of the significance or relevance of this git overlay but it has remained to be one of the more gentoo specific comprehensive sources of rocm-opencl information i've located.

https://github.com/justxi/rocm

----------

## Chiitoo

ROCm does not work too well, or at all, with the RX 5700 XT (Navi) though.  Not yet at least.

I don't know about mining (other than it being part of ruining the GPU market perhaps), but I did want to use OpenCL for Blendering and such.

Some possibly interesting reads:

https://forums.gentoo.org/viewtopic-t-1121939.html

https://bugs.gentoo.org/706406

https://wiki.gentoo.org/wiki/AMDGPU-PRO

https://github.com/RadeonOpenCompute/ROCm/issues/1106

https://github.com/RadeonOpenCompute/ROCm/issues/1210

----------

## loopdeloop

Okay i think i got it, amdgpu-pro-opencl package on gentoo repo is 20.40 while the one on the AUR (which works perfectly) is 20.45. i will try 20.45 on gentoo and return back the results. If it works i might try to maintain the package.

----------

## loopdeloop

 *DaggyStyle wrote:*   

>  *loopdeloop wrote:*    *DaggyStyle wrote:*    *loopdeloop wrote:*    *Hu wrote:*   If you do not set DISTDIR in /etc/portage/make.conf, where does it default to for you?  Run emerge --info to see that and many other potentially useful things.  It might be best just to post here the output of emerge --info.  What is the output of namei -l /usr/portage/distfiles? 
> 
> i managed to install it, i put it in /var/cache/distfiles without DISTDIR and it worked but even after i install amdgpu-pro-opencl miners still do not work. i am on arch again and it is the exact same problem. but if i install opencl-amd package from AUR it works just fine. opencl-amd is basically amdgpu-pro's opencl that works with amdgpu. so if this package were to exist on gentoo i think it would work.
> 
> opencl-amd https://aur.archlinux.org/packages/opencl-amd/
> ...

 

I actually tried that but it gives file length errors, so naturally i tried to write my own ebuild file. But i am kind of stuck here, the original ebuild file is kind of complex. So i am learning how to write ebuild files at the moment.

----------

## Zucca

 *Chiitoo wrote:*   

> ROCm does not work too well, or at all, with the RX 5700 XT (Navi) though.  Not yet at least.

 Before, if ever, the fix comes... How do we with older AMD GPUs can have OpenCL working? Mesa Clover?

----------

## loopdeloop

 *Zucca wrote:*   

>  *Chiitoo wrote:*   ROCm does not work too well, or at all, with the RX 5700 XT (Navi) though.  Not yet at least. Before, if ever, the fix comes... How do we with older AMD GPUs can have OpenCL working? Mesa Clover?

 

its not just old gpus, my rx 5700 which counts as a recent card i assume doesnt work with rocm and mesa clover. clinfo shows correct info but it just doesnt work. that is why i am trying to get latest version of amdgpu-pro's proprietary opencl to work. So long story short none of the opencl solutions on official repos work on my rx 5700.

----------

## Zucca

 *loopdeloop wrote:*   

> that is why i am trying to get latest version of amdgpu-pro's proprietary opencl to work.

 That's what I've been using. I tried clover once and I got it working, but since it's so limited it barely could do anything.

amdgpu-pro-opencl did only pull the opencl libraries out of the package. So it was a hack (using FOSS driver but closed-source OpenCL libs). But it worked.

I have R9 Nano (Fury). So it's an older GPU already. But its power for rendering work is still pretty OK.

I surely won't do any hardware upgrades until I get OpenCL working again.

----------

## DaggyStyle

 *loopdeloop wrote:*   

>  *DaggyStyle wrote:*    *loopdeloop wrote:*    *DaggyStyle wrote:*    *loopdeloop wrote:*    *Hu wrote:*   If you do not set DISTDIR in /etc/portage/make.conf, where does it default to for you?  Run emerge --info to see that and many other potentially useful things.  It might be best just to post here the output of emerge --info.  What is the output of namei -l /usr/portage/distfiles? 
> 
> i managed to install it, i put it in /var/cache/distfiles without DISTDIR and it worked but even after i install amdgpu-pro-opencl miners still do not work. i am on arch again and it is the exact same problem. but if i install opencl-amd package from AUR it works just fine. opencl-amd is basically amdgpu-pro's opencl that works with amdgpu. so if this package were to exist on gentoo i think it would work.
> 
> opencl-amd https://aur.archlinux.org/packages/opencl-amd/
> ...

 

such as? maybe we can help you fix them

----------

## NeddySeagoon

The ebuild has its own topic.

How to install custom ebuild files?

----------

## loopdeloop

Update: 20.45 does the exact same thing as 20.40 they both do not work. so it is not about versions but i dont think it is over yet. i think i will try doing all the steps in this AUR package manually https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=opencl-amd which might totally mess up my system but i took a full backup so i am fine.

----------

## Zucca

I remember I had to do few things manually to get OpenCL working with amdgpu-pro-opencl.

I think I could write an updated ebuild... I have little time tomorrow, so I can look into this while I have time.

----------

## Chiitoo

 *Zucca wrote:*   

>  *Chiitoo wrote:*   ROCm does not work too well, or at all, with the RX 5700 XT (Navi) though.  Not yet at least. Before, if ever, the fix comes... How do we with older AMD GPUs can have OpenCL working? Mesa Clover?

 

That or 'amdgpu-pro-opencl', yeah, as far as I know.  Those + ROCm are the three I have been testing.

 *loopdeloop wrote:*   

> Okay i think i got it, amdgpu-pro-opencl package on gentoo repo is 20.40 while the one on the AUR (which works perfectly) is 20.45. i will try 20.45 on gentoo and return back the results. If it works i might try to maintain the package.

 

It did "work" for me at '20.40.1147286' as you may or may not have seen in the topic I linked to earlier.

One of the problems with the current official ebuilds is that they only use the "legacy" files which don't work with Navi.

See for example post 8520866 for a diff and more.

----------

## Slaviusz

I'm fighting with this problem for quite a while. I used Arch when I decided to migrate (back) to Gentoo after some years. I wanted to run Blender so I emerged the ROCm drivers, tested clinfo output, successfully bencharked hashcat on GPU but Blender would start crashing. After filling the bug report with blender devs they told me ROCm is not supported with Blender and I need to use the proprietary amdgpu-pro driver. So I have emerged the latest driver but clinfo shows no cards as well as Blender.

I even wrote my own ebuild to install 21.30 drivers for Ubunto 20.04 but the same result, clinfo shows 0 devices. I tried to strace the clinfo command, it reads the amdgpu-pro config files, loads the .so files, reads device infos in /sys/devices/, tries a buch of ioctls and thend just dumps "Number of devices    0".

I have no idea how to debug this any further, I'd appriciate any help. I'm running quite recent stuff, custom built 5.14 kernel with lots of stuff disabled (though I followed all AMDGPU kernel config advices in Gentoo handbook) and latest mesa (without opencl as it breaks emerging amdgpu-pro).

----------

## jmponce

same problem here with a 5700XT

in archlinux 0 problems

----------

## ali3nx

 *jmponce wrote:*   

> same problem here with a 5700XT
> 
> in archlinux 0 problems

 

Since it appears you've encountered this post offering some disheartening results I can offer that i've recently tested rocm-opencl-runtime-5.x and it now works with some gpu cards if your motherboard pcie slots do not support pcie atomics. 

to use rocm-opencl-runtime the opencl use flag must not be enabled globally or package specific.

I can confirm I've successfully used hashcat with a 5500xt and linux native amdgpu using a supermicro ivy bridge xeon server motherboard. If you have a newer motherboard the pcie atomic support requirement may never have been or may never be a concern.

Attempting to use old amdgpu-pro-opencl driver package will certainly provide very little to nothing of merit.

----------

## Goverp

If PCIe atomics might be an issue, it's worth noting that some motherboards have one PCIe slot that supports atomics and one that doesn't.  In my ASUS XT570 the one that supports it (them?) means the graphics card overlaps a cooling fan, so it's not the one you choose by default!

----------

