Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Instructions for CUDA v11.2 and cuDNN 8.1 installation on Ubuntu 20.04 for Pytorch 1.8 & Tensorflow 2.7.0
#!/bin/bash
### steps ####
# verify the system has a cuda-capable gpu
# download and install the nvidia cuda toolkit and cudnn
# setup environmental variables
# verify the installation
###
### to verify your gpu is cuda enable check
lspci | grep -i nvidia
### If you have previous installation remove it first.
sudo apt-get purge nvidia*
sudo apt remove nvidia-*
sudo rm /etc/apt/sources.list.d/cuda*
sudo apt-get autoremove && sudo apt-get autoclean
sudo rm -rf /usr/local/cuda*
# system update
sudo apt-get update
sudo apt-get upgrade
# install other import packages
sudo apt-get install g++ freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev
# first get the PPA repository driver
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
# install nvidia driver with dependencies
sudo apt install libnvidia-common-470
sudo apt install libnvidia-gl-470
sudo apt install nvidia-driver-470
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub
echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 /" | sudo tee /etc/apt/sources.list.d/cuda.list
sudo apt-get update
# installing CUDA-11.2
sudo apt install cuda-11-2
# setup your paths
echo 'export PATH=/usr/local/cuda-11.2/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-11.2/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc
sudo ldconfig
# install cuDNN v11.2
# For downloading cuDNN v11.2 you have to be regeistered here https://developer.nvidia.com/developer-program/signup
CUDNN_TAR_FILE="cudnn-11.2-linux-x64-v8.1.1.33.tgz"
wget https://developer.nvidia.com/compute/machine-learning/cudnn/secure/8.1.1.33/11.2_20210301/cudnn-11.2-linux-x64-v8.1.1.33.tgz
tar -xzvf ${CUDNN_TAR_FILE}
# copy the following files into the cuda toolkit directory.
sudo cp -P cuda/include/cudnn.h /usr/local/cuda-11.2/include
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda-11.2/lib64/
sudo chmod a+r /usr/local/cuda-11.2/lib64/libcudnn*
# Finally, to verify the installation, check
nvidia-smi
nvcc -V
# install Pytorch (an open source machine learning framework)
# I choose version 1.8.1 because it is stable and compatible with CUDA 11.2 Toolkit and cuDNN 8.1
pip3 install torch==1.8.1 torchvision==0.9.1
@haomingw
Copy link

haomingw commented Jul 2, 2018

line 32 should be ~/.bashrc?

@Mahedi-61
Copy link
Author

Mahedi-61 commented Jul 9, 2018

Yes. My mistake. Thanks for your correction.

@zosorock
Copy link

zosorock commented Aug 11, 2018

Shouldn't it include the updates as well? Or does the base always contains all patches? There are 4 patches in nVidia's website. By the way the latest cuDNN link is
https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v7.2.1/prod/9.0_20180806/cudnn-9.0-linux-x64-v7.2.1.38

@Mahedi-61
Copy link
Author

Mahedi-61 commented Aug 14, 2018

cuDNN link is now updated !

@kennethyu2017
Copy link

kennethyu2017 commented Sep 3, 2018

I tried on my ubuntu 18.04 and it works well, thanks for your kindly sharing ~

@indukantdeo
Copy link

indukantdeo commented Sep 4, 2018

Thanks a lot for sharing, it worked on my laptop.

@brookzee
Copy link

brookzee commented Sep 5, 2018

Thank you for the tut

@ast
Copy link

ast commented Sep 10, 2018

Thanks. This worked great with tensorflow-gpu on Ubuntu 18.04.

@chasedenecke
Copy link

chasedenecke commented Sep 13, 2018

Thanks! This guide is great!

@Elma-Landro
Copy link

Elma-Landro commented Sep 14, 2018

Hello guys and primarily, thank you to sharing this kinds of information.
So, i'm a noob and for instance i followed your guide from the begenning to the line #52 and then i'm blocked...
When you say "in order to download cuDNN you have to registered here https://developer.nvidia.com/developer-program/signup

then download cuDNN v7.2 form https://developer.nvidia.com/cudnn": i'm not sure what do you mean...

For my first trial, i I've logged to nvidia, and i download cuda v7.2.1.deb (https://developer.nvidia.com/rdp/cudnn-download) and open it directly with ubuntu appstore, but then the commande line #54 and following give nothing...
For a second trial, after erasing my first installation with appstore, i'm only log to nvidia site and then copy/past the comande line #54 and #55 but here the terminal give me
"elma@elma-UX32VD:$ CUDNN_TAR_FILE="cudnn-9.0-linux-x64-v7.2.1.38"
elma@elma-UX32VD:
$ wget https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v7.2.1/prod/9.0_20180806/${CUDNN_TAR_FILE}
--2018-09-14 17:14:46-- https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v7.2.1/prod/9.0_20180806/cudnn-9.0-linux-x64-v7.2.1.38
Résolution de developer.nvidia.com (developer.nvidia.com)… 192.229.182.215
Connexion à developer.nvidia.com (developer.nvidia.com)|192.229.182.215|:443… connecté.
requête HTTP transmise, en attente de la réponse… 403 Forbidden
2018-09-14 17:14:46 erreur 403 : Forbidden."

So i'm lost, can anyone may give me some advice (in the form of comande line) for helping me to finish this installation?

Thank a lot in advance

@Mahedi-61
Copy link
Author

Mahedi-61 commented Sep 16, 2018

May be some connectivity issues.

Never mind, In #55 instead of using wget
download "cuDNN v7.2.1 Library for Linux" for CUDA 9.0 manually from https://developer.nvidia.com/rdp/cudnn-download

then use command "scp" to your pure-terminal machine.

@Elma-Landro
Copy link

Elma-Landro commented Sep 16, 2018

