How to install tensorflow/pytorch gpu version in ubuntu 20.04 at hp zbook studio g8 laptop

1. Install a special ubuntu system starting from HP website 

https://support.hp.com/hk-en/drivers/selfservice/hp-zbook-studio-15.6-inch-g8-mobile-workstation-pc/2100677682

Choose ubuntu, download the iso file, put it into a usb by using Balena Etcher, flush it into your laptop

2. After you get into the ubuntu20.04 system 

You could use nvidia-smi to check the GPU memory.

3. Install tensorflow by using anaconda

Tensorflow has a tutorial in here: https://www.tensorflow.org/install/pip

It’s something like this:


conda install -c conda-forge cudatoolkit=11.8.0
python3 -m pip install nvidia-cudnn-cu11==8.6.0.163 tensorflow==2.12.*
mkdir -p $CONDA_PREFIX/etc/conda/activate.d
echo 'CUDNN_PATH=$(dirname $(python -c "import nvidia.cudnn;print(nvidia.cudnn.__file__)"))' >> $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/:$CUDNN_PATH/lib' >> $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
source $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
# Verify install:
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

4. Install pytorch

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

https://pytorch.org/get-started/locally/

Verify it:

import torch
print(torch.cuda.is_available())