# Enabling NVIDIA® GPUs for accelerating deep learning model training ## Prerequisites Before using NVIDIA® GPUs, ensure that you meet the following prerequisites: - System requirements - Ubuntu 22.04 LTS - Hardware requirements - NVIDIA® GPUs that meet the specifications outlined by TensorFlow in this [link](https://www.tensorflow.org/install/pip#hardware_requirements). ## Step-by-step instructions ### Option 1 (**Recommended**) - Step 1. Install NVIDIA® GPU drivers Install the [NVIDIA® GPU drivers](https://www.nvidia.com/en-us/drivers/unix/) with a minimum version of 525.60.13. For example, you can download and install the driver of 535.274.02 with the following commands. ```bash wget https://download.nvidia.com/XFree86/Linux-x86_64/535.274.02/NVIDIA-Linux-x86_64-535.274.02.run sudo sh NVIDIA-Linux-x86_64-535.274.02.run ``` Next, verify the installation using: ```bash nvidia-smi ``` - Step 2. Install CUDA Toolkit 12.5 Time Series Studio requires the [CUDA Toolkit 12.5](https://developer.nvidia.com/cuda-12-5-0-download-archive?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=22.04&target_type=runfile_local). You can install and config the CUDA Toolkit as follows. ```bash wget https://developer.download.nvidia.com/compute/cuda/12.5.0/local_installers/cuda_12.5.0_555.42.02_linux.run sudo sh cuda_12.5.0_555.42.02_linux.run ``` Next, you must add the following lines to your `~/.bashrc` file. ```bash export PATH=/usr/local/cuda-12.5/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda-12.5/lib64:$LD_LIBRARY_PATH ``` After you have added them to the `~/.bashrc` file, execute `source ~/.bashrc` and `sudo ldconfig`. - Step 3. Install cuDNN 9.3 Time Series Studio also requires [cuDNN 9.3](https://developer.nvidia.com/cudnn-9-3-0-download-archive?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=22.04&target_type=deb_network). You can install the cuDNN as follows. ```bash wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb sudo dpkg -i cuda-keyring_1.1-1_all.deb sudo apt-get update sudo apt-get -y install cudnn sudo apt-get -y install cudnn-cuda-12 ``` After installing the CUDA Toolkit and cuDNN, you can use the GPU to train integrated deep learning models in eIQ Time Series Studio. If either component is installed incorrectly. For example, if the version is incompatible, the GPU does not function properly during training. ### Option 2 - Step 1. Install NVIDIA® GPU drivers Install the [NVIDIA® GPU drivers](https://www.nvidia.com/en-us/drivers/unix/) with a minimum version of 525.60.13. For example, you can download and install the driver of 535.274.02 with the following commands. ```bash wget https://download.nvidia.com/XFree86/Linux-x86_64/535.274.02/NVIDIA-Linux-x86_64-535.274.02.run sudo sh NVIDIA-Linux-x86_64-535.274.02.run ``` Next, verify the installation using: ```bash nvidia-smi ``` - Step 2. Install Python 3.10.8 If you already have Python 3.10.8 installed, you can skip this step. If Python 3.10.8 is not installed, use a Python version management tool such as pyenv. Example: ```bash pyenv install 3.10.8 # set Python 3.10.8 globally pyenv global 3.10.8 ``` - Step 3. Create a virtual environment with [venv](https://docs.python.org/3/library/venv.html) Navigate to your preferred directory and create a virtual environment named `tss` using Python 3.10.8: ```bash python -m venv tss ``` Activate the environment: ```bash source tss/bin/activate ``` - Step 4. Install TensorFlow Upgrade pip to the latest version: ```bash pip install --upgrade pip ``` Then, install TensorFlow with CUDA support: ```bash pip install tensorflow[and-cuda]==2.18.1 ``` - Step 5. Configure environment variables After installing TensorFlow, locate the `nvidia` folder under your virtual environment. For example, `lib/python3.10/site-packages/nvidia`. Add the following lines to your `~/.bashrc` file, replacing `/your_path/` with the actual path: ```bash export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$(find /your_path/tss/lib/python3.10/site-packages/nvidia -type f -name "*.so*" -exec dirname {} \; | sort -u | paste -sd: -)" export XLA_FLAGS="--xla_gpu_cuda_data_dir=/your_path/tss/lib/python3.10/site-packages/nvidia/cuda_nvcc" ``` Reload the configuration: ```bash source ~/.bashrc ```