Installing CUDA 10.1, cuDNN, TensorFlow 2.3.0, and Python 3.8 on Ubuntu 20.04
I’m doing this on an AWS p3.2xlarge
instance with an NVIDIA Tesla v100 GPU.
Get the prerequisites
- Download the NVIDIA driver (
NVIDIA-Linux-x86_64-418.152.00.run
) from here. - Download the libcudnn packages from here (you need to sign up and login). Make sure to get version 7 for 10.1.
Download them into some folder:
I put these files in an S3 bucket then wget
them before running the following script.
Run these commands in whatever folder you download everything to:
# Update package lists and upgrade
sudo apt-get update && sudo apt-get dist-upgrade -y
# Install NVIDIA driver
sudo apt-get install -y build-essential
sudo sh NVIDIA-Linux-x86_64-418.152.00.run --ui=none --no-questions
# Install CUDA
sudo apt-get install -y nvidia-cuda-toolkit
# Install libcudnn
sudo dpkg -i libcudnn7*
# Install python 3
sudo apt-get install -y python3 python3-pip python3-virtualenv
# Create a virtualenv and install tensorflow 2.3.0 in it
virtualenv venv
./venv/bin/pip install --no-cache-dir tensorflow==2.3.0
./venv/bin/python -c 'import tensorflow as tf; print(tf.config.list_physical_devices("GPU"))'
The last line should print something like [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
.
Reboot the machine and you’re done.