How to setup OpenCL on AMD videocard with opensource driver? - opencl

I have read this link - https://wiki.debian.org/ru/AtiHowTo
and decide to setup OpenCL.
the r600g driver still have to load proprietary microcode into the GPU
to enable hardware acceleration. This firmware is usually included in
the kernel, but is packaged separately in Debian.
So, I installed firmware:
# apt-show-versions firmware-linux-nonfree firmware-linux
firmware-linux-nonfree:all/sid 0.40 uptodate
firmware-linux:all/sid 0.40 uptodate
Then I upgrade kernel version:
uname -v
#1 SMP PREEMPT RT Debian 3.12.8-1 (2014-01-19)
and checked kernel flags:
grep DRM_RADEON /boot/config-$(uname -r)
CONFIG_DRM_RADEON=m
# CONFIG_DRM_RADEON_UMS is not set
grep AGP /boot/config-$(uname -r)
CONFIG_AGP=y
CONFIG_AGP_AMD64=y
CONFIG_AGP_INTEL=y
CONFIG_AGP_SIS=y
CONFIG_AGP_VIA=y
Also I setup xserver version recent enough:
# apt-show-versions xorg
xorg:amd64/sid 1:7.7+5 uptodate
I choose radeon as driver:
You most certainly are using wheezy's xserver-xorg-core which does not
provide xorg-video-abi-6.0 any more, and radeonhd is not available for
the newer xorg-video-abi because it has been removed from Debian
# apt-show-versions xserver-xorg-video-radeon
xserver-xorg-video-radeon:amd64/sid 1:7.3.0-1 uptodate
This gives me OpenGL working:
$ glxinfo | grep OpenGL
OpenGL vendor string: X.Org
OpenGL renderer string: Gallium 0.4 on AMD RV770
OpenGL core profile version string: 3.1 (Core Profile) Mesa 10.1.0-devel (git-81144c0 saucy-oibaf-ppa+curaga)
OpenGL core profile shading language version string: 1.40
OpenGL core profile context flags: (none)
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 10.1.0-devel (git-81144c0 saucy-oibaf-ppa+curaga)
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
I am trying to use application which works with OpenCL.
This programs works ok on CPU:
$ mono scallion/bin/Debug/scallion.exe parallax
Cooking up some delicions scallions...
Putting 1 patterns into 1 buckets.
Using kernel optimized from file kernel.cl (Optimized4)
Using work group size 1
Compiling kernel... done.
LoopIteration:10 HashCount:167.77MH Speed:7.8MH/s Runtime:00:00:21
Predicted:19:38:20
Stopping and shutting down...
LoopIteration:11 HashCount:184.55MH Speed:7.8MH/s Runtime:00:00:23
Predicted:19:36:58 init: 2687ms / 1 (2687ms, 0.37/s)
generate key: 153ms / 6 (25.5ms, 39.22/s)
cpu precompute: 7ms / 6 (1.17ms, 857.14/s)
total without init: 23706ms / 1 (23706ms, 0.04/s)
set buffers: 0ms / 11 (0ms, 0/s)
write buffers: 0ms / 11 (0ms, 0/s)
read results: 23699ms / 11 (2154.45ms, 0.46/s)
check results: 0ms / 11 (0ms, 0/s)
7.78 million hashes per second
Stopping and shutting down...
But I am unable to detect GPU:
$ mono scallion/bin/Debug/scallion.exe
Usage: scallion [OPTIONS]+ regex [regex]+
Options:
-l, --listdevices Lists the devices that can be used.
-d, --device=VALUE Specifies the opencl device that should be used.
There is no GPU in the list of devices:
$ mono scallion/bin/Debug/scallion.exe -l
Id:0 Name:Intel(R) Core(TM)2 Quad CPU Q9650 # 3.00GHz
PreferredGroupSizeMultiple:1 ComputeUnits:4 ClockFrequency:2000
MaxConstantBufferSize:65536 MaxConstantArgs:8 MaxMemAllocSize:2147483648
I am unable to find instructions on how to setup OpenCL:
apt-get install libclc-r600
apt-show-versions libclc-r600 ocl-icd-libopencl1
libclc-r600:all/saucy 0~git20140101-1~gd~s uptodate
ocl-icd-libopencl1:amd64/sid 2.1.3-2 uptodate
and after starting application I receive an error:
~/github.com/lachesis/scallion$ mono ./scallion/bin/Debug/scallion.exe -l
Unhandled Exception:
System.InvalidOperationException: ErrorCode:'-1001'
at scallion.CLDeviceInfo.CheckError (Int32 err) [0x00000] in :0
at scallion.CLDeviceInfo.GetPlatformIds () [0x00000] in :0
at scallion.CLDeviceInfo.GetDeviceIds () [0x00000] in :0
at scallion.CLRuntime.GetDevices () [0x00000] in :0
at scallion.Program.ListDevices () [0x00000] in :0
at scallion.Program.Main (System.String[] args) [0x00000] in :0
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException:
ErrorCode:'-1001'
at scallion.CLDeviceInfo.CheckError (Int32 err) [0x00000] in :0
at scallion.CLDeviceInfo.GetPlatformIds () [0x00000] in :0
at scallion.CLDeviceInfo.GetDeviceIds () [0x00000] in :0
at scallion.CLRuntime.GetDevices () [0x00000] in :0
at scallion.Program.ListDevices () [0x00000] in :0
at scallion.Program.Main (System.String[] args) [0x00000] in :0
The error code values are defined in opencl.h
It look like your platform is not configured properly.
CL_PLATFORM_NOT_FOUND_KHR (-1001) error from clGetPlatformIDs.
That's because you do have the dispatcher, but no actual OpenCL drivers."
After
sudo apt-get install libopencl1-mesa
$ find / -iname «libMesaOpenCL.so*» 2>/dev/null
/usr/lib/x86_64-linux-gnu/libMesaOpenCL.so
/usr/lib/x86_64-linux-gnu/libMesaOpenCL.so.1.0.0
/usr/lib/x86_64-linux-gnu/libMesaOpenCL.so.1
In configuration file there should be
cat /etc/OpenCL/vendors/mesa.icd
libMesaOpenCL.so
The error is
fatal error: cannot open file '/usr/lib/clc/rv770-r600--.bc': No such file or directory
How to make this work?

