This project has moved and is read-only. For the latest updates, please go here.

Is it a way to force Magick to use GPU?

Jan 28, 2015 at 12:09 PM

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.
Jan 28, 2015 at 12:17 PM
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:
Jan 28, 2015 at 12:40 PM
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));

It prints:
Use GPU = True
Features = DPC Modules OpenCL OpenMP
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!
Jan 28, 2015 at 12:43 PM
Edited Jan 28, 2015 at 12:43 PM
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 12:59 PM
Edited Jan 28, 2015 at 1:00 PM
I'm using latest version of stable Nuget package. From my packages.config:
<package id="Magick.NET-Q16-AnyCPU" version="" 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.
Jan 28, 2015 at 9:34 PM
Edited Jan 28, 2015 at 9: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 11:35 AM
Oh, thank you very much for help. If we'd need to test it before the release, I'll contact you.