hi, thank for answering!
But for instance, i understand nothing of what i have to do in your previous messge... i'm a blind noob! I can dowload it with the buntu app like in my first trial? and then, what is scp command? pure terminale machine? (sudo?)
Thank

@aaralh
Copy link

aaralh commented Sep 17, 2018

Thanks for this great guide!

@bikashg
Copy link

bikashg commented Sep 20, 2018

At the end, I had to exit the terminal running all these commands and start a new terminal so that the "nvcc -V" command was recognized. Overall, a great guide. Saved a plenty of frustrating hours.

@Elma-Landro
Copy link

Elma-Landro commented Sep 21, 2018

So guys, i understand that my low skill level is the main problem here... but i will try to improve myself. I understand that command #54 #55 correspond to downloading the CuDNN, i don't know why the command line respond me forbbiden but i can try to download it using GUI RIGHT? I have made this, (question what is the cuDNN i have to download exactly: cuDNN v7.3.0 Runtime Library for Ubuntu16.04 (Deb) or cuDNN v7.3.0 Developer Library for Ubuntu16.04 (Deb) or cuDNN v7.3.0 Library for Linux; i'm on Ubuntu 18.04) so normally the cuDNN is on my computer (i have try the Runtime... and the Dev Lib....)

after that, #56 #57: I need to copy some file from a direction to an other (if i try now my computer say that the file didn't exist: sudo cp -P cuda/include/cudnn.h /usr/local/cuda-9.0/include cp: impossible d'évaluer 'cuda/include/cudnn.h': Aucun fichier ou dossier de ce type; so it's inform me that the my Gui downloading doesn't give the good library no? when i check on usr/local/cuda or on usr/local/cuda-9 i don't found the cuda/include/cudnn.h nor cuda/lib64/libcudnn

Please someone, if you have any idea, respond me thank in advance

@idantene
Copy link

idantene commented Sep 27, 2018

Don't forget the cublas patches (1-4).
Great snippet though, thanks!

@Gambitier
Copy link

Gambitier commented Oct 6, 2018

I followed the script, but after restarting I encountered black screen for tty login instead of gui login screen.

@Gambitier
Copy link

Gambitier commented Oct 6, 2018

@Gambitier First of all I wasn't able to resolve that problem. I tried apt purge nvidia-*, but that didn't worked for me the problem persisted. So I freshly installed Ubuntu and followed the guide https://www.linuxbabe.com/desktop-linux/switch-intel-nvidia-graphics-card-ubuntu

The key point was to install recommended Nvidia driver, in my case it was 390. Then I followed rest of your script. Now it's working fine.

@aowais2
Copy link

aowais2 commented Oct 10, 2018

Lines 34 and 35 have a typo. Should be
chmod +x cuda_9.0.176_384.81_linux.run
instead of
chmod +x cuda_9.0.176_384.81_linux-run
Same with 35

@Mahedi-61
Copy link
Author

Mahedi-61 commented Oct 10, 2018

Thanks for your correction

@kmamine
Copy link

kmamine commented Oct 12, 2018

nvidea-smi not working
the following error is being displayed :
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running

every thing else is working !
but when i run a Keras Model it still uses CPU instead of GPU !! i have installed the keras -gpu package and the tensorflow-gpu package!

@mbrad26
Copy link

mbrad26 commented Oct 17, 2018

A bit of an issue:
chmod +x cuda_9.0.176_384.81_linux.run

returns:
chmod: cannot access 'cuda_9.0.176_384.81_linux.run': No such file or directory

Any ideas?

@developer0hye
Copy link

developer0hye commented Oct 20, 2018

Someone who has error to build openCV after installing cuda,

look at below links
opencv build gcc g++ compiler error
opencv build nvcc error

@danomois
Copy link

danomois commented Oct 21, 2018

Same issue as mbrad26:
chmod +x cuda_9.0.176_384.81_linux.run

returns:
chmod: cannot access 'cuda_9.0.176_384.81_linux.run': No such file or directory

FWIW the last line in the terminal before trying shows:
‘cuda_9.0.176_384.81_linux-run.3’ saved [252/252]

So, being a newbie I tried the command with -run, -run.3, .run, .run.3, unless I missed one it does not seem to be working.
Any help would be greatly appreciated - I'd be lost without this instruction

@Mahedi-61
Copy link
Author

Mahedi-61 commented Oct 22, 2018

@mbrad26 and @danomois, I think the problem may be due to broken file
One way to ensure the file is not broken is to manually check whether or not
the downloaded file cuda_9.0.176_384.81_linux-run file is 1.6 GB.

If you still have problem, try download it manually instead of using "wget" in terminal.

@danomois
Copy link

danomois commented Oct 22, 2018

Redownload is working so far!
Though with linux-run not linux.run
Also, there seemed to be some intermediate steps regarding location of install?
Anyway, will post again if more fun issues crop up
Thanks Again!

@danomois
Copy link

danomois commented Oct 22, 2018

Sigh
Any idea what to do with
***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 384.00 is required for CUDA 9.0 functionality to work.
To install the driver using this installer, run the following command, replacing with the name of this run file:
sudo .run -silent -driver

For my part, I'm not sure what to replace with to try?

@Mahedi-61
Copy link
Author

Mahedi-61 commented Oct 23, 2018

It's not a big deal ! Just ignore this warning.

May be it's due to the negation of the driver installation from the CUDA 9.0 package.

@hxyhxym
Copy link

hxyhxym commented Oct 25, 2018

nvidea-smi not working
the following error is being displayed :
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running

every thing else is working !
but when i run a Keras Model it still uses CPU instead of GPU !! i have installed the keras -gpu package and the tensorflow-gpu package!

hi,
I also have this problem, have you already solved this ?
thanks!

@venkatrebba
Copy link

venkatrebba commented Oct 31, 2018

