Course Wiki

Installation of tensorflow — Machine Learning Zoomcamp Module 8

This installation guide is specific to the use case as in the pre-requisites. I'm not sure if it is similar for Mac/Linux native OSes or Other WSL2 Distros. Let me know either way if it does help.

Machine Learning Zoomcamp › Module 8: Neural Networks and Deep Learning › Installation of tensorflow

Notes

Installation of tensorflow

date: 2023 Nov 12

This installation guide is specific to the use case as in the pre-requisites. I’m not sure if it is similar for Mac/Linux native OSes or Other WSL2 Distros. Let me know either way if it does help.

Also, welcome to edit and make corrections directly (via PRs) or let me know via Slack.

pre-requisites

starting over or pre-install

windows host

  1. control panel –> Uninstall Cuda v??.?
  2. verify Nvidia driver is >= v450.xx (currently v546.01 as of @2023 Nov 12)
  3. download cuda executable for Win10
    • install following screen prompts, but select Custom Install, shorten the Path if desired. I’ve shorten from the defaults to just cuda
    • disable nsight, visual studio, GPU driver, GeForce Experience, HD Audio driver (if installed separately)
    • add to PATH manually or verify these are present; first 2 are mandatory, 3rd might be optional (I’m not sure):
      • C:\Program Files\cuda\v12.3\bin
      • C:\Program Files\cuda\v12.3\libnvvp
      • D:\Program Files\cuda\v12.3\extras\CUPTI\lib64
  4. cudnn-windows-x86_64-8.9.6.zip, download cudnn archive for other versions
    • unzip and drag contents into the C:\Program Files\cuda\v12.3\ where the matching bin, include and lib are located. Let the contents from cudnn*.zip replace the folders in the CUDA folder

wsl2 Ubuntu 22.04

source –> go to Ubuntu and Debian section

In the wsl2 Ubuntu terminal, clean up previous installs especially if on a different version

sudo apt-key del 7fa2af80
sudo apt-get --purge remove "*cuda*" "*cublas*" "*cufft*" "*cufile*" "*curand*" \
 "*cusolver*" "*cusparse*" "*gds-tools*" "*npp*" "*nvjpeg*" "nsight*" "*nvvm*"
sudo apt-get --purge remove "*nvidia*" "libxnvctrl*"
sudo apt-get autoremove
rm -rf "*.deb" "*.tar" "*.gz"

source: go here for exact version numbers, other than 12.3 @2023 Nov 12

wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/12.3.0/local_installers/cuda-repo-wsl-ubuntu-12-3-local_12.3.0-1_amd64.deb
sudo dpkg -i cuda-repo-wsl-ubuntu-12-3-local_12.3.0-1_amd64.deb
sudo cp /var/cuda-repo-wsl-ubuntu-12-3-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cuda-toolkit-12-3

post Install

export PATH=/usr/local/cuda-12.3/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-12.3/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

create new environment

micromamba create -n py310 python=3.10

activate environment

micromamba activate py310

install tensorflow

pip install 'tensorflow[and-cuda]'
or
python3 -m pip install 'tensorflow[and-cuda]'

Outcome:

in virtual environment

in wsl2

verify install

  1. Run test_tf.ipynb to check if GPU recognized, or
  2. Run the notebook.ipynb cells, and use nvidia-smi while it’s running. Ensure the corre

Key concepts

Sources


DataTalks.Club. Hosted on GitHub Pages. Built with Rustkyll. We use cookies.