This project has moved. For the latest updates, please go here.

Is it a way to force Magick to use GPU?

Jan 28, 2015 at 11:09 AM
Hello.

I would like to measure performance of library on some our loads and I want to explicitly define "Use only GPU", "Use only CPU" and "Use whatever you want" and compare results.

Is it possible?

What are criterions for GPU to be selected by MagickNet automatically?

Thank you.
Coordinator
Jan 28, 2015 at 11:17 AM
ImageMagick/Magick.NET will use OpenCL when this supported by your video card. Support for this is detected automatically. You can disable this with MagickNET.UseOpenCL.

But there is no such thing as "Use only GPU". Magick.NET will only use GPU acceleration for a subset of the operations. You can see for which operations we do that here: http://trac.imagemagick.org/browser/ImageMagick/trunk/MagickCore/accelerate.h.
Jan 28, 2015 at 11:40 AM
Yeah, I'm aware of it, thank you, I checked it before posting.

We are doing mostly resize, and if I'm not mistaken resize is supported for operation on GPU.

GPU-Z says that OpenCL is supported by my integrated GPU (Intel HD Graphics 4600). So I'm trying to resize a big image (41 megapixel, from Nokia 1020) to a small one (1000*1000 for tests) and GPU load is zero, but CPU load is nearly 100% on one core during test run, so I assume that Magick.NET didn't use GPU.

I have very simple console app:
 static void Main(string[] args)
 {
     Console.WriteLine("Use GPU = {0}", MagickNET.UseOpenCL);
     Console.WriteLine("Features = {0}", MagickNET.Features);

     var image = new MagickImage("Sources\\bigOne.jpg");
     image.Resize(new Percentage(50));
     image.Write("output\\1.jpg");

     Console.WriteLine("Done");
     Console.ReadKey();
 }
It prints:
Use GPU = True
Features = DPC Modules OpenCL OpenMP
Done
We want to test viability of adding GPU to our servers to handle resizing of images using ImageMagick. For that I should measure performance on CPU and GPU and understand when Magick.Net will choose GPU and when not.

Thank you for fast answer!
Coordinator
Jan 28, 2015 at 11:43 AM
Edited Jan 28, 2015 at 11:43 AM
Are you using the latest version of Magick.NET? And can you share your image?

p.s. I removed one of your duplicate posts. I hope I removed the correct one.
Jan 28, 2015 at 11:59 AM
Edited Jan 28, 2015 at 12:00 PM
I'm using latest version of stable Nuget package. From my packages.config:
<package id="Magick.NET-Q16-AnyCPU" version="7.0.0.0009" targetFramework="net45" />
I don't know is it the latest version of Magick.Net :)

You can get picture where I got it (link points to gallery, right click on picture -> save as) I think it's legit to use it for tests.

And sorry about duplicate posts, I have not very stable connection at work.
Coordinator
Jan 28, 2015 at 8:34 PM
Edited Jan 28, 2015 at 8:34 PM
It seems AccelerateResizeImage was not enabled in ImageMagick 7. I just committed a change to fix this for the next release of Magick.NET.

AccelerateResizeImage will only be used if the image contains an alpha channel. ImageMagick 6 always has 4 channels per pixel and the OpenCL code for ImageMagick 7 also expects this. This will be changed in the future but I don't know when this will be done. To add an alpha channel to your jpeg file use: MagickImage.Alpha(AlphaOption.On);

The next release of Magick.NET will probably be in the end of February. Contact me through CodePlex if you want a development build to test the OpenCL acceleration.
Jan 30, 2015 at 10:35 AM
Oh, thank you very much for help. If we'd need to test it before the release, I'll contact you.