It worked, thanks for sharing!

@VietTralala
Copy link

VietTralala commented Nov 8, 2018

A bit of an issue:
chmod +x cuda_9.0.176_384.81_linux.run

returns:
chmod: cannot access 'cuda_9.0.176_384.81_linux.run': No such file or directory

Any ideas?

This is probably due to the fact that the downloaded file is 'cuda_9.0.176_384.81_linux-run' but the commands in line 34 and 35 refer to 'cuda_9.0.176_384.81_linux.run'

Solution is to rename files I guess:

mv cuda_9.0.176_384.81_linux-run cuda_9.0.176_384.81_linux.run

@srcolinas
Copy link

srcolinas commented Nov 11, 2018

I followed this steps before installing TensorFlow. However, I got the following error when importing Tensorflow:
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory

@flxh
Copy link

flxh commented Nov 17, 2018

I followed this steps before installing TensorFlow. However, I got the following error when importing Tensorflow:
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory

Hey I had the same Issue. I got it fixed by running ldconfig, as suggested in this comment tensorflow/tensorflow#19375 (comment)

@ohenrik
Copy link

ohenrik commented Nov 22, 2018

After following your guide i got an error when trying to use CUDA with Tensorflow:
tensorflow/tensorflow#19266

The solution offered by @1Mr-Styler, worked for me:
sudo apt install nvidia-modprobe

tensorflow/tensorflow#19266 (comment)

@NightFantom
Copy link

NightFantom commented Nov 24, 2018

nvidea-smi not working
the following error is being displayed :
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running
every thing else is working !
but when i run a Keras Model it still uses CPU instead of GPU !! i have installed the keras -gpu package and the tensorflow-gpu package!

hi,
I also have this problem, have you already solved this ?
thanks!

I had it. But after reboot of OS it worked.

@wonderingabout
Copy link

wonderingabout commented Nov 28, 2018

@Mahedi-61

the no such file or directory issue is due to a typo in the name :
(you notice it with ls command)

first, for ubuntu 18.04 forget all what is written here

this is full of compatibility issues

follow these instructions to install cuda 9.0 and cudnn 7.0 for cuda 9.0 in ubuntu 18.04 LTS

first :
i dont recommend using ppa, biggest chance to mess up everything :
just install nvidia-384 (without dev), then reboot, is fine

then i recommend following nvidia official instructions

for ubuntu 18.04 you have to use run file for both cuda and cudnn (no .deb for ubuntu 18.04 cuda 9.0 : max deb file 16.04 for cuda 9.0) :

https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#runfile
https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#installcuda

and/or (better) these (it's for ubuntu 16.04 but you can adapt it) :
https://medium.com/@zhanwenchen/install-cuda-and-cudnn-for-tensorflow-gpu-on-ubuntu-79306e4ac04e

during cuda install, it's easier to use nano than vim to edit files though
in nano (^ = ctrl, so it's ctrl+x to save modfications, then press enter), you can verify that file has been modified by relaunching it, then reboot to run sample tests

after reboot, to run sample tests you need to use update-alternatives to install gcc-6 and g++-6 instead of the default gcc7
you will need gcc6 and g++6 max for cuda 9 and then test samples for cuda :
https://askubuntu.com/a/1039919
https://forum.libreelec.tv/thread/12368-fixed-compilation-under-ubuntu-18-04-lts/

gcc --version && g++ --version && sudo apt-get -y install gcc-6 && sudo apt-get -y install g++-6 && sudo update-alternatives --install "/usr/bin/gcc" "gcc" "/usr/bin/gcc-6" 60 --slave "/usr/bin/g++" "g++" "/usr/bin/g++-6" && sudo update-alternatives --config gcc && gcc --version && g++ --version

if you do it like that cuda install works and test sample works too :

./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "Tesla K80"
  CUDA Driver Version / Runtime Version          9.1 / 9.0
  CUDA Capability Major/Minor version number:    3.7
  Total amount of global memory:                 11441 MBytes (11996954624 bytes)
  (13) Multiprocessors, (192) CUDA Cores/MP:     2496 CUDA Cores
  GPU Max Clock rate:                            824 MHz (0.82 GHz)
  Memory Clock rate:                             2505 Mhz
  Memory Bus Width:                              384-bit
  L2 Cache Size:                                 1572864 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
  Maximum Layered 1D Texture Size, (num) layers  1D=(16384), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(16384, 16384), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  2048
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 2 copy engine(s)
  Run time limit on kernels:                     No
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Enabled
  Device supports Unified Addressing (UVA):      Yes
  Supports Cooperative Kernel Launch:            No
  Supports MultiDevice Co-op Kernel Launch:      No
  Device PCI Domain ID / Bus ID / location ID:   0 / 0 / 4
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 9.1, CUDA Runtime Version = 9.0, NumDevs = 1
Result = PASS

then for cudnn run file, you can use this trick to wget cudnn run file on ubuntu 18.04 on command line
https://stackoverflow.com/questions/31279494/how-to-install-cudnn-from-command-line

download cudnn 7.0.x for CUDA 9.0 (tar.gz archive for universal linux, includes ubuntu 18.04)

it would be easier to use .deb for ubuntu, but max is ubuntu 16.04 for cudnn 7.0
still, run files (library tar gz file) are universal so let's learn how to do it ! :)
(cant use deb because max is ubuntu 16.04 as explained here :
https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#installcuda

download from (need to create an account, free) :
https://developer.nvidia.com/rdp/cudnn-archive

first use this trick to download cudnn using your firefox link :
https://stackoverflow.com/a/49752272

then "copy original download URL"
and do, for example :
wget PASTE-YOUR-COPIED-LINK-HERE

the link is something like this (unique token that will expire) , for example :
for example :
wget https://developer.download.nvidia.com/compute/machine-learning/cudnn/secure/v7.0.5/prod/9.0_20171129/cudnn-9.0-linux-x64-v7.tgz?oj-SZ9vkkWyIVSb6YfUo6ci2jqR9-E117-7xmyoTFs5h5K3Tnuej1bTtJmGKXIa-V8WFUcevldjedUL2JlYCchL0SNA_wZlzMlc_rJ4Vktc4fbC2bpNZmk8Q-nHcRnIcdGSmVT0YIkBkAglzwcEGP5s9yfx4YlgQhL50yfQNdV6ddTC77StJUKjyLrcH246nbJvvGVn5h94

then rename it to remove temporary download token
The downloaded filename is libcudnn***.deb?. You will need to rename it by stripping the ? and everything after it:

ls to list files then copy name from ls result, then rename it removing :

ls
NVIDIA-Linux-x86_64-384.81.run
cuda-linux.9.0.176-22781540.run
cuda-samples.9.0.176-22781540-linux.run
cuda_9.0.176_384.81_linux-run
'cudnn-9.0-linux-x64-v7.tgz?oj-SZ9vkkWyIVSb6YfUo6ci2jqR9-E117-7xmyoTFs5h5K3Tnuej1bTtJmGKXIa-V8WFUcevldjedUL2JlYCchL0SNA_wZlzMlc_rJ4Vktc4fbC2bpNZmk8Q-nHcRnIcdGSmVT0YIkBkAglzwcEGP5s9yfx4YlgQhL50yfQNdV6ddTC77StJUKjyLrcH246nbJvvGVn5h94'

for example :

mv cudnn-9.0-linux-x64-v7.tgz?oj-SZ9vkkWyIVSb6YfUo6ci2jqR9-E117-7xmyoTFs5h5K3Tnuej1bTtJmGKXIa-V8WFUcevldjedUL2JlYCchL0SNA_wZlzMlc_rJ4Vktc4fbC2bpNZmk8Q-nHcRnIcdGSmVT0YIkBkAglzwcEGP5s9yfx4YlgQhL50yfQNdV6ddTC77StJUKjyLrcH246nbJvvGVn5h94 cudnn-9.0-linux-x64-v7.tgz

result :

ls
NVIDIA-Linux-x86_64-384.81.run cuda-samples.9.0.176-22781540-linux.run cudnn-9.0-linux-x64-v7.tgz
cuda-linux.9.0.176-22781540.run cuda_9.0.176_384.81_linux-run

"install" (more like extract) cudnn 7.0.x for CUDA 9.0 (linux) :

these instructions look great :
https://medium.com/@taylordenouden/installing-tensorflow-gpu-on-ubuntu-18-04-89a142325138

Unpack the archive
tar -zxvf cudnn-9.0-linux-x64-v7.tgz

result :
cuda/include/cudnn.h
cuda/NVIDIA_SLA_cuDNN_Support.txt
cuda/lib64/libcudnn.so
cuda/lib64/libcudnn.so.7
cuda/lib64/libcudnn.so.7.0.5
cuda/lib64/libcudnn_static.a

Move the unpacked contents to your CUDA directory, then # Give read access to all users, Install libcupti, Do the CUDA post-install actions So Tensorflow can find your CUDA installation and use it properly, you need to add these lines to the end of you ~/.bashrc or ~/.zshrc.

sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda-9.0/lib64/ && sudo cp cuda/include/cudnn.h /usr/local/cuda-9.0/include/ && sudo chmod a+r /usr/local/cuda-9.0/include/cudnn.h /usr/local/cuda/lib64/libcudnn* && sudo apt-get -y install libcupti-dev && export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}} && export LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} && sudo reboot

reboot is needed
if all went it will reboot

revert to gcc7 and g++7 for the future :

last thing, you probably dont need gcc6 and g++6 so revert to gcc7 and g++7

https://codeyarns.com/2015/02/26/how-to-switch-gcc-version-using-update-alternatives/

select the version you want :

gcc --version && g++ --version && sudo apt-get -y install gcc-7 && sudo apt-get -y install g++-7 && sudo update-alternatives --install "/usr/bin/gcc" "gcc" "/usr/bin/gcc-7" 60 --slave "/usr/bin/g++" "g++" "/usr/bin/g++-7" && sudo update-alternatives --config gcc && gcc --version && g++ --version && sudo reboot

reboot is needed

thats it !

hope this helps

@Rahul-Venugopal
Copy link

Rahul-Venugopal commented Dec 13, 2018

Hi ,
Now I am not able to find cudNN7.2 for cuda 9.0 in nvidia site. Will this steps work if I download cudNN 7.4 for cuda 9.0 ?

@Mahedi-61
Copy link
Author

Mahedi-61 commented Dec 13, 2018

Sure.
Just change the script according to updated cuDNN link.

@lz-chen
Copy link

lz-chen commented Dec 26, 2018

Thanks a lot for sharing! I tried it with with tensorflow-gpu on Ubuntu 18.04 and it works:)

@YangLiu14
Copy link

YangLiu14 commented Jan 6, 2019

This method works on my Ubuntu 18.04, thank you for writing this tutorial!

@Yossarian0916
Copy link

Yossarian0916 commented Jan 12, 2019

Thank you a lot! The script is of great help.

@siddhantkaushal
Copy link

siddhantkaushal commented Jan 16, 2019

Hello Friends,

Stuck at line number 54.
getting forbidden error..

Please assist

@zuoanqh
Copy link

zuoanqh commented Jan 18, 2019

line 34 and 35 needs to end with "-run" not ".run". look at line 31: the file name ends with "-run".

@Mahedi-61
Copy link
Author

Mahedi-61 commented Jan 19, 2019

Nope. It's alright.
Check the downloaded file.

@DanielRobertAppel
Copy link

DanielRobertAppel commented Jan 31, 2019