I eventually enabled the free OpenCL stack, and ran into very similar problems. I'll provide an abridged overview, of some of the relevant packages.
That libopencl1-mesa is just the ICD runtime, which is loaded into the generic ocl-icd-libopencl1. Then libclc is used by libopencl1-mesa to deal with the OpenCL Kernels. Using an LLVM chipset specific backend, libclc generates instructions. You're missing the GPU chipset specific glue, which is provided by the missing .bc. This is greatly simplified, but for this problem it should suffice, still a good diagram would help immensely.
In your particular example, the .bc's would be provided by libclc-r600 However I'm not seeing anything for your chipset 'DONE', on this Freedesktop.org GalliumCompute page. It appears the lowest supported chipset is the Evergreen (HD5000 Series).
* please recheck GalliumCompute if you read this after 02-04-2014.

Not sure if 'nonfree' drivers are opensource.
Then, if you look at:
OpenGL renderer string: Gallium 0.4 on AMD RV770
Looks like Gallium LLVM is used to render (not native GPU), so no guarantee, that OpenGL is accelerated by GPU. Anyway, if you use nonfree drivers, my advice is to download most recent drivers from AMD site & use them instead of currently installed.
Also, recent AMD APP SDK (from 2.8 on, if memory serves me right) is shipped apart from GPU driver, so you may try to use it instead of open package. It works at least on Ubuntu 12.04 (AMD drivers from repository + AMD APP SDK from AMD's site)

Related

DllNotFoundException using SkiaSharp 1.68 on Linux

Using SkiaSharp 1.68.0 with .NET Core 2.2 on Linux and get this error when trying to use Decode on a jpeg-memory-stream (same code works on Windows):
System.TypeInitializationException: The type initializer for 'SkiaSharp.SKAbstractManagedStream' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'libSkiaSharp' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibSkiaSharp: cannot open shared object file: No such file or directory
at SkiaSharp.SkiaApi.sk_managedstream_set_delegates(IntPtr pRead, IntPtr pPeek, IntPtr pIsAtEnd, IntPtr pHasPosition, IntPtr pHasLength, IntPtr pRewind, IntPtr pGetPosition, IntPtr pSeek, IntPtr pMove, IntPtr pGetLength, IntPtr pCreateNew, IntPtr pDestroy)
at SkiaSharp.SKAbstractManagedStream..cctor()
--- End of inner exception stack trace ---
at SkiaSharp.SKAbstractManagedStream..ctor(Boolean owns)
at SkiaSharp.SKManagedStream..ctor(Stream managedStream, Boolean disposeManagedStream, Boolean owns)
at SkiaSharp.SKManagedStream..ctor(Stream managedStream, Boolean disposeManagedStream)
at SkiaSharp.SKCodec.WrapManagedStream(Stream stream)
at SkiaSharp.SKCodec.Create(Stream stream, SKCodecResult& result)
at SkiaSharp.SKCodec.Create(Stream stream)
at SkiaSharp.SKBitmap.Decode(Stream stream)
The inner-most error message seem to be "No such file or directory" which is strange since I'm decoding a memory-stream. This works on Windows and it have worked on Linux before I upgraded to .NET Core 2.2 and latest SkiaSharp.
I have tried setting the LD_DEBUG env variable as suggested in the error message but that didn't do much. Not sure what to set it to really. Tried 'all' but that didn't result in any more detailed log.
Found a thread that suggests installing SkiaSharp.NativeAssets.Linux as a solution, but unfortunately that didn't help. Do I need to target Linux-x64 runtime when building/publishing? Have tried different combinations but couldn't detect any difference. (I'm building with dotnet cli in a Docker-file on Linux over ssh with putty. Pretty much default Docker-file as generated by VS:latest)
Another suggestion was to install libSkiaSharp.so manually and also apt-get install libfontconfig1, but unfortunately apt-get is not available on Synology DSM.
Installing Linux dependency NuGet Package will solve this issue
SkiaSharp.NativeAssets.Linux.NoDependencies
https://www.nuget.org/packages/SkiaSharp.NativeAssets.Linux.NoDependencies
I had the same problem running SkiaSharp with .Net Core 2.2 on Linux.
First, I installed the NuGet package SkiaSharp.NativeAssets.Linux (that you mention above) and made sure that the libSkiaSharp.so file was copied into the same directory as the rest of the DLLs.
I still received the error.
Next, I connected a shell to my container and I listed the dependencies using the command:
ldd libSkiaSharp.so
I found out that I was missing libfreetype6 and libfontconfig1.
As my environment uses Docker, I simply added some commands to install these extra dependencies in my docker file:
FROM microsoft/dotnet:aspnetcore-runtime
RUN apt-get update
RUN apt-get install -y libfreetype6
RUN apt-get install -y libfontconfig1
Now the application works.
Can you try adding these commands to your Docker file?

OSX 10.13 DOTNET RUN System.ComponentModel.Win32Exception (0x80004005): No such file or directory

When executing dotnet run -c release in my terminal on OSX 10.13, I get the following error:
../../Properties/launchSettings.json...
System.ComponentModel.Win32Exception (0x80004005): No such file or
directory
at Interop.Sys.ForkAndExecProcess(String filename, String[] argv,
String[] envp, String cwd, Boolean redirectStdin, Boolean
redirectStdout, Boolean redirectStderr, Int32& lpChildPid, Int32&
stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean shouldThrow)
at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at Microsoft.DotNet.Cli.Utils.Command.Execute()
at Microsoft.DotNet.Tools.Run.RunCommand.Start()
at Microsoft.DotNet.Tools.Run.RunCommand.Run(String[] args)
at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry
telemetryClient)
at Microsoft.DotNet.Cli.Program.Main(String[] args)
.NET Command Line Tools (2.2.0-preview1-007582)
Product Information:
Version: 2.2.0-preview1-007582
Commit SHA-1 hash: 4845efe2ea
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.13
OS Platform: Darwin
RID: osx.10.12-x64
Base Path: /usr/local/share/dotnet/sdk/2.2.0-preview1-007582/
Microsoft .NET Core Shared Framework Host
Version : 2.1.0-preview1-25919-02
Build : 96a1025de48784825ac61e45ece24a4343e0bf01
The runtime identifier is set for OSX 10.12 as directed on the Microsoft documents.
The project works on Windows 10, just not on any OSX device.
The launchSettings.json file does exist. If I copy and nano the file, it will edit the file. I'm out of ideas right now.
dotnetcore 2.0.3 and 2.1 have this issue:
https://github.com/dotnet/cli/issues/6397
There is a . in our project name and it's causing the issue.
It's currently reopened as it has not been resolved.
Make sure that you have installed and are using a version of the .NET Core Runtime that supports macOS High Sierra (10.13).
Since you are building a self-contained app, make sure that you set the RuntimeFrameworkVersion to a recent version to ensure that you include all the assets necessary to run on High Sierra.
For example:
<PropertyGroup>
<TargetFramework>netcoreapp1.0</TargetFramework>
<RuntimeFrameworkVersion>1.0.8</RuntimeFrameworkVersion>
</PropertyGroup>
or if you are using .NET Core 1.1:
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<RuntimeFrameworkVersion>1.1.5</RuntimeFrameworkVersion>
</PropertyGroup>
.NET Core 2.0 always supported High Sierra, but to get the newest runtime for self-contained apps, you currently also need to set this property:
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeFrameworkVersion>2.0.3</RuntimeFrameworkVersion>
</PropertyGroup>

Crosscompiling Qt4: uic segfaults

For a dated embedded project I try to crosscompile Qt 4.7.4 on a current Ubuntu 16.04 x86_64 system with multiarch setup (amd64 + i386).
The crosscompilation was once set up for Ubuntu 12.04 x86, and it works well there. Compiling it on the new system for host debugging (host and target platform being set to x86/i386/32 bit) worked well, too. However, when I try to crosscompile it for the target system (arm) with the host set to i386 uic segfaults while building the QtGui lib.
The following relevant flags are used to configure Qt for the target system:
-host-arch i386 -platform qws/linux-x86-g++
-embedded arm -xplatform qws/linux-gnueabi-arm-mucross-g++
Furthermore mkspecs/qws/linux-x86-g++/qmake.conf has been patched to include some compiler flags that seem necessary to get compilation and linking right:
QT_ARCH = I386
QMAKE_CFLAGS += -m32
QMAKE_CXXFLAGS += -m32
QMAKE_LFLAGS += -m32
This is the call that fails:
/<project>/qt-target/bin/uic /<project>/qt-everywhere-opensource-src-4.7.4/src/gui/dialogs/qpagesetupwidget.ui -o .uic/release-shared-emb-arm/ui_qpagesetupwidget.h
I can reproduce the segfault manually and debug it. strace doesn't show anything obvious, the correct i386 libs are being loaded. Here's the first lines of the gdb backtrace:
Program received signal SIGSEGV, Segmentation fault.
__GI___fesetenv (envp=0xffffbbd4) at ../sysdeps/i386/fpu/fesetenv.c:116
116 ../sysdeps/i386/fpu/fesetenv.c: Datei oder Verzeichnis nicht gefunden.
(gdb) backtrace
#0 __GI___fesetenv (envp=0xffffbbd4) at ../sysdeps/i386/fpu/fesetenv.c:116
#1 0x080fa7de in qdtoa (d=9999.9899999999998, mode=2, ndigits=6,
decpt=0xffffbce8, sign=0xffffbcec, rve=0xffffbcf4, resultp=0xffffbcf8)
at /<project>/qt-everywhere-opensource-src-4.7.4/src/corelib/tools/qlocale.cpp:6655
#2 0x080fc230 in QLocalePrivate::doubleToString (
this=0x8181160 <locale_data>, d=9999.9899999999998, precision=2,
form=<optimized out>, width=0, flags=<optimized out>)
at /<project>/qt-everywhere-opensource-src-4.7.4/src/corelib/tools/qlocale.cpp:4012
#3 0x0811da6f in QString::setNum (this=0xffffbf78, n=9999.9899999999998,
f=<optimized out>, prec=6)
at /<project>/qt-everywhere-opensource-src-4.7.4/src/corelib/tools/qstring.cpp:5930
#4 0x0811ddca in QString::number (n=9999.9899999999998, f=103 'g', prec=6)
at /<project>/qt-everywhere-opensource-src-4.7.4/src/corelib/tools/qstring.cpp:6034
Some investigation brought me to a glibc bug in fesetenv() which was fixed in glibc 2.23, but since this is already installed (libc6 2.23-0ubuntu3), I didn't get any further here. The faulting line 116 has been introduced by that fix, but lacking knowledge of the internals I'm not able to point out the cause of the segfault:
__asm__ ("ldmxcsr %0" : : "m" (mxcsr));
Furthermore there are some old, closed or unresolved Qt bug reports regarding the bootstrap build (which includes uic), but these didn't give me any useful hints either.
Who can give a pointer what I can try to find the cause and work around or fix this issue?
The reason for this problem was that additional, target specific include and lib dirs were provided to the configure script using the -I and -L options. These were used for the bootstrap build, too, which didn't matter much on the old system where the headers of host and target where apparently close enough to each other.
Once moved into the target mkspec file and added to QMAKE_CFLAGS, QMAKE_CXXFLAGS and QMAKE_LFLAGS the build process works fine.

