Ubuntu20.04 配置记录
Just for record Ubuntu20.04 Setup
0x00 apt换cn源
1 | sudo apt update |
0x01 apt install
1 | sudo apt install \ |
0x02 fonts
Optional
I use Font:‘Meslo LG L Regular for Powerline’
1 | git clone git@github.com:powerline/fonts.git |
0x03 install zsh & ohmyzsh
install zsh
1 | sudo apt install zsh |
install ohmyzsh
1 | sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" |
ohmyzsh plugins
1 | pushd .oh-my-zsh |
manually change default $SHELL
1 chsh -s /usr/bin/zsh重启终端后可以看到
1
2 echo $SHELL
/usr/bin/zsh
clipboard
Optional GUI required
install dependency, xclip
on ubuntu
pbcopy, pbpaste (macOS)
cygwin (Windows running Cygwin)
wl-copy, wl-paste (if $WAYLAND_DISPLAY is set)
xsel (if $DISPLAY is set)
xclip (if $DISPLAY is set)
lemonade (for SSH) https://github.com/pocke/lemonade
doitclient (for SSH) http://www.chiark.greenend.org.uk/~sgtatham/doit/
win32yank (Windows)
tmux (if $TMUX is set)
Usage:
1 | <command> | clipcopy # copy from stdout |
0x04 LLVM stuff
1 | wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - |
0x05 CMake
1 | wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null \ |
0x06 NVIDIA stuff
Driver
driver装最新的就行,高版本兼容低版本
skip this section on WSL, nvidia driver on windows already done this
- download a xxx.run file
- install NVIDIA driver
bash NVIDIA-Linux-x86_64-530.41.03.run
- reboot
- install (cuda)[https://developer.nvidia.com/cuda-toolkit-archive]
NVIDIA Docker
Work on Ubuntu,Debian, WSL as well.
First install Docker
WSL
install Windows Docker-Desktop
Linux
Example for Ubuntu>18.04:
install from apt repo
1 | sudo install -m 0755 -d /etc/apt/keyrings |
Install nvidia-docker2
Note that in some cases the downloaded list file may contain URLs that do not seem to match the expected value of distribution which is expected as packages may be used for all compatible distributions. As an examples:
- For distribution values of ubuntu20.04 or ubuntu22.04 the file will contain ubuntu18.04 URLs
- For a distribution value of debian11 the file will contain debian10 URLs
1 | distribution=$(. /etc/os-release;echo $ID$VERSION_ID) |
Update daemon.json
Edit docker config
1 | sudo vim /etc/docker/daemon.json |
- set
default-runtime
tonvidia
. - set data root of docker contents.
Sample:
1 | { |
Then, restart docker
1 | systemctl restart docker # or daemon reload |
Test Nvidia Docker
Test with official docker images:
1 | docker run -it --rm nvcr.io/nvidia/k8s/cuda-sample:devicequery-cuda11.7.1-ubuntu20.04 |
CUDA toolkit
Linux
Cuda install .deb file contains a driver, so choose a specific package to install meta package
CUDNN
download from tar file
- download files from https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-x86_64/
- copy files into the CUDA directory
1 | tar -xvf cudnn-linux-x86_64-8.x.x.x_cudaX.Y-archive.tar.xz |
other
libcudnn不会和cudatoolkit一起安装,nvidia提供下载页面,下载后copy到cuda的lib目录下。对应docker label:nvidia/cuda:xxxx-cudnn-xxx
。
有一个trick:pip 安装的torch中带一个libcudnn,在torch的安装位置的lib里,如/usr/lib/python3.10/site-packages/torch/lib
。不然torch的gpu版的体积也不用这么大。
还可以使用pip安装。如pip install nvidia-cudnn-xxxxx
。
WSL
修复 libcuda.so.1 is not a symbolic link
原因:
WSL nvidia-container-cli 需要用 /usr/lib/wsl/lib下的东西,而且都是copy,不可以是link
WSL 内ldconfig 需要用 {xxx}.so link to file {xxx}.so.1.1
WSL内/usr/lib/wsl/lib是auto mount%SYSTEMROOT%\System32\lxss\lib
的,把这个automount关掉,修改/etc/wsl.conf
1 | [automount] |
创建link:
1 | mkdir /usr/lib/wsl/lib2 |
然后修改/etc/ld.so.conf.d/ld.wsl.conf
,让ldconfig全用link的
1 | /usr/lib/wsl/lib2 |
最后重新启动wsl。
Post-installation Actions
set path
1 | export PATH=/usr/local/cuda/bin${PATH:+:${PATH}} |
Verify the Installation
check version
1 | cat /proc/driver/nvidia/version |
run samples from https://github.com/nvidia/cuda-samples
0x07 Setup python env with conda
0x08 OpenCL
WSL不支持Opencl No OpenCL platforms reported
1 | sudo apt install ocl-icd-opencl-dev \ |
Check status:
1 | clinfo |
0x09 OpenCV
1 | git clone -b 4.5.5 --depth 1 git@github.com:opencv/opencv.git |
0x0a Gnome Extention
简单记录几个我在用的extension
Install
1 | sudo apt-get install chrome-gnome-shell gnome-tweaks gnome-shell-extensions |
Chrome extension: Gnome shell integration