A quick guide: How to install OpenCL for AMD GPUs on Linux Kubuntu 18.04 (and similar distro)

cecht
cecht
Joined: 7 Mar 18
Posts: 1533
Credit: 2902425536
RAC: 2178229

koschi wrote:Any feedback is

koschi wrote:
Any feedback is welcome, I'd appreciate you reporting back in case it works or fails for you.

I got this error when I tried to install the OpenCL DEB package over the existing OpenCL (I was expecting to get a message that no new packages were installed):

$ sudo dpkg -i amdgpu-ocl_19.20-812932.deb
[sudo] password for craig:
(Reading database ... 206143 files and directories currently installed.)
Preparing to unpack amdgpu-ocl_19.20-812932.deb ...
Unpacking amdgpu-ocl (0.3-19.20.812932) ...
dpkg: error processing archive amdgpu-ocl_19.20-812932.deb (--install):
 trying to overwrite '/etc/OpenCL/vendors/amdocl-orca64.icd', which is also in package opencl-orca-amdgpu-pro-icd:amd64 19.20-812932
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 amdgpu-ocl_19.20-812932.deb


So does the DEB package only work if there is no OpenCL (or a different version) already present?

Ideas are not fixed, nor should they be; we live in model-dependent reality.

Matt White
Matt White
Joined: 9 Jul 19
Posts: 120
Credit: 280798376
RAC: 0

I've had mixed results trying

I've had mixed results trying to install one package over another. Sometimes it works, other times, not so much. My brief experience with Linux seems to suggest some driver packages (NVIDIA) behave better than others (AMD) when doing an overwrite install. Your mileage may vary. :)

I've come to learn one can get into the weeds quite quicky if not careful. :) This is one reason I haven't yet to put anything of importance on my linux box. Besides crunching, it is a testbed for me to get more familiar with linux. If I break it, it isn't the end of the world. 

Clear skies,
Matt
mikey
mikey
Joined: 22 Jan 05
Posts: 12682
Credit: 1839086786
RAC: 3830

Matt White wrote:I've had

Matt White wrote:

I've had mixed results trying to install one package over another. Sometimes it works, other times, not so much. My brief experience with Linux seems to suggest some driver packages (NVIDIA) behave better than others (AMD) when doing an overwrite install. Your mileage may vary. :)

I've come to learn one can get into the weeds quite quicky if not careful. :) This is one reason I haven't yet to put anything of importance on my linux box. Besides crunching, it is a testbed for me to get more familiar with linux. If I break it, it isn't the end of the world. 

And why I use 120gb SSD drives for my Linux installs, they are cheap so I have several and Linux loads really fast on them if I mess things up. If I mess one install up I just grab another drive and use it instead, then put the old one on the stack of okay to wipe drives and use net time.

Gary Roberts
Gary Roberts
Moderator
Joined: 9 Feb 05
Posts: 5872
Credit: 117570266612
RAC: 35263994

cecht wrote:I got this error

cecht wrote:
I got this error when I tried to install the OpenCL DEB package over the existing OpenCL (I was expecting to get a message that no new packages were installed):

But that (effectively) is exactly what you got :-).  dpkg refused to allow you potentially to bork your system :-).

Now I guess the authors of dpkg could have been a little bit more gentle and said something like :-

"Excuse me sir but I'm afraid I really shouldn't overwrite a component that you have already installed from a different package with a component of the same name from your new and, I'm sure, highly illustrious package.  Perhaps you'd like me to uninstall that old rubbish first?  Let me know what you decide as I'm here to serve."

The above, of course, is just my weird sense of humour.  Please don't take offense :-).  I did try really hard to resist though, but somehow, something just got the better of me ... :-)

The AMDGPU-PRO package comes with an uninstall option as part of the installation script.  Before trying to install the OpenCL functionality from a different package, you really should use the AMD script's uninstall option to go back to a "clean slate".

I know nothing about Ubuntu style distros, .deb packages, or the dpkg utility.  Also I haven't looked at the AMD supplied script in a long time so don't remember what safeguards are there to make sure you can't double-up on an install.  I'd be very surprised though, if that hasn't been properly taken care of.

