Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yingshaoxo/b15febd86c5ed660e53cf538d541a94a to your computer and use it in GitHub Desktop.
Save yingshaoxo/b15febd86c5ed660e53cf538d541a94a to your computer and use it in GitHub Desktop.
How to install Nvidia Driver and Tensorflow/Pytorch GPU version in Ubuntu/PopOS 22.04 at HP Zbook Studio G8 laptop

1. Upgrade HP bios

You could directly use online bios update to update your bios fireware.


Reboot -> F2 -> Esc -> Set up WiFi -> reboot -> F10 -> update bios in a online way

Or you could use Windows system to do the update:

https://support.hp.com/us-en/document/ish_3894564-1633733-16

2. Switch to integrated graphics only mode

In popos, you can do it in right-top-corner icon, power settings.

In ubuntu, you can do it in nvidia-settings -> profile-settings -> use integrated graphics

reboot

3. Use gcc-12


which gcc



# if gcc is not gcc-12, then do the following

sudo rm /usr/bin/gcc

sudo ln -s /usr/bin/gcc-12 /usr/bin/gcc

4. Install nvidia special driver for your special gpu version

For me, it's GeForce RTX 3070 Mobile.

From the nvidia driver download page, you could download a file like NVIDIA-Linux-x86_64-525.105.17.run

https://www.nvidia.com/download/index.aspx?lang=en-us

Then you do the following:

sudo chmod 777 NVIDIA-Linux-x86_64-525.105.17.run

sudo ./NVIDIA-Linux-x86_64-525.105.17.run

5. Switch back to nvidia graphics only mode

reboot

Now, you should be able to use nvidia-smi to see the real-time gpu memory info

6. Install anaconda

https://conda.io/projects/conda/en/latest/user-guide/install/linux.html#installing-on-linux

Download a file look like Anaconda3-2023.03-Linux-x86_64.sh

sudo chmod 777 Anaconda3-2023.03-Linux-x86_64.sh

sudo ./Anaconda3-2023.03-Linux-x86_64.sh

7. Install cuda by using conda

Now, open a new terminal window

Then, try to install tensorflow by using script from tensorflow official documentation:

https://www.tensorflow.org/install/pip

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'))"

8. Done

author: @yingshaoxo

@demogit-code
Copy link

What is your video setting in the bios: uma/hybrid/discrete/auto ?

Can you use external monitors?

Tnx for the gist sofar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment