Ubuntu18.04 install cuda

tags: gcc version

1. change your gcc version, in the ubuntu18.04, the gcc version is 7.3.0, but cuda can't support it now, so we will change it

sudo apt install gcc-5 g++-5

after that we use update-alternatives to manage gcc version

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 50 --slave /usr/bin/g++ g++ /usr/bin/g++-5
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 --slave /usr/bin/g++ g++ /usr/bin/g++-7
sudo update-alternatives --config gcc

Ubuntu18.04 install cuda_第1张图片
image

you can use this conmmand to show all package version

update-alternatives --list [package name]

tags: add PPA

2. add the PPA (Personal Package Archive) repository

sudo add-apt-repository ppa:graphics-drivers/ppa

check the recommended graphic driver

ubuntu-driver devices

then you will see like this

Ubuntu18.04 install cuda_第2张图片
image

if you already install the graphic driver, then you can use "nvidia-smi" to see the graphic usage situation

Ubuntu18.04 install cuda_第3张图片
image
tags: download cuda (this version is 9.1) && install it

3. this case use the cuda_9.1.85_387.26_linux.run, you can download this run file by the link below

https://developer.nvidia.com/cuda-91-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1704&target_type=runfilelocal

then you can use sh commend to executing it

sudo sh XXX.run

pay attention, you musk reject installing the graphic driver!!!

after that add the path to the .bashrc

echo "export PATH=/usr/local/cuda-9.1/bin:$PATH" >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-9.1/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc

英文很垃圾请见谅

你可能感兴趣的:(Ubuntu18.04 install cuda)