Saturday 16 December 2023

cuDNN and TensorFlow performance

 Speed testing cuDNN and TensorFlow versions


I have noticed an increase in recommendations to use newer versions of cuDNN and TensorFlow instead of those linked in my tutorial - usually claiming the older versions to be the reason for someone failing to get the GPU working in PixInsight.

The current version for cuDNN is 8.9.7, and my tutorial recommends 8.7.0. The only difference in hardware support is cuDNN 8.9.7 dropping support for Kepler GPUs and CUDA Compute Capability 3.5. All the more recent GPUs are supported by both.

TensorFlow's latest native Windows version is 2.10.0, and my tutorial uses 2.9.0. No difference in hardware compatibility. Both are also built on a very old 8.1 version of cuDNN.

So no, updating to a newer version does not magically make GPU acceleration work. If someone only got it working by using a different version, then they either had a corrupted file in their previous attempt or they first failed to follow the instructions and read them more carefully later.

One thing that will change, though, is the performance.
I have done countless tests using different versions before and after creating the tutorial. For this post I ran another set of tests with PixInsight and the processes updated to the latest versions. The results are rounded to one decimal to make them easier to read.

StarNet2: pretty much the same performance across the board.
StarXterminator: 30% difference from the fastest to the slowest!
NoiseXterminator: about 10% in favor of TensorFlow 2.9.0.
BlurXterminator: a surprise win for  8.9.7+2.10.0 - 5% faster than the slowest of the four.

Based on these findings, I will not change the links in my tutorial.
Of course this test shows only one system and one image, but the results are similar to my previous tests with other systems and images.
I encourage everyone to run comparison tests on their own system to determine the best combination.



Wednesday 1 February 2023

PixInsight CUDA

How to enable GPU acceleration for PixInsight


Certain processes in PixInsight, like StarNet2 and the RC-Astro XTerminator tools, benefit massively from running on the GPU. Typically they take minutes to finish when using the CPU, but with a CUDA capable GPU they'll be done in less than 30s.
This tutorial was inspired by the guide made by darkarchon, and updated to support newer GPUs. To keep things simple, the guide covers the necessary files and steps to make PixInsight use the GPU, and nothing more.
The software used here should work on most Nvidia GPUs from the last ten years; from the GTX 900-series to the RTX 4000-series, for example.

Getting started


- Before proceeding, open the following link, and make sure that your GPU has Compute Capability 3.5 or higher. https://developer.nvidia.com/cuda-gpus

- Use the 64-bit version of Windows 10 or Windows 11

- Update the GPU drivers; the software used here requires driver version 452.39 or higher.

- Log in to your developer account on the NVIDIA website. If you don't have one, create one for free.

- Download the following 4 files:





- If you have previously installed CUDA, uninstall it if you don't have other uses for it


Setting up


1. Replace tensorflow
- Go to 'C:\Program Files\PixInsight\bin'
- Rename tensorflow.dll to tensorflow-old.dll in case you want to use it later and don't want to re-install
- Open libtensorflow-gpu-windows-x86_64-2.9.0.zip
- Extract tensorflow.dll from 'lib' to 'C:\Program Files\PixInsight\bin'



2. Install CUDA
- Run cuda_11.8.0_windows_network.exe
- Select 'Custom (Advanced)'


- Deselect everything, then select 'Libraries' in CUDA > Runtime


- Click next, and proceed with the install


3. Install cuDNN
- Open cudnn-windows-x86_64-8.7.0.84_cuda11-archive.zip
- Extract the contents of the folder 'bin' to 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin'
- Overwrite existing files if you are updating from another version



4. Install zLib
- Open zlib123dllx64.zip
- Extract zlibwapi.dll from 'dll_x64' to 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin'



5. Edit Environment Variables
- Open the start menu, search for 'environment', and click 'Edit the system environment variables'


- Click 'Environment Variables', then under 'System variables' click 'New' and enter "TF_FORCE_GPU_ALLOW_GROWTH" as name and "true" as value, then click 'OK'


- Select the variable called 'Path' under 'System variables', and click 'Edit'


- Click 'New', and add "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin"
- If you had previously installed a different version of the CUDA Toolkit, there might be a path pointing to that version as well; remove it if you don't need it, otherwise move it down below 11.8 on the list
- Click 'OK' to save and exit



6. Test
- Open an image in PixInsight, and run StarNet2 or any RC-Astro tool
If it's a lot faster than before, you know it's working :)
- A successful install will also show up on the GPU performance monitor when processing; depending on your setup it can be either in the 3D graph or the Cuda graph




Troubleshooting
- If CPU usage increases instead of the GPU, then re-do steps 1, 3 and 5
- If PixInsight crashes, re-do step 4
- If still not working, re-download all files and re-do every step


PixInsight re-installs and major updates will overwrite the tensorflow.dll, so step 1 must be re-done occasionally.