cancel
Showing results for 
Search instead for 
Did you mean: 

OpenCL

Exemplar
Exemplar

Guide to run OpenCL headless, without X server and as normal user

EDIT: this guide is no more relevant as from catalyst 14.12 omega it is supported to run OpenCL applications without Xserver. read discussion below.

You may know that you can run OpenCL program as root without Xserver. I found patch which enable running the OpenCL programs even without

Download catalyst driver. Then run


chmod +x amd-driver-installer-*-x86.x86_64.run


./amd-driver-installer-*-x86.x86_64.run --extract ./fglrx


cd fglrx




Open file common/lib/modules/fglrx/build_mod/firegl_public.c and find KCL_PosixSecurityCapCheck function.

modify this function to this


int ATI_API_CALL KCL_PosixSecurityCapCheck(KCL_ENUM_PosixSecurityCap cap)
{
    if(cap == KCL_SECURITY_CAP_GENERAL_SYS_ADMIN) {
        return 1;
    }

    if (cap >= KCL_SECURITY_CAP_NUM)
    {
        return 0;
    }

    return capable(KCL_MAP_PosixSecurityCap[cap]);
}




then run. change according to distro you use.


./ati-installer.sh 13.35.1005 --buildpkg Ubuntu/saucy


cd ..


sudo dpkg -i fglrx*.deb




reboot. now if you run clinfo it will still find only CPU. that is because there is no devices in /dev/ati/. If you run "sudo clinfo" once it will create them. after that you must change permission on them with "sudo chmod 666 /dev/ati/*" after this you can run any OpenCL program without Xserver running and as a normal user. To setup /dev/ati permission you can add upstart job. Place this script to /etc/init/opencl.conf


description "Set up /dev/ati/"



start on filesystem



script


    clinfo > /dev/null


    chmod 666 /dev/ati/*


end script




This can enable privilege escalation. Use on your own risk.

Thanks to lgeek/catalyst-test-compat-headless-opencl · GitHub

0 Kudos
Reply
18 Replies
Elite
Elite

Re: Guide to run OpenCL headless, without X server and as normal user

Good afternoon.

I have tried this with my laptop,

# lspci | grep 'VGA\|ATI'

00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)

01:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI] Mars [Radeon HD 8670A/8670M/8750M]

hoping to enable discrete AMD card for OpenCL (I cannot start X in ordinary way, the problem is described in Intel HD 4000 + AMD Radeon HD 8750M + Linux). I have installed driver with change as it is described, rebooted to the multiuser level, without X. But running clinfo as root leads to "Segmentation fault". With independently written OpenCLInfo I found that this is in the stage of clGetPlatformIDs.

Could you tell, what is wrong and how is it possible to fix this (if possible, of course)?

Thank you in advance,

Natalia

0 Kudos
Reply
Miniboss
Miniboss

Re: Guide to run OpenCL headless, without X server and as normal user

This does not seem to work anymore with the Omega drivers.

Exemplar
Exemplar

Re: Guide to run OpenCL headless, without X server and as normal user

With omega drivers it is not need to patch driver anymore. Just build packages as normally with --buildpkg option and install only fglrx-core_*.deb package. After restart you need to run clinfo as root once so it load devices in /dev/ati. You can use script from original post. After that you can run any OpenCL program as normal user without X server. Oh and there is bug that cause driver crash if it doesn't find "/etc/ati/amdpcsdb.default" file which is inside fglrx_*.deb package. So extract this file from fglrx package and put it into /etc/ati directory.

0 Kudos
Reply
Miniboss
Miniboss

Re: Guide to run OpenCL headless, without X server and as normal user

Are you sure? I just used the installer to install omega packages and as root I see 3 GPUs (1 integrated 2 discrete) but as normal user only the ones which are mentioned in xorg.conf are mentioned. Also when X is not running, user sees no GPUs.

I see

  Device OpenCL C version:     OpenCL C 2.0
  Driver version:     1642.5 (VM)

In the clinfo. So pretty sure that the driver is installed (also I installed it several times over itself, rebooted the machine etc. in between.

Yet, it just doesnt seem to be working? (on Linux)

0 Kudos
Reply
Exemplar
Exemplar

Re: Guide to run OpenCL headless, without X server and as normal user

I am sure. I have testing Ubuntu server installation. I installed only fglrx-core package and after initial "sudo clinfo" I can run OpenCL programs on GPU. It spit some error about permission but then it runs fine.

Miniboss
Miniboss

Re: Guide to run OpenCL headless, without X server and as normal user

Hmm, you seem to be correct. Thanks for the info. I have found out that I only see GPUs set in the X config when I export the COMPUTE=:0 env variable (the DISPLAY env variable seem to have no effect). EDIT: I meant the 3rd GPU does not appear when COMPUTE=:0 is set.

0 Kudos
Reply
Journeyman III
Journeyman III

Re: Guide to run OpenCL headless, without X server and as normal user

I also had issues getting it to work, but it turned out to be because the AMD APP SDK was installed on the machine, and LD_LIBRARY_PATH and OPENCL_VENDOR_PATH were set to point to that installation. When running with sudo, the environment variables were cleared (an effect of sudo), which made things work.

0 Kudos
Reply
Journeyman III
Journeyman III

Re: Guide to run OpenCL headless, without X server and as normal user

bmerry, your last sentence was confusing... the way it's written you are saying "sudo clearing the environmental variables made things work." Please clarify, did you end up using "sudo -E clinfo"?

0 Kudos
Reply
Journeyman III
Journeyman III

Re: Guide to run OpenCL headless, without X server and as normal user

I am running Ubuntu 12.04. I uninstalled my xserver-xorg packages (I am running a server).

I built the fglrx packages using:

./ati-installer.sh 14.501.1003 --buildpkg Ubuntu/precise

I extracted /etc/ati/amdpcsdb.default from fglrx_*.deb

I installed using:

dpkg -i fglrx-core_14.501-0ubuntu1_amd64.deb

I rebooted.

I can run /opt/AMDAPPSDK-3.0-0-Beta/bin/x86_64/clinfo as root, but it hangs for about 2 to 3 minutes, then spits out the AMD card and Intel processor information.

Then I do "chmod 666 /dev/ati/*"

When I run /opt/AMDAPPSDK-3.0-0-Beta/bin/x86_64/clinfo as a regular user, it likewise hangs for about 2 to 3 minutes, then spits out the AMD card and Intel processor information.

However, If I do "export COMPUTE=:0" as a regular user and run /opt/AMDAPPSDK-3.0-0-Beta/bin/x86_64/clinfo, there is no hang, BUT, the AMD card DOES NOT show up, only the Intel processor.


Any ideas on how to eliminate the hang or make the AMD card show up after "export COMPUTE=:0"


Thanks in advance,

Michael

0 Kudos
Reply