Page 1 of 2
Guetzli cuda support
Posted: Thu Nov 23, 2023 7:50 am
by Tschens
Hello,
the "save as guetzli jpg" option is extremely slow on almost each computer. 20 Mpix files need about 20 minutes. This is anything but practical in everyday use.
There is a cuda version of guetzli available with is way faster (25-40x acording to the developers) than the original one:
https://github.com/doterax/guetzli-cuda-opencl
However, even this exe file needs the --cuda parameter in order to use cuda. I would recommend to introduce CUDA support.
Maybe introducing a dropdown menu in the settings where the user can choose between these switches would make sense:
standard guetzli settings (no parameter)
optimized settings (--c as parameter); about 2x faster
OpenCL (--opencl as parameter); about 10x faster
CUDA (--cuda as parameter); about 20x faster
This would be GREAT!!
Jens
Re: Guetzli cuda support
Posted: Thu Nov 23, 2023 9:30 am
by m.Th.
Interesting! It seems that it has autodetection so it can switch automatically to the best engine available (if it was compiled correctly).
Do you have practical experience with Guetzli? Which is the compression ratio compared with „normal” JPEG?
Re: Guetzli cuda support
Posted: Thu Nov 23, 2023 12:28 pm
by Tschens
Just started to play around with guetzli a few days ago. The jpg files created by guetzli are quite small.
The normal version is by far too slow, see my previous post.
Currently, I use CUDA-guetzli the following way for batch-conversion of 1 or more than 1 files:
1) Download the cuda-version of guetzli and put it in an extra folder, name the exe file guetzli.exe
2) Creat a batch file, for example guetzli.bat, with the following content:
for %%i in (*.jpg) do guetzli.exe --verbose --cuda --quality 85 "%%i" "%%~ni.jpg
Now
copy all jpg files you want to compress into this folder and execute the batch file. Keep in mind: These jpg files will be overwritten by the compressed ones.
The "normal" usage (one file only) of the cuda version of guetzli would be
guetzli.exe --cuda input.jpg output.jpg
Where input.jpg is the name of the file you want to compress and output.jpg is the output file. Feel free to change the --quality 85 setting to anything between 84 and 100. This will only convert the ONE file named input.jpg.
Guetzli also works with TIF files (tif -> jpg) and with png files (png->jpg), so if you want a quite flexible batch file for converting jpg, tif and png files, just add 2 more lines to the first bat file which should look like this (the line for jpg to jpg conversion should be the first one, otherwise the already compressed jpg files (from tif->jpg and png->jpg) will be compresses a second time

:
for %%i in (*.jpg) do guetzli.exe --verbose --cuda --quality 85 "%%i" "%%~ni.jpg
for %%i in (*.tif) do guetzli.exe --verbose --cuda --quality 85 "%%i" "%%~ni.jpg
for %%i in (*.png) do guetzli.exe --verbose --cuda --quality 85 "%%i" "%%~ni.jpg
With htis extended batch file,
all file names you start with HAVE TO BE DIFFERENT! Dont start with myfile.tif and myfile.jpg, since both will be compressed to myfile.jpg. (the second result overwrites the first one in this case).
Have fun.
Jens
Re: Guetzli cuda support
Posted: Thu Nov 23, 2023 12:40 pm
by Tschens
Some more info, also for the development team from XNView MP:
I just contacted one of the developers with the question how to introduce the CUDA-guetzli into XNView as a plugin instead of the normal (slow) guetzli. The issue is that CUDA-guetzli needs the extra command "--cuda" in order to activate the cuda function of the exe file. This means you cannot just take the cuda version of the exe file, name it "guetzli_windows_x86-64.exe" and overwrite the normal guetzli version in the plugin folder of XNView. He provided 2 ideas:
1) do it via a batch file
Maybe I was not able to follow the process, however, it did not work for me
2) Compile a exe which uses the CUDA function without needing the "--cuda" parameter.
Although the author gave the detailed description (just a minor change in the program code), I am not aware how to self-compile the exe since this seems to be a quite complex procedure.
Maybe there is someone out there who is willing to help?
Jens
Re: Guetzli cuda support
Posted: Thu Nov 23, 2023 4:20 pm
by m.Th.
Got it. AFAIS it has a switch to autodetect the best acceleration (--c).
Is it true?
Note: The solution should work also for ATI/AMD VGA cards which support only OpenCL.