Line 34 : in-which you are making the cuda download executable (chmod +x) you have a typo.

Current line: chmod +x cuda_9.0.176_384.81_linux.run
Should Be: chmod +x cuda_9.0.176_384.81_linux-run

Line 35: in-which you are executing the cuda download. Same typo.

Current line: sudo ./cuda_9.0.176_384.81_linux.run --override
Should Be: sudo ./cuda_9.0.176_384.81_linux-run --override

@raeidsaqur
Copy link

raeidsaqur commented Feb 6, 2019

Thanks for compiling this. Might want to add the cuBLAS patches installation after cuda toolkit archive.

@remeus
Copy link

remeus commented Feb 8, 2019

It seems to work. Thanks for the wrap-up!

@i-chaochen
Copy link

i-chaochen commented Mar 5, 2019

Same problem for nvidia-smi. Anyone knows how to solve it?

I tried to install NVIDIA drive 384 and 390, both of them have the following same error.

$ nvidia-smi
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

My nvcc is fine thought.
$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Sep__1_21:08:03_CDT_2017
Cuda compilation tools, release 9.0, V9.0.176

I can't run nvidia-settings as well.

$ nvidia-settings

ERROR: NVIDIA driver is not loaded

ERROR: Unable to load info from any available system

@biphasic
Copy link

biphasic commented Mar 7, 2019

NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.
had the same issue after fresh 18.04.2 install. Disabled secure boot and it worked!

@Nova-Scotia
Copy link

Nova-Scotia commented Mar 15, 2019

I had an error when checking to see if the install was successful. I rebooted and then checked the install; it worked.

@dsysoev
Copy link

dsysoev commented Apr 28, 2019

Correct filename cuda_9.0.176_384.81_linux-run (instead cuda_9.0.176_384.81_linux.run ) in line 34 and 35.
Please fix it.

@prameshbajra
Copy link

prameshbajra commented May 12, 2019

NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.
had the same issue after fresh 18.04.2 install. Disabled secure boot and it worked!

Having the same issue. Any help?

@jisnava
Copy link

jisnava commented May 16, 2019

It's working Thanq

@mcanet
Copy link

mcanet commented May 17, 2019

I am not able to download install cuDNN v7.2 or 7.5 (lastest in nvidia cuDNN website) in terminal and i cannot use manual download throught browser since i am using a cloud machine with only ssh remote control.

@prameshbajra
Copy link

prameshbajra commented May 17, 2019

@mcanet You can download it into your local machine and the upload the downloaded tar.gz into your cloud machine. Also, can you please tell us what cloud machine are you referring to? May be I can help by providing a step wise answer.

@raniaoueslati
Copy link

raniaoueslati commented Jun 23, 2019

Same problem for nvidia-smi. Anyone knows how to solve it?

I tried to install NVIDIA drive 384 and 390, both of them have the following same error.

$ nvidia-smi
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

My nvcc is fine thought.
$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Sep__1_21:08:03_CDT_2017
Cuda compilation tools, release 9.0, V9.0.176

I can't run nvidia-settings as well.

$ nvidia-settings

ERROR: NVIDIA driver is not loaded

ERROR: Unable to load info from any available system

I have this same error plz how to slove it ?

@John-Almardeny
Copy link

John-Almardeny commented Oct 25, 2019

You need:

sudo apt-get update

before

sudo apt-get -o Dpkg::Options::="--force-overwrite" install cuda-10-0 cuda-drivers 

@aivf-compute
Copy link

aivf-compute commented Oct 29, 2019

great tutorial!
I couldn't execute:
"sudo apt-get -o Dpkg::Options::="--force-overwrite" install cuda-10-0 cuda-drivers"
i got "Unable to locate package cuda-10-0"

i needed to download manually the cuda deb file and to execute the following lines:
sudo dpkg -i cuda-repo-ubuntu1604-9-2-local_9.2.148-1_amd64.deb
sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub
sudo apt-get update

@valdezf10
Copy link

valdezf10 commented Nov 10, 2019

Hi,

I have been following the steps to install CUDA and tensorflow but when I get to the following step

-Finally, to verify the installation, check

nvidia-smi
nvcc -V

nvidia-smi output:
Failed to initialize NVML: Driver/library version mismatch

nvcc -V output:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130

I am using an RTX 2070 Super and have previously installed an NVIDIA driver 440.35 (neweste version) in Ubuntu 18.04
Any help would be greatly appreciate it!

@Mahedi-61
Copy link
Author

Mahedi-61 commented Nov 11, 2019

You have probably mixed a previous runfile install with this current install (apt-get).
May a reboot can help

@Ankitjaiswal1201
Copy link

Ankitjaiswal1201 commented Nov 14, 2019

rstudio/keras#461 (comment)

Cudnn 7.5 is not supported with Tensorflow. It caused me some issues later after installing cudnn 7.5. So install cudnn 7.4 to avoid it.

https://www.tensorflow.org/install/source#linux

@rpvelloso
Copy link

rpvelloso commented Dec 15, 2019

Hi,

I have been following the steps to install CUDA and tensorflow but when I get to the following step

-Finally, to verify the installation, check

nvidia-smi
nvcc -V

nvidia-smi output:
Failed to initialize NVML: Driver/library version mismatch

nvcc -V output:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130

I am using an RTX 2070 Super and have previously installed an NVIDIA driver 440.35 (neweste version) in Ubuntu 18.04
Any help would be greatly appreciate it!

same problem here. Did you solved it? How?

@mxochicale
Copy link

mxochicale commented Jan 22, 2020

Hi,
I have been following the steps to install CUDA and tensorflow but when I get to the following step
-Finally, to verify the installation, check

nvidia-smi
nvcc -V

