ubuntu18.04 安装cuda-10.2

0,重装ubuntu安装基本软件
刻录系统盘,rufus工具,3.10
基本配置和ubuntu阿里源

sudo apt-get install vim make cmake gcc g++ libnss3 tree git openssh-server openssh-client
sudo apt-get install libssl-dev net-tools apache2-utils # ifconfig, ab
sudo apt-get install htop jtop  # 压测指标
sudo apt-get install locales  # python输出中文不报错,zh_CN.UTF-8

# 谷歌浏览器
sudo wget http://www.linuxidc.com/files/repo/google-chrome.list -P /etc/apt/sources.list.d/
sudo wget  -q -O - https://dl.google.com/linux/linux_signing_key.pub  | sudo apt-key add -
sudo apt-get update
sudo apt-get install google-chrome-stable

# vlc
sudo apt-get install liba52-dev
sudo snap install vlc

# 搜狗输入法
sudo apt-get install fcitx
设置 -> 区域和语言 -> 管理已安装的语言 -> 键盘输入法系统 -> fcitx
下载搜狗输入法 https://pinyin.sogou.com/linux/
双击安装,安装完重启系统
桌面右上角"键盘图标" -> 配置当前输入法 -> 英语+搜狗

# 文本文件
主目录 -> 模板 -> 打开终端
sudo gedit 文本文件
保存

# u盘支持ExFat格式
sudo apt-get install exfat-utils

# 可选 lua
sudo apt-get install lua5.2

# 静止休眠
设置 -> 隐私 -> 锁屏 打开,设置时间,5分钟
sudo apt install gnome-tweak-tool
gnome-tweaks -> 电源 -> 笔记本电脑盖子关闭时挂起 -> 关闭 # root权重设置,重启检查

# ubuntu 安装 wrk
git clone https://github.com/wg/wrk.git 
cd mrk
make -j 8
ln -s /xxx/mrk/mrk  /usr/local/bin

# ubuntu 安装 vscode
sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make
sudo apt-get update
sudo apt-get install ubuntu-make
umake ide visual-studio-code

1,安装相关软件准备

sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev 
sudo apt-get install libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
sudo apt-get install lib32ncurses5 lib32z1
sudo apt-get update
sudo apt-get upgrade

# nvidia显卡驱动,非cuda
ubuntu-drivers devices
sudo ubuntu-drivers autoinstall
#sudo apt-get install nvidia-driver-450 # cuda-10.2

# reboot
nvidia-smi

2,安装CUDA-10.2
2.1 网络安装,离线方式

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://.../cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb
sudo apt-key add /var/cuda-repo-10-2-local-10.2.89-440.33.01/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda

2.2 测试CUDA的例子

cd  /usr/local/cuda-10.2/samples/1_Utilities/deviceQuery
sudo make
./deviceQuery

3,安装cudnn
解压cudnn-10.2-linux-x64-v8.0.4.30.tgz,所有文件复制到cuda驱动的对应位置

tar zxvf cudnn-10.2-linux-x64-v8.0.4.30.tgz
sudo cp cuda/include/* /usr/local/cuda-10.2/include
sudo cp cuda/lib64/* /usr/local/cuda-10.2/lib64
sudo chmod a+r /usr/local/cuda-10.2/include/*
sudo chmod a+r /usr/local/cuda-10.2/lib64/*

4,环境变量

vim ~/.bashrc
# set cuda
export LC_ALL="zh_CN.utf8"   
export CUDA_HOME=/usr/local/cuda-10.2
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDA_HOME/lib64:$CUDA_HOME/extras/CUPTI/lib64
export CUDACXX=$CUDA_HOME/bin/nvcc
export PATH=$CUDA_HOME/bin:$PATH
source ~/.bashrc
localedef -c -f UTF-8 -i zh_CN zh_CN.utf8   # 设置中文utf-8

# jetson NX
export OPENBLAS_CORETYPE=ARMV8
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime  # docker 设置时间
sudo /usr/bin/nvidia-uninstall
sudo apt-get --purge remove nvidia-*
sudo apt-get purge nvidia*
sudo apt-get purge libnvidia*
sudo dpkg --list | grep nvidia-*

你可能感兴趣的:(环境搭建,ubuntu,linux)