Re: Guetzli cuda support
Posted: Thu Nov 23, 2023 5:40 pm
by Tschens
--c ist just the „optimised“ procedure which speeds up about 2x. Check the table here:
https://github.com/doterax/guetzli-cuda-opencl
I think --auto is the switch for autodetection. This does not help for the use in XNview, since it is not possible to use any switch.
Re: Guetzli cuda support
Posted: Fri Nov 24, 2023 6:27 am
by strongtu
m.Th. wrote: Thu Nov 23, 2023 4:20 pm
Got it. AFAIS it has a switch to autodetect the best acceleration (--c).
Is it true?
Note: The solution should work also for ATI/AMD VGA cards which support only OpenCL.
clguetzli support these special mode
--c do not use any hardware accelerated but CPU
--opencl use opencl compute platform
--cuda use cuda compute platform
if don't give any mode to it, there will be no optimize(as same as guetzli)
Re: Guetzli cuda support
Posted: Fri Nov 24, 2023 6:29 am
by strongtu
Tschens wrote: Thu Nov 23, 2023 5:40 pm
--c ist just the „optimised“ procedure which speeds up about 2x. Check the table here:
https://github.com/doterax/guetzli-cuda-opencl
I think --auto is the switch for autodetection. This does not help for the use in XNview, since it is not possible to use any switch.
no --auto mode in clguetzli
Re: Guetzli cuda support
Posted: Fri Nov 24, 2023 8:30 am
by m.Th.
strongtu wrote: Fri Nov 24, 2023 6:29 am
Tschens wrote: Thu Nov 23, 2023 5:40 pm
--c ist just the „optimised“ procedure which speeds up about 2x. Check the table here:
https://github.com/doterax/guetzli-cuda-opencl
I think --auto is the switch for autodetection. This does not help for the use in XNview, since it is not possible to use any switch.
no --auto mode in clguetzli
A, ok. It is easy then. The autodetection code exists, and this is important.
Re: Guetzli cuda support
Posted: Fri Nov 24, 2023 10:36 am
by Tschens
m.Th. wrote: Fri Nov 24, 2023 8:30 am
strongtu wrote: Fri Nov 24, 2023 6:29 am
Tschens wrote: Thu Nov 23, 2023 5:40 pm
--c ist just the „optimised“ procedure which speeds up about 2x. Check the table here:
https://github.com/doterax/guetzli-cuda-opencl
I think --auto is the switch for autodetection. This does not help for the use in XNview, since it is not possible to use any switch.
no --auto mode in clguetzli
A, ok. It is easy then. The autodetection code exists, and this is important.
In fact, ther IS --auto mode in cl_guetzli, I just checked it and it works, see here:
https://github.com/doterax/guetzli-cuda-opencl/releases
Re: Guetzli cuda support
Posted: Fri Nov 24, 2023 9:12 pm
by Tschens
The solution would be (citation from author):
if you can clone&rebuild the source, you can change the default parameter of g_mathMode which is in the file clguetzli.cpp, change it to MODE_CUDA and rebuild it. (End of citation).
Unfortunately, I did not manage to compile it after 2 days of hard work. Lots of errors during the compiling process. Hoping for help now.
Re: Guetzli cuda support
Posted: Sat Nov 25, 2023 9:13 am
by Tschens
Finally, I did it. I got a working „auto“ as well as a „CUDA“ exe which is dependent from 5 dll files (don’t know why visual studio does not merge, I have chosen static exe). However, it does not work with XNview since I get an error message. Obviously, XNview sends some additional parameters to the guetzli exe which might not work with this forked version.
I think the „auto“ version could be very interesting as a plugin instead of the normal, slow guetzli exe. I hope the dev team is reading here.
Re: Guetzli cuda support
Posted: Sat Nov 25, 2023 1:04 pm
by doterax
I have built guetzli with autodetection of best mode from the start.
You can download it from here
https://github.com/doterax/guetzli-cuda ... /issues/11
If you experience some problems with it, you can write it in this issue.
Enjoy.
Re: Guetzli cuda support
Posted: Sat Nov 25, 2023 2:24 pm
by m.Th.
Tschens wrote: Sat Nov 25, 2023 9:13 am
Finally, I did it. I got a working „auto“ as well as a „CUDA“ exe which is dependent from 5 dll files (don’t know why visual studio does not merge, I have chosen static exe). However, it does not work with XNview since I get an error message. Obviously, XNview sends some additional parameters to the guetzli exe which might not work with this forked version.
I think the „auto“ version could be very interesting as a plugin instead of the normal, slow guetzli exe. I hope the dev team is reading here.
Yes, „the dev team” is reading.

Re: Guetzli cuda support
Posted: Sat Nov 25, 2023 2:26 pm
by m.Th.
Thanks a lot!
First problem:
I cannot download it because the latest Windows 11 with the latest MS Edge and latest MS Defender Antivirus finds a virus!
See below:

- Cannot download.jpg (18.49 KiB) Viewed 2162 times
This is it:
https://www.microsoft.com/en-us/wdsi/th ... ik.FL.B!ml