HOW TO install nVIDIA CUDA toolkit , cudnn and nvcc and tensorflow2.5.0+keras, and Pytorch on UBUNTU


 

HOW TO install nVIDIA CUDA toolkit and nvcc and tensorflow2.5.0+keras, and Pytorch on UBUNTU

I installed it on UBUNTU 20.04.

I using version 11.1  and the file is .deb to install:

because on the Pytorch website, they have the 11.1 version now, so I installed the 11.1 version.

but after few days, I found I can't using FFmpeg with GPU, then I purge all nvidia* and installed 11.3 version.


before install: 

before install, if your nVIDIA driver is higher than 455.23, you need to purge  Nvidia drivers:

sudo apt-get purge nvidia*

Install CUDA:

Cuda download page: https://developer.nvidia.com/cuda-11.1.0-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=2004&target_type=deblocal


using above page's command

Base Installer
Installation Instructions:
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pinsudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600wget https://developer.download.nvidia.com/compute/cuda/11.1.0/local_installers/cuda-repo-ubuntu2004-11-1-local_11.1.0-455.23.05-1_amd64.debsudo dpkg -i cuda-repo-ubuntu2004-11-1-local_11.1.0-455.23.05-1_amd64.debsudo apt-key add /var/cuda-repo-ubuntu2004-11-1-local/7fa2af80.pubsudo apt-get updatesudo apt-get -y install cuda


or for newest version cuda-toolkit 11.3

download page: https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=20.04&target_type=deb_local

Base Installer
Installation Instructions:
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pinsudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600wget https://developer.download.nvidia.com/compute/cuda/11.3.1/local_installers/cuda-repo-ubuntu2004-11-3-local_11.3.1-465.19.01-1_amd64.debsudo dpkg -i cuda-repo-ubuntu2004-11-3-local_11.3.1-465.19.01-1_amd64.debsudo apt-key add /var/cuda-repo-ubuntu2004-11-3-local/7fa2af80.pubsudo apt-get updatesudo apt-get -y install cuda


after installed, then you need to setup ~/.bashrc

$ nano ~/.bashrc


then Scroll to the bottom and add the following lines, you can change the red part to suit your version:

#NVIDIA CUDA Toolkitexport PATH=/usr/local/cuda-11.3/bin/:$PATHexport LD_LIBRARY_PATH=/usr/local/cuda-11.3/lib64


then execute

$ source ~/.bashrc


maybe reboot now is better:

$ sudo reboot now


then you can check your cuda-toolkit version and GPU driver version==>


$ nvidia-smi
$ nvcc --version



or 

or cuda-toolkit 11.3 with nvidia-driver-465.19




install cudnn:

cudnn download page: https://developer.nvidia.com/rdp/cudnn-download



tar -zxf cudnn-11.3-linux-x64-v8.2.0.53.tgz 

$ cd cuda

$ sudo cp -P lib64/* /usr/local/cuda/lib64/

$ sudo cp -P include/* /usr/local/cuda/include/

$ cd ~



install Tensorflow 2.5.0:

pip install tensorflow


if you install Keras's version is  higher than Tensorflow 2.0  (I installed the TensorFlow 2.5.0 in virtualenv), in Python, the Keras import need change to :

import tensorflow as tffrom tensorflow.keras import layers

after installed TensorFlow 2.5.0


install Pytorch:

then I installed Pytorch in virtualenv:

pip3 install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

then go to Python dialog to check version:




留言

這個網誌中的熱門文章

【多益】現點現做的英文怎麼說呢?

《Microsoft Word 應用》:圖片被文字蓋住解決方法,不可設定為固定行高

如何在Ubuntu系統上安裝Notepad ++ (Install Notepad++ On Ubuntu 16.04 / 17.10 / 18.04 / 20.04)