nvidia-smi output:
Failed to initialize NVML: Driver/library version mismatch
nvcc -V output:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130
I am using an RTX 2070 Super and have previously installed an NVIDIA driver 440.35 (neweste version) in Ubuntu 18.04
Any help would be greatly appreciate it!

same problem here. Did you solved it? How?

For the output of nvidia-smi I reboot my machine and for the nvcc -V I forget to activate my virtual environment which fixed the problem by simply source ~/.bashrc.

Many thanks @Mahedi-61 for your nice script!

@tahakucukkatirci
Copy link

tahakucukkatirci commented Mar 26, 2020

Great script. Thanks for sharing. You saved me hours.

@MittalShruti
Copy link

MittalShruti commented Apr 1, 2020

I installed cuda10.1 on google colab.
After source ~/.bashrc, I get
on running
!nvcc -V
/bin/bash: nvcc: command not found

@espoirMur
Copy link

espoirMur commented May 3, 2020

@Mahedi-61, Line 38 , we should also do :

sudo apt-get update

@espoirMur
Copy link

espoirMur commented May 3, 2020

@Mahedi-61

the no such file or directory issue is due to a typo in the name :
(you notice it with ls command)

first, for ubuntu 18.04 forget all what is written here

this is full of compatibility issues

follow these instructions to install cuda 9.0 and cudnn 7.0 for cuda 9.0 in ubuntu 18.04 LTS

first :
i dont recommend using ppa, biggest chance to mess up everything :
just install nvidia-384 (without dev), then reboot, is fine

then i recommend following nvidia official instructions

for ubuntu 18.04 you have to use run file for both cuda and cudnn (no .deb for ubuntu 18.04 cuda 9.0 : max deb file 16.04 for cuda 9.0) :

https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#runfile
https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#installcuda

and/or (better) these (it's for ubuntu 16.04 but you can adapt it) :
https://medium.com/@zhanwenchen/install-cuda-and-cudnn-for-tensorflow-gpu-on-ubuntu-79306e4ac04e

during cuda install, it's easier to use nano than vim to edit files though
in nano (^ = ctrl, so it's ctrl+x to save modfications, then press enter), you can verify that file has been modified by relaunching it, then reboot to run sample tests

after reboot, to run sample tests you need to use update-alternatives to install gcc-6 and g++-6 instead of the default gcc7
you will need gcc6 and g++6 max for cuda 9 and then test samples for cuda :
https://askubuntu.com/a/1039919
https://forum.libreelec.tv/thread/12368-fixed-compilation-under-ubuntu-18-04-lts/

gcc --version && g++ --version && sudo apt-get -y install gcc-6 && sudo apt-get -y install g++-6 && sudo update-alternatives --install "/usr/bin/gcc" "gcc" "/usr/bin/gcc-6" 60 --slave "/usr/bin/g++" "g++" "/usr/bin/g++-6" && sudo update-alternatives --config gcc && gcc --version && g++ --version

if you do it like that cuda install works and test sample works too :

./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "Tesla K80"
  CUDA Driver Version / Runtime Version          9.1 / 9.0
  CUDA Capability Major/Minor version number:    3.7
  Total amount of global memory:                 11441 MBytes (11996954624 bytes)
  (13) Multiprocessors, (192) CUDA Cores/MP:     2496 CUDA Cores
  GPU Max Clock rate:                            824 MHz (0.82 GHz)
  Memory Clock rate:                             2505 Mhz
  Memory Bus Width:                              384-bit
  L2 Cache Size:                                 1572864 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
  Maximum Layered 1D Texture Size, (num) layers  1D=(16384), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(16384, 16384), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  2048
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 2 copy engine(s)
  Run time limit on kernels:                     No
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Enabled
  Device supports Unified Addressing (UVA):      Yes
  Supports Cooperative Kernel Launch:            No
  Supports MultiDevice Co-op Kernel Launch:      No
  Device PCI Domain ID / Bus ID / location ID:   0 / 0 / 4
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 9.1, CUDA Runtime Version = 9.0, NumDevs = 1
Result = PASS

then for cudnn run file, you can use this trick to wget cudnn run file on ubuntu 18.04 on command line
https://stackoverflow.com/questions/31279494/how-to-install-cudnn-from-command-line

download cudnn 7.0.x for CUDA 9.0 (tar.gz archive for universal linux, includes ubuntu 18.04)

it would be easier to use .deb for ubuntu, but max is ubuntu 16.04 for cudnn 7.0
still, run files (library tar gz file) are universal so let's learn how to do it ! :)
(cant use deb because max is ubuntu 16.04 as explained here :
https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#installcuda

download from (need to create an account, free) :
https://developer.nvidia.com/rdp/cudnn-archive

first use this trick to download cudnn using your firefox link :
https://stackoverflow.com/a/49752272

then "copy original download URL"
and do, for example :
wget PASTE-YOUR-COPIED-LINK-HERE

the link is something like this (unique token that will expire) , for example :
for example :
wget https://developer.download.nvidia.com/compute/machine-learning/cudnn/secure/v7.0.5/prod/9.0_20171129/cudnn-9.0-linux-x64-v7.tgz?oj-SZ9vkkWyIVSb6YfUo6ci2jqR9-E117-7xmyoTFs5h5K3Tnuej1bTtJmGKXIa-V8WFUcevldjedUL2JlYCchL0SNA_wZlzMlc_rJ4Vktc4fbC2bpNZmk8Q-nHcRnIcdGSmVT0YIkBkAglzwcEGP5s9yfx4YlgQhL50yfQNdV6ddTC77StJUKjyLrcH246nbJvvGVn5h94

then rename it to remove temporary download token
The downloaded filename is libcudnn***.deb?. You will need to rename it by stripping the ? and everything after it:

ls to list files then copy name from ls result, then rename it removing :

ls
NVIDIA-Linux-x86_64-384.81.run
cuda-linux.9.0.176-22781540.run
cuda-samples.9.0.176-22781540-linux.run
cuda_9.0.176_384.81_linux-run
'cudnn-9.0-linux-x64-v7.tgz?oj-SZ9vkkWyIVSb6YfUo6ci2jqR9-E117-7xmyoTFs5h5K3Tnuej1bTtJmGKXIa-V8WFUcevldjedUL2JlYCchL0SNA_wZlzMlc_rJ4Vktc4fbC2bpNZmk8Q-nHcRnIcdGSmVT0YIkBkAglzwcEGP5s9yfx4YlgQhL50yfQNdV6ddTC77StJUKjyLrcH246nbJvvGVn5h94'

for example :

mv cudnn-9.0-linux-x64-v7.tgz?oj-SZ9vkkWyIVSb6YfUo6ci2jqR9-E117-7xmyoTFs5h5K3Tnuej1bTtJmGKXIa-V8WFUcevldjedUL2JlYCchL0SNA_wZlzMlc_rJ4Vktc4fbC2bpNZmk8Q-nHcRnIcdGSmVT0YIkBkAglzwcEGP5s9yfx4YlgQhL50yfQNdV6ddTC77StJUKjyLrcH246nbJvvGVn5h94 cudnn-9.0-linux-x64-v7.tgz

result :

ls
NVIDIA-Linux-x86_64-384.81.run cuda-samples.9.0.176-22781540-linux.run cudnn-9.0-linux-x64-v7.tgz
cuda-linux.9.0.176-22781540.run cuda_9.0.176_384.81_linux-run

"install" (more like extract) cudnn 7.0.x for CUDA 9.0 (linux) :

these instructions look great :
https://medium.com/@taylordenouden/installing-tensorflow-gpu-on-ubuntu-18-04-89a142325138

Unpack the archive
tar -zxvf cudnn-9.0-linux-x64-v7.tgz

result :
cuda/include/cudnn.h
cuda/NVIDIA_SLA_cuDNN_Support.txt
cuda/lib64/libcudnn.so
cuda/lib64/libcudnn.so.7
cuda/lib64/libcudnn.so.7.0.5
cuda/lib64/libcudnn_static.a

Move the unpacked contents to your CUDA directory, then # Give read access to all users, Install libcupti, Do the CUDA post-install actions So Tensorflow can find your CUDA installation and use it properly, you need to add these lines to the end of you ~/.bashrc or ~/.zshrc.

sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda-9.0/lib64/ && sudo cp cuda/include/cudnn.h /usr/local/cuda-9.0/include/ && sudo chmod a+r /usr/local/cuda-9.0/include/cudnn.h /usr/local/cuda/lib64/libcudnn* && sudo apt-get -y install libcupti-dev && export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}} && export LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} && sudo reboot

