diff --git a/Models/model_sk_convnext_v1.py b/Models/model_sk_convnext_v1.py index 6b1637f..1440a9b 100644 --- a/Models/model_sk_convnext_v1.py +++ b/Models/model_sk_convnext_v1.py @@ -9,9 +9,16 @@ import matplotlib.pyplot as plt # This is the new 2026 version # This model was trained with 13,185 images -# See CNNImageProcessor solution for create the test images for training this model - - +# See CNNImageProcessor solution for creating the test images for training this model +# **************************************** I M P O R T A N T ******************************************************** +# Train the model on EUPORIE laptop using the GPU card with WSL2. (Windows Subsystem For Linux). I am running Ubuntu1 22.04.2 +# To launch WSL open up a command prompt, run powershell and type "wsl". +# The folder structure will be /home/pi/CNN. +# You can access the folder structure through windows explorer. type "\\wsl$" in explorer and navigate to the folder. +# drop in the Data and Model and run the model +# There is a shell script in the Scripts folder. setup_tf_gpu.sh Copy teh script to the CNN folder and run it. It will +# create the venv enviroment and install python 3.10 and tensorflow (gpu) +# ******************************************************************************************************************** # Figure out if we are training in CPU or GPU print("GPUs:", tf.config.list_physical_devices('GPU')) diff --git a/Scripts/setup_tf_gpu.sh b/Scripts/setup_tf_gpu.sh new file mode 100644 index 0000000..d76b354 --- /dev/null +++ b/Scripts/setup_tf_gpu.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +set -e + +echo "=====================================" +echo "TensorFlow GPU WSL Setup Script" +echo "=====================================" + +PROJECT_DIR="$HOME/CNN" +VENV_NAME="tf_gpu" + +echo "Updating system packages..." +sudo apt update +sudo apt install -y python3.10 python3.10-venv python3-pip + +echo "" +echo "Creating project directory if needed..." +mkdir -p $PROJECT_DIR + +cd $PROJECT_DIR + +echo "" +echo "Creating Python virtual environment..." +python3.10 -m venv $VENV_NAME + +echo "" +echo "Activating virtual environment..." +source $VENV_NAME/bin/activate + +echo "" +echo "Upgrading pip..." +pip install --upgrade pip + +echo "" +echo "Installing TensorFlow GPU build..." +pip install tensorflow[and-cuda]==2.19 + +echo "" +echo "Adding recommended TensorFlow environment variables..." + +BASHRC="$HOME/.bashrc" + +if ! grep -q TF_FORCE_GPU_ALLOW_GROWTH $BASHRC; then +echo "" >> $BASHRC +echo "# TensorFlow GPU settings" >> $BASHRC +echo "export TF_FORCE_GPU_ALLOW_GROWTH=true" >> $BASHRC +echo "export TF_CPP_MIN_LOG_LEVEL=2" >> $BASHRC +fi + +echo "" +echo "Testing TensorFlow GPU detection..." + +python <