If you study the AMD supplied script you should be able to work out what checks are made concerning the detection of already installed versions.  Any found may be noted and uninstalled before allowing a new install.  At least I would expect it to give some sort of warning if it detected a previous install.

Koschi's script seems to allow you to combine all the bits from a few different packages into a single package that doesn't carry any extra baggage with it.  Seeing as you have to download all the baggage anyway in order to make the single package, I don't see any particular advantage to doing that in preference to using the already downloaded full package with the --opencl=... and the --headless options to restrict what gets installed.

I guess the real reason for doing all this seems to be that by using a hack of renaming libraries and library functions (check out all the amdgpu -> amdgpo renaming going on) this somehow must allow you to work around which versions of Ubuntu are compatible with which versions of the OpenCL libs packages.  I haven't tried to properly understand how that all works because I don't have any such issues and have no intention of moving from what works really well for me just the way it is - no renaming hacks needed ;-).

So, just uninstall the AMD version of the OpenCL libs and then try again.  In future, if you want to try a version different to 19.20, you would need to make a new package and, before trying to install it, you should consult the dpkg man page for how to properly remove the 19.20 version.  As I mentioned before, I know nothing about dpkg and it's probably got lots of complicated options so be careful :-).

Cheers,
Gary.

cecht
cecht
Joined: 7 Mar 18
Posts: 1533
Credit: 2902425536
RAC: 2178229

Gary Roberts wrote:"Excuse me

Gary Roberts wrote:
"Excuse me sir but I'm afraid I really shouldn't overwrite a component that you have already installed from a different package with a component of the same name from your new and, I'm sure, highly illustrious package.  Perhaps you'd like me to uninstall that old rubbish first?  Let me know what you decide as I'm here to serve.":-)

Haha! Yes, I like that.  I think all command line programs should in include an --urbane option for making stderr and stdout more digestable for folks like me.

I've looked at the amdgpu-install script and I don't see where OpenCL components are pre-checked or removed, but then there are a few bits in the script that I can't quite follow. More cogitating is needed. All is working well now, however, so, right, if it ain't broke, don't fix it.

Ideas are not fixed, nor should they be; we live in model-dependent reality.

Gary Roberts
Gary Roberts
Moderator
Joined: 9 Feb 05
Posts: 5872
Credit: 117570266612
RAC: 35263994

cecht wrote:I've looked at

cecht wrote:
I've looked at the amdgpu-install script and I don't see where OpenCL components are pre-checked or removed, but ....

The script is hard work to decipher.  I first looked at it in 2017 (as it existed in the 16.60 version and again in the 17.50 version) and I've just refreshed my memory by looking at the 19.10 version since that's the latest package I've extracted the components from.  I wrote my install/uninstall script in 2017 out of frustration with trying to fully understand the constructs being used in the two early versions.  The 19.10 version has more in it but it seems like the basic logic is still much the same.  There's a lot of stuff I didn't really understand without a lot of hard work, and a week later I would forget what I'd previously worked out anyway :-).  I'm lazy and it was giving me a headache so I gave up trying :-).  It was much simpler and less stressful to write something I could understand :-).

Please don't try to learn bash scripting using any of these as examples, unless you have a lot of prior experience with much more straight forward scripting constructs and examples under your belt.  The gurus who write this stuff are obviously paid huge bonuses for making it as unintelligibly obscure and arcane as possible :-).

However you should note the two functions amdgpu_pro_install() and amdgpu_pro_uninstall().  The first line of the install function creates a symbolic link (the 'ln' command) to the install script and adds a -uninstall ending to the name.  It installs that soft link in /bin (which is guaranteed to be in your $PATH).  So that means if you use the script to install, at some later stage you can simply issue a standard amdgpu-uninstall command (or amdgpu-pro-uninstall, depending on exactly what you installed initially) and that command will run the script again as an uninstaller.  You should check to see if you have such a symbolic link in your /bin directory.  If so, that would be what you would use to uninstall the previous version.  Of course that link would disappear if you've ever reinstalled the OS without reinstalling OpenCL using the official AMD version of the script.  The symbolic link might point at nothing if you've deleted the package contents you previously downloaded.

For the Benefit of All Readers.