EADDRINUSE address already in use

When I run dnu . kestrel to start up the asp.net 5 server on OS X, and then press CTL+C to stop the server, then run dnu . kestrel a second time, I receive the following exception:
Sullys-MacBook-Pro:Test1App Sully$ dnx . kestrel
System.Exception: Error -48 EADDRINUSE address already in use
at Microsoft.AspNet.Server.Kestrel.Networking.Libuv.Check (Int32 statusCode) [0x00000] in :0
at Microsoft.AspNet.Server.Kestrel.Networking.Libuv.listen (Microsoft.AspNet.Server.Kestrel.Networking.UvStreamHandle handle, Int32 backlog, Microsoft.AspNet.Server.Kestrel.Networking.uv_connection_cb cb) [0x00000] in :0
at Microsoft.AspNet.Server.Kestrel.Networking.UvStreamHandle.Listen (Int32 backlog, System.Action`4 callback, System.Object state) [0x00000] in :0
^C
The terminal acts like the server is running, because I have to press CTL+C again to terminate the server process. While it is "running", I can't actually navigate to it from a browser.
Is there a proper way to shut down the server as I change code, without having to kill the terminal, open a new one, navigate to my project directory and re-start kestrel?
I have seen other errors related to this on SO; they all seemed related to Android. I haven't seen anything related to kestrel and the dnu for EADDRINUSE
On OS X pressing the Enter key in the terminal should stop kestrel. What is happening is that Cntrl-C puts it into a suspended state and you would then have to find the process and issues a unix kill command for that process. The issue https://github.com/aspnet/KestrelHttpServer/issues/26 refers. Though I am sure I say a thread saying it was going to fixed so that either Cntrl-C or Cntrl-Z would would work on all environments for Kestrel
I know this is a OSX question, but I was getting this exception in Windows after I changed --server.urls=http://*:9000 to --server.urls=http://*:9000;https://*:9000 to attempt to support https. It look like the semi-colon is not supported.
The same is true in RC2 with .UseUrls("http://:9000", "https://:9000")

Open CL with AMD

I am trying to implement matrix multiplication usign OpenCL. I have an ATI Radeon HD Radeon 5000 series graphics card.
This is one of the programs i found on the net, but linking errors are coming which i am not able to solve.
I tried running the code mentioned in this site
http://gpgpu-computing4.blogspot.in/2009/10/matrix-multiplication-3-opencl.html
I followed setting up my visual studio project from this site http://www.guineacode.com/2010/linking-and-compiling-opencl/
but the following errors come
error LNK2019: unresolved external symbol _oclLoadProgSource referenced in function _main
error LNK2019: unresolved external symbol _shrLogEx referenced in function "void __cdecl __shrCheckErrorEX(int,int,void (__cdecl*)(int),char const *,int)" (?__shrCheckErrorEX##YAXHHP6AXH#ZPBDH#Z)
Any help would be appreciated
Can you try this ?
Make sure you have the latest Catalyst driver from AMD.
Try downloading AMD APP SDK 2.6 from here : http://developer.amd.com/sdks/AMDAPPSDK/downloads/Pages/default.aspx
After the install, do the following
Make sure to include $(AMDAPPSDKROOT)\include for header files
Library Directory : $(AMDAPPSDKROOT)\lib\x86 or x86_64 depending on your bitness
4.Now you can build and run the program
Here is an older post which talks about linking 2.4... with slight modification you can use the instruction
http://blog.cuvilib.com/2011/07/01/how-to-run-opencl-in-microsoft-vs-2008-using-amd-app-sdk/
If you are looking only MatrixMultiplication sample, AMD APP SDK bundles some samples along with pack you can find them in (Windows)
C:\USERS\%USER%\My Documents\AMD APP\ Samples
and in Linux under
/opt/AMD APP SDK/Samples
HTH

Resources