Last modified on 01 Oct 2021.
Check if GPU available?
# check if GPU available?
import tensorflow as tf
tf.config.list_physical_devices('GPU')
Installation with docker
๐ Official guide.
๐ Docker & GPU note.
The advantage of this method is that you only have to install GPU driver on the host machine.
Without docker-compose
๐ Different types of images for tensorflow.
# pull the image
docker pull tensorflow/tensorflow:latest-gpu-jupyter
# run a container
mkdir ~/Downloads/test/notebooks
docker run --name docker_thi_test -it --rm -v $(realpath ~/Downloads/test/notebooks):/tf/notebooks -p 8888:8888 tensorflow/tensorflow:latest-gpu-jupyter
# check if gpu available?
nvidia-smi
# check if tf2 working?
docker exec -it docker_thi_test bash
python
import tensorflow as tf
tf.config.list_physical_devices('GPU')
With docker-compose?
๐ Read this note instead.
On Windows WSL2
Install directly on Linux (without docker)
On my computer, Dell XPS 15 7590 - NVIDIAยฎ GeForceยฎ GTX 1650 Mobile.
This section is not complete, the guide is still not working!
Installation
This guide is specific for:
pip show tensorflow # 2.3.1
pip show tensorflow-gpu # 2.3.1
nvidia-smi # NVIDIA-SMI 450.80.02 Driver Version: 450.80.02 CUDA Version: 11.0
๐ PyTorch note.
๐ Ubuntu note.
๐ Linux note.
CUDA Toolkit:
- If you meet Existing package manager installation of the driver found, try this method to remove some already-installed packages before continuing.
- Or you can download cuda toolkit
.run
and then run
sudo sh cuda_11.1.0_*.run --toolkit --silent --override
Errors?
# Could not load dynamic library 'libcudart.so.10.1'; dlerror: libcudart.so.10.1: cannot open shared object file: No such file or directory
Need to install new cuda & CUDNN libraries and tensorflow. (This note is for tensorflow==2.3.1
and CUDA 11.1
). [ref]
# update path
export PATH=/usr/local/cuda-11.1/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.1/lib\
${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
# quickly test cuda version
nvcc --version
โขNotes with this notation aren't good enough. They are being updated. If you can see this, you are so smart. ;)