To get an overview of the purpose of all the components in the full package, please read all of this.  This documentation makes things really clear and I sure wish it had been around when I was trying to come to grips with the whole thing.

If you have a supported OS and you are using the amdgpu kernel module for your graphics and you just need to add the OpenCL compute capability to support Polaris or Vega GPUs (and also Sea Islands and Volcanic Islands GPUs that came before Polaris), the simplest thing to do is to download the full AMDGPU-PRO package (Radeon Software for Linux) for your supported distro and run the amdgpu-install script with the --headless and --opencl=pal,legacy options.

If you don't have a supported distro, it is quite possible to extract the components you need from a supported OS package and install them manually.  There are probably many unsupported distros where this has already been done by the packaging people for that distro.  Ask questions on the forums of that distro if you're not sure.

Cheers,
Gary.

koschi
koschi
Joined: 17 Mar 05
Posts: 86
Credit: 1688527555
RAC: 822565

Hi together! Sorry was kind

Hi together!

Sorry was kind of offline due to lack of internet after moving into a new flat Cry

My script was inspired by a package build script from arch Linux. Not being supported by the official driver, they had to extract the important OpenCL bits from the Ubuntu driver archive and use those on their machines. This also means that no AMD OpenCL is installed when the package created by my script is being installed. Otherwise there are of course conflicts, as files would belong to two packages, which is a problem.

I used the script few days back on a new Ubuntu 19.04 install with driver 19.30-855429, worked like a charm. I only  needed to install clinfo and boinc-client-opencl for BOINC to utilise the Vega56. 

 

cecht
cecht
Joined: 7 Mar 18
Posts: 1533
Credit: 2902425536
RAC: 2178229

As has happened to me, If you

As has happened to me,
If you have Ubuntu 18.04.3 or later or the Linux kernel 5.0.0020 or later, which provide open Mesa drivers for (most?) AMD cards...
And for whatever reason you just attempted manual installation of recent amdgpu drivers...
But upon reboot get a black login screen instead of your Desktop environment, then...
You probably don't need those amdgpu drivers (as most of this discussion addresses).
Therefore, from the black screen...
Hit F2 (or some other F key) to bring up the command line prompt for user login and...
Login with your regular login name and password.
Navigate to the amdgpu-pro package directory from which you previously attempted installation, i.e.
~$ cd /home/craig/amdgpu-pro-19.20-812932-ubuntu-18.04
And execute the following:
~$ amdgpu-pro-uninstall   #this actually can be done from any directory
~$ sudo apt autoremove
~$ ./amdgpu-pro-install --opencl=legacy --headless  #or --opencl=pal,legacy
~$ shutdown
...and restart the host.
You should now be booted into your regular Desktop, assuming autologin is enabled.
This sequence will remove the unnecessary and offending amdgpu driver packages and reinstall the necessary OpenCL components needed for GPU crunching. I think the failed Desktop login is only an Ubuntu issue.
I'm only running Polaris cards, so don't know how well this approach works with other AMD cards.

Ideas are not fixed, nor should they be; we live in model-dependent reality.

Matt White
Matt White
Joined: 9 Jul 19
Posts: 120
Credit: 280798376
RAC: 0

cecht wrote:As has happened

cecht wrote:
As has happened to me,
If you have Ubuntu 18.04.3 or later or the Linux kernel 5.0.0020 or later, which provide open Mesa drivers for (most?) AMD cards...
And for whatever reason you just attempted manual installation of recent amdgpu drivers...
But upon reboot get a black login screen instead of your Desktop environment, then...
You probably don't need those amdgpu drivers (as most of this discussion addresses).
Therefore, from the black screen...

I too have been down that rabbit hole.

Craig, my solution is on par with yours, the only difference being, I used the root CLI in the recovery mode. It kind of reminds me of my MSDOS or HDOS (RT-11) days, although with those OS's, I knew exactly what I was doing. :) Not so much with LINUX, which is why I printed and read the procedure several times before attempting it.

My first instructions to anyone I train to service my radio system (A Motorola Astro25 Digital Trunk Public Safety System) is: "You don't know, what you don't know. Assume nothing." That piece of advice has served me well throughout my career. :)

Clear skies,
Matt

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.