reboot is needed
if all went it will reboot

revert to gcc7 and g++7 for the future :

last thing, you probably dont need gcc6 and g++6 so revert to gcc7 and g++7

https://codeyarns.com/2015/02/26/how-to-switch-gcc-version-using-update-alternatives/

select the version you want :

gcc --version && g++ --version && sudo apt-get -y install gcc-7 && sudo apt-get -y install g++-7 && sudo update-alternatives --install "/usr/bin/gcc" "gcc" "/usr/bin/gcc-7" 60 --slave "/usr/bin/g++" "g++" "/usr/bin/g++-7" && sudo update-alternatives --config gcc && gcc --version && g++ --version && sudo reboot

reboot is needed

thats it !

hope this helps

Bro, you are a lifesaver the firefox download lin link..... @nahedi-61 , we should include it in the guide

@Kreyren
Copy link

Kreyren commented May 14, 2020

Sorry, but this is shell malware that none should be using namely:

  1. Lack of sanitization so code alike https://gist.github.com/Mahedi-61/2a2f1579d4271717d421065168ce6a73#file-cuda_10-1_installation_on_ubuntu_18-04-L45 is placing these lines on every invokation resulting in overwhelming spam.

You should be using something alike:

if ! grep pattern path/to/file; then printf '%s\n' "expected content" > path/to/file; fi
  1. Other various issues mensioned on https://shellcheck.net/?id=cb40763 -> ALWAYS use shellcheck (linting) if you are writing a shell/bash script

I am willing to make a contribution if you provide an abstract to what needs to be done and why as in-code documentation and assuming this being released under FSF approved license

@naknakLEE
Copy link

naknakLEE commented Jun 3, 2020

Thanks for this great guide!

@supersexy
Copy link

supersexy commented Jun 24, 2020

@Kreyren - where can I download your much better version of this? I can not find it. Thanks!

@Kreyren
Copy link

Kreyren commented Jun 24, 2020

@supersexy I would need an abstract for that version meaning what the script should do, how and when which wasn't provided yet and i am not motivated enough to try to reverse engineer it.

@gcvoigt
Copy link

gcvoigt commented Jul 17, 2020

Thanks! Help me a lot!

@hazkaz
Copy link

hazkaz commented Oct 15, 2020

Jesus! NVIDIA is messing with us! Like seriously? I had to go through so many installation tutorials and finally a golden gem of a gist linked on some answer in stack overflow works? That's just messed up man! The official documentation just doesn't work. Anyway I found out from here that I had to add another line to make it work when using cuda 10.1 ...

export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

any guesses why though? cause nvidia installs some 10.2 components when installing 10.1. who would have thunk?
anyway peace out and much thanks my man @Mahedi-61

@AndreiMiculita
Copy link

AndreiMiculita commented Nov 21, 2020

@supersexy I would need an abstract for that version meaning what the script should do, how and when which wasn't provided yet and i am not motivated enough to try to reverse engineer it.

Wow, zero willingness to help, zero willingness to give more detail, just complaining about linter warnings on some code you found on the internet. And malware, talk about crying wolf.

