If you have an Nvidia card, you can greatly improve the performance of StarXTerminator and StarNet2. These instructions are for Linux.
This is an update to a post by Ajay Narayanan.
https://pixinsight.com/forum/index....cuda-and-libtensorflow-gpu-under-linux.18180/
Most of the credit should go to Ajay. I am just updating his instructions and providing troubleshooting tips.
A summary of the key commands is provided at the end of this post.
System Used to Test Instructions
Ubuntu 22.04 with KDE desktop
Nvidia GTX Titan X (Compute Compatability 5.2)
PixInsight 1.8.9-1
StarXTerminator 2.0.5 AI Version 11
StarNet2
Speed improvement is roughly 10x.
Mostly complete list of compatible GPUs
https://developer.nvidia.com/cuda-gpus
apt
If apt install fails at any point, you can try
$ sudo apt install --fix-broken install
apt and apt-get are essentially the same in modern versions of Debian based Linuxes.
Install CUDA
If you do not already have build-essential
$ sudo apt install build-essential
At https://developer.nvidia.com/cuda-toolkit-archive click the links for your system. For me, this was CUDA Toolkit 11.8.0 -> Linux -> x86_64 -> Ubuntu -> 22.04 -> deb (local)
Follow the instructions presented by Nvidia. There are about 7 commands beginning with wget.
Install libcudnn8
$ sudo apt install libcudnn8
Cuda will be installed to /usr/local
libcudnn.so.8 will be put in a system directory such as /usr/lib/x86_64-linux-gnu/
Reboot
Installing Cuda installs kernel modules which may not go into effect without rebooting.
Install TensorFlow
Download the tar file for Linux GPU support at
https://www.tensorflow.org/install/lang_c
Extract to /usr/local
$ sudo tar -C /usr/local -xzf libtensorflow-gpu-linux-x86_64-2.11.0.tar.gz
$ sudo ldconfig /usr/local/lib
The above is the current tar file as of this writing. It will change.
ldconfig tells your system where to look for the tensorflow libraries.
I highly recommend creating, compiling, linking, and executing the very short C program as per https://www.tensorflow.org/install/lang_c It will only take a few minutes. You do not need to understand this; follow TensorFlow's instructions. This will verify that TensorFlow was properly installed. The program should respond with something like Hello from TensorFlow C library version 2.11.0
Remove PixInsight's TensorFlow Libraries
This will ensure that PI picks up the new tensorflow libraries. Create a directory to save the libraries and move them. Be careful not to move any other files.
$ sudo mkdir /opt/pi_lib_tmp
$ sudo mv /opt/Pixinsight/bin/lib/libtensor* /opt/pi_lib_tmp
The above commands moved 6 files (2 TensorFlow libraries and 4 soft links). The updated GPU version of these same 6 files will be in /usr/local/lib
Update ~/.bashrc
Add the following lines:
export TF_FORCE_GPU_ALLOW_GROWTH="true"
export CUDA_VISIBLE_DEVICES="0"
If you have more than 1 GPU, you may want a different CUDA_VISIBLE_DEVICES value. See
https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#env-vars
Start a new bash shell and verify your .bashrc changes worked with commands such as:
$ env | grep TF_FORCE
$ env | grep CUDA
Verify PixInsight is now using the GPU
Install performance meter for nvidia. Run it in a command terminal.
$ sudo apt install nvtop
$ nvtop
Run PixInsight from the command line to see helpful messages
$ PixInsight
In PixInsight, bring up an image and try StarXTerminator or StarNet2.
nvtop should show the GPU's memory and CPU being used graphically and on the text line where type=compute
If PixInsight cannot run star removal, it will output text to the command terminal you started it from. This text will give you a clue, such as missing a library associated with cuda, or missing libcudnn, or finding the CPU version of TensorFlow instead of the GPU version.
If PixInsight can run star removal with your GPU, it will output a line in the command terminal that includes the name of your GPU, its memory, and compute capability.
For my system, PixInsight outputs
Created device /job:localhost/replica:0/task:0/device:GPU:0 with 10641 MB memory: -> device: 0, name: NVIDIA GeForce GTX TITAN X, pci bus id: 0000:05:00.0, compute capability: 5.2
List of Essential Commands from above
$ sudo apt install build-essential
# Follow Nvidia instructions at https://developer.nvidia.com/cuda-toolkit-archive
$ sudo apt install libcudnn8
# reboot
# download tar file from https://www.tensorflow.org/install/lang_c
$ sudo tar -C /usr/local -xzf libtensorflow-gpu-linux-x86_64-2.11.0.tar.gz
$ sudo ldconfig /usr/local/lib
# move PI TensorLibrares to another directory so PI won't find them
$ sudo mkdir /opt/pi_lib_tmp
$ sudo mv /opt/Pixinsight/bin/lib/libtensor* /opt/pi_lib_tmp
# add to .bashrc
export TF_FORCE_GPU_ALLOW_GROWTH="true"
export CUDA_VISIBLE_DEVICES="0"
# start PixInsight and verify GPU is being used
Clear Skies!
Steve
This is an update to a post by Ajay Narayanan.
https://pixinsight.com/forum/index....cuda-and-libtensorflow-gpu-under-linux.18180/
Most of the credit should go to Ajay. I am just updating his instructions and providing troubleshooting tips.
A summary of the key commands is provided at the end of this post.
System Used to Test Instructions
Ubuntu 22.04 with KDE desktop
Nvidia GTX Titan X (Compute Compatability 5.2)
PixInsight 1.8.9-1
StarXTerminator 2.0.5 AI Version 11
StarNet2
Speed improvement is roughly 10x.
Mostly complete list of compatible GPUs
https://developer.nvidia.com/cuda-gpus
apt
If apt install fails at any point, you can try
$ sudo apt install --fix-broken install
apt and apt-get are essentially the same in modern versions of Debian based Linuxes.
Install CUDA
If you do not already have build-essential
$ sudo apt install build-essential
At https://developer.nvidia.com/cuda-toolkit-archive click the links for your system. For me, this was CUDA Toolkit 11.8.0 -> Linux -> x86_64 -> Ubuntu -> 22.04 -> deb (local)
Follow the instructions presented by Nvidia. There are about 7 commands beginning with wget.
Install libcudnn8
$ sudo apt install libcudnn8
Cuda will be installed to /usr/local
libcudnn.so.8 will be put in a system directory such as /usr/lib/x86_64-linux-gnu/
Reboot
Installing Cuda installs kernel modules which may not go into effect without rebooting.
Install TensorFlow
Download the tar file for Linux GPU support at
https://www.tensorflow.org/install/lang_c
Extract to /usr/local
$ sudo tar -C /usr/local -xzf libtensorflow-gpu-linux-x86_64-2.11.0.tar.gz
$ sudo ldconfig /usr/local/lib
The above is the current tar file as of this writing. It will change.
ldconfig tells your system where to look for the tensorflow libraries.
I highly recommend creating, compiling, linking, and executing the very short C program as per https://www.tensorflow.org/install/lang_c It will only take a few minutes. You do not need to understand this; follow TensorFlow's instructions. This will verify that TensorFlow was properly installed. The program should respond with something like Hello from TensorFlow C library version 2.11.0
Remove PixInsight's TensorFlow Libraries
This will ensure that PI picks up the new tensorflow libraries. Create a directory to save the libraries and move them. Be careful not to move any other files.
$ sudo mkdir /opt/pi_lib_tmp
$ sudo mv /opt/Pixinsight/bin/lib/libtensor* /opt/pi_lib_tmp
The above commands moved 6 files (2 TensorFlow libraries and 4 soft links). The updated GPU version of these same 6 files will be in /usr/local/lib
Update ~/.bashrc
Add the following lines:
export TF_FORCE_GPU_ALLOW_GROWTH="true"
export CUDA_VISIBLE_DEVICES="0"
If you have more than 1 GPU, you may want a different CUDA_VISIBLE_DEVICES value. See
https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#env-vars
Start a new bash shell and verify your .bashrc changes worked with commands such as:
$ env | grep TF_FORCE
$ env | grep CUDA
Verify PixInsight is now using the GPU
Install performance meter for nvidia. Run it in a command terminal.
$ sudo apt install nvtop
$ nvtop
Run PixInsight from the command line to see helpful messages
$ PixInsight
In PixInsight, bring up an image and try StarXTerminator or StarNet2.
nvtop should show the GPU's memory and CPU being used graphically and on the text line where type=compute
If PixInsight cannot run star removal, it will output text to the command terminal you started it from. This text will give you a clue, such as missing a library associated with cuda, or missing libcudnn, or finding the CPU version of TensorFlow instead of the GPU version.
If PixInsight can run star removal with your GPU, it will output a line in the command terminal that includes the name of your GPU, its memory, and compute capability.
For my system, PixInsight outputs
Created device /job:localhost/replica:0/task:0/device:GPU:0 with 10641 MB memory: -> device: 0, name: NVIDIA GeForce GTX TITAN X, pci bus id: 0000:05:00.0, compute capability: 5.2
List of Essential Commands from above
$ sudo apt install build-essential
# Follow Nvidia instructions at https://developer.nvidia.com/cuda-toolkit-archive
$ sudo apt install libcudnn8
# reboot
# download tar file from https://www.tensorflow.org/install/lang_c
$ sudo tar -C /usr/local -xzf libtensorflow-gpu-linux-x86_64-2.11.0.tar.gz
$ sudo ldconfig /usr/local/lib
# move PI TensorLibrares to another directory so PI won't find them
$ sudo mkdir /opt/pi_lib_tmp
$ sudo mv /opt/Pixinsight/bin/lib/libtensor* /opt/pi_lib_tmp
# add to .bashrc
export TF_FORCE_GPU_ALLOW_GROWTH="true"
export CUDA_VISIBLE_DEVICES="0"
# start PixInsight and verify GPU is being used
Clear Skies!
Steve