I'll address your complaints:

  • the paths will be reappended every time the script runs source ~/.bashrc. So, once. Hardly overwhelming, and not at all spam. If you care so much about having an aesthetically-pleasing $PATH variable, there are scripts on the internet that can remove duplicates, and it gets reset to $(getconf PATH) anyway (probably on reboot).
  • the expressions in lines 45-46 are supposed to be non-expanding since they are written to .bashrc, not executed

There is zero reverse-engineering needed here as you have full access to the sources and documentation (if we're taking ourselves so seriously about a 71-line script).

@rnrpereira
Copy link

rnrpereira commented Dec 8, 2020

What if I want to install cuda 10.0 ? Is the same sequence of instructions? thanx

@apiszcz
Copy link

apiszcz commented Jan 1, 2021

Unpacking xfonts-base (1:1.0.4+nmu1) ...
Errors were encountered while processing:
/tmp/apt-dpkg-install-0cZNOW/106-libnvidia-compute-460_460.27.04-0ubuntu1_amd64.deb
/tmp/apt-dpkg-install-0cZNOW/107-libnvidia-decode-460_460.27.04-0ubuntu1_amd64.deb
/tmp/apt-dpkg-install-0cZNOW/108-libnvidia-encode-460_460.27.04-0ubuntu1_amd64.deb
/tmp/apt-dpkg-install-0cZNOW/109-libnvidia-fbc1-460_460.27.04-0ubuntu1_amd64.deb
/tmp/apt-dpkg-install-0cZNOW/110-libnvidia-gl-460_460.27.04-0ubuntu1_amd64.deb
/tmp/apt-dpkg-install-0cZNOW/111-libnvidia-ifr1-460_460.27.04-0ubuntu1_amd64.deb
/tmp/apt-dpkg-install-0cZNOW/112-nvidia-compute-utils-460_460.27.04-0ubuntu1_amd64.deb
/tmp/apt-dpkg-install-0cZNOW/117-libnvidia-extra-460_460.27.04-0ubuntu1_amd64.deb
/tmp/apt-dpkg-install-0cZNOW/118-nvidia-utils-460_460.27.04-0ubuntu1_amd64.deb
/tmp/apt-dpkg-install-0cZNOW/119-libnvidia-cfg1-460_460.27.04-0ubuntu1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

@hongweilibran
Copy link

hongweilibran commented Jan 8, 2021

the best tutorial that saves my life!!!!!

@guruvishnuvardan
Copy link

guruvishnuvardan commented Jan 8, 2021

Yes, It's the best Tensorflow Installation Guide, I had resolved all my previous issues.

@MAMOMIMOMU
Copy link

MAMOMIMOMU commented Jan 21, 2021

If you run this on shell, tensorflow recognizes gpus?
I ran this shell script, and seemed like there was no problem running it, but tensorflow-gpu still doesn't recognize gpus.
Tensorflow-gpu version is 2.3.0 and this version must also be compatible with cuda 10.1 and cudnn 7.6.

@jrincon23
Copy link

jrincon23 commented Mar 12, 2021

If you run this on shell, tensorflow recognizes gpus?
I ran this shell script, and seemed like there was no problem running it, but tensorflow-gpu still doesn't recognize gpus.
Tensorflow-gpu version is 2.3.0 and this version must also be compatible with cuda 10.1 and cudnn 7.6.

Try this
sudo apt-get install -y --no-install-recommends
cuda-10-1
libcudnn7=7.6.0.64-1+cuda10.1
libcudnn7-dev=7.6.0.64-1+cuda10.1;

sudo apt-get install -y --no-install-recommends
libnvinfer6=6.0.1-1+cuda10.1
libnvinfer-dev=6.0.1-1+cuda10.1
libnvinfer-plugin6=6.0.1-1+cuda10.1;

also as someone above said, cuda 10.1 install some cuda 10.2 components

@KnightOfTheMoonlight
Copy link

KnightOfTheMoonlight commented Jun 22, 2021

it works on my pc. Thanks!

@riyaj8888
Copy link

riyaj8888 commented Oct 2, 2021

can you tell what changes should be done for cuda 11.1 in 18.04 ubuntu system.

Thanks

@kikefdezl
Copy link

kikefdezl commented Nov 2, 2021

Was having issues getting the TensorFlow Object Detection API to work without errors. This guide worked for Ubuntu 20.04, CUDA 11.2, CuDNN 8.1.0 and TensorFlow 2.6.

Thanks a lot!

@yummyKnight
Copy link

yummyKnight commented Nov 7, 2021

@mnielsen There is extra i in sudo apt install libnividia-gl-470. I think it should be sudo apt install libnvidia-gl-470

@Mahedi-61
Copy link
Author

Mahedi-61 commented Nov 11, 2021

@yummyKnight Thanks for your correction.

@asadolahzade
Copy link

asadolahzade commented Nov 30, 2021

Can someone tell me is sudo ubuntu-drivers autoinstall the same as three following commands? Do they do the same job?

sudo apt install libnvidia-common-470
sudo apt install libnvidia-gl-470
sudo apt install nvidia-driver-470

@hiraksarkar
Copy link

hiraksarkar commented Dec 6, 2021

After installing this I was getting the following (non-fatal) warning

>>> import tensorflow as tf
>>> print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
2021-11-24 09:01:58.877869: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:937] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-11-24 09:01:58.899255: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:937] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-11-24 09:01:58.900051: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:937] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
Num GPUs Available:  1

I resolved it by following tensorflow/tensorflow#53184
for a in /sys/bus/pci/devices/*; do echo 0 | sudo tee -a $a/numa_node; done

@AI-Hunter
Copy link

AI-Hunter commented Dec 10, 2021

Thanks for nice repo
I have installed using your instruction. but when type nvidia-smi it shows 11.5. Why, how can I install 11.2?

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