My wiki

所有wiki整合,便于查找。

Linux

软件安装

bootable device: ventoy refus

clash for windows sogou pinyin

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# apt source
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bcakup
sudo gedit /etc/apt/sources.list

# conda
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.3.1-Linux-x86_64.sh
sh Anaconda3-5.3.1-Linux-x86_64.sh

# wechat https://github.com/zq1997/deepin-wine
wget -O- https://deepin-wine.i-m.dev/setup.sh | sh
sudo apt-get install com.qq.weixin.deepin
sudo apt install libjpeg62:i386

# dingding https://page.dingtalk.com/wow/z/dingtalk/simple/ddhomedownload#/
sudo dpkg -i com.alibabainc.dingtalk_**_amd64.deb

# proxychains4
sudo apt install proxychains4
sudo vim /etc/proxychains4.conf
# socks5 127.0.0.1 1081
echo "alias pc4='proxychains4 -q'" >> ~/.bash_aliases
source ~/.bash_aliases
pc4 ...

# eyeblue网盘 https://tank-doc.eyeblue.cn/basic/install.html
docker run --name dockermysql -p 13306:3306 -e MYSQL_ROOT_PASSWORD=123456 -e MYSQL_DATABASE=tank -e TZ=Asia/Shanghai -d mysql:5.7 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --default-time_zone=+8:00
docker run --name tank -p 6010:6010 --link dockermysql:mysql -v ~/data/dockermatter:/data/build/matter -d eyeblue/tank:3.1.6
sudo docker start dockermysql
sudo docker start tank

# firefox https://www.firefox.com.cn/
sudo vi /usr/share/applications/firefox.desktop

# droidcam
wget -O droidcam_latest.zip https://files.dev47apps.net/linux/droidcam_2.0.0.zip
unzip droidcam_latest.zip -d droidcam
cd droidcam && sudo ./install-client
sudo apt install libappindicator3-1

[Desktop Entry]
Name=firefox
Name[zh_CN]=firefox
Comment=firefox
Exec=/opt/firefox/firefox
Icon=/opt/firefox/browser/chrome/icons/default/default128.png
Terminal=false
Type=Application
Categories=Application;
Encoding=UTF-8
StartupNotify=true


系统管理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
htop # 查看PID
cat /proc/$PID/status | grep PPid # 父进程ID
kill -9 $PPid
# 批量杀死进程
ps -elf |grep open-mmlab |awk '{print $4}'|xargs kill -9
# 磁盘
sudo iotop -oP
# 内存
htop
# GPU
nvidia-smi
# timezone
tzselect
sudo cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
sudo hwclock --systohc
date
# 系统升级
cat /etc/os-release
sudo apt update && sudo apt full-upgrade
sudo do-release-upgrade

Nvidia显卡相关

1
2
3
4
5
6
7
8
# 指定显卡
os.environ["CUDA_VISIBLE_DEVICES"] = '0' # python
export CUDA_VISIBLE_DEVICES=0 # sh

# 适用内核更新导致,or reinstall cuda dirver
ls /usr/src | grep nvidia
sudo apt install dkms
sudo dkms install -m nvidia -v ***.**.**

小问题合集

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# unzip乱码
unzip -O CP936 filename.zip

# 项目打包上传
python setup.py sdist build
twine upload dist/*

# #### 百度云网盘劫持html文件打开方式
gedit ~/.config/mimeapps.list

text/html=baidunetdisk.desktop
text/html=firefox.desktop;org.gnome.gedit.desktop;userapp-Firefox-MEQ910.desktop;

#### linux下matplotlib显示中文
下载字体 [SimHei.ttf](https://www.fontpalace.com/font-download/SimHei/), 移动到 `/site-packages/matplotlib/mpl-data/fonts/ttf`
mv SimHei.ttf ../site-packages/matplotlib/mpl-data/fonts/ttf
# 删除缓存
rm -rf /home/tyler/.cache/matplotlib
gedit ../site-packages/matplotlib/mpl-data/matplotlibrc

# 修改为:
font.family : sans-serif
# 去掉前面的#
font.sans-serif : SimHei, Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
# 去掉前面的#,并在冒号后面添加SimHei
axes.unicode_minus : False
# 去掉前面的#,并将True改为False

# 去除设置字体的代码

# 自用bash_aliases
# .bash_aliases
alias nn='watch -n 1 -d nvidia-smi'
alias sb='source ~/.bashrc'
alias cod='conda deactivate'
alias coa='conda activate'
alias col='conda env list'
alias pc4='proxychains4 -q'
alias pyserver='python -m http.server 8888'
# alias 84='sshpass -p password ssh user@ip'
alias tar='tar -zxvf'
alias tarz='tar -zcvf'
alias hexoss='hexo clean && hexo g && hexo s'

Envs

apt source

1
2
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bcakup
sudo gedit /etc/apt/sources.list

ref tsinghua mirror

pip source

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

conda source

pytorch

official site, conda pytorch

opencv python3 cuda

更新cmake版本 opencv cuda编程

opencv 编译官方指导

其中FAST_MATH两个都是加速选项, 会一定程度影响精度

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
除了文档中的以外:
pip install opencv-python


coa base_py38_torch18_tf2

cmake \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D OPENCV_EXTRA_MODULES_PATH=/opt/opencv_contrib-4.5.4/modules \
-D BUILD_OPENCV_PYTHON2=OFF \
-D ENABLE_FAST_MATH=ON \
-D CUDA_FAST_MATH=ON \
-D BUILD_OPENCV_PYTHON3=ON \
-D PYTHON_DEFAULT_EXECUTABLE=$(python -c "import sys; print(sys.executable)") \
-D PYTHON3_EXECUTABLE=$(which python3) \
-D PYTHON_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-D PYTHON_INCLUDE_DIR2=$(python3 -c "from os.path import dirname; from distutils.sysconfig import get_config_h_filename; print(dirname(get_config_h_filename()))") \
-D PYTHON_LIBRARY=$(python3 -c "from distutils.sysconfig import get_config_var;from os.path import dirname,join ; print(join(dirname(get_config_var('LIBPC')),get_config_var('LDLIBRARY')))") \
-D PYTHON3_NUMPY_INCLUDE_DIRS=$(python3 -c "import numpy; print(numpy.get_include())") \
-D PYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
-D BUILD_EXAMPLES=OFF \
-D WITH_CUDA=ON \
-D WITH_CUDNN=ON \
-D OPENCV_DNN_CUDA=ON \
-D WITH_CUBLAS=ON \
-D CUDNN_VERSION=8.2 \
-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-11.1 \
-D OpenCL_LIBRARY=/usr/local/cuda-11.1/lib64/libOpenCL.so \
-D OpenCL_INCLUDE_DIR=/usr/local/cuda-11.1/include/ \
..

make -j20
sudo make install
sudo ldconfig

cd /opt/anaconda3/envs/base_py38_torch18_tf2/lib/python3.8/site-packages/
ln -sf /usr/local/lib/python3.8/dist-packages/cv2/cv2.cpython-38-x86_64-linux-gnu.so cv2.so

conda base env

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# install memba to replace conda
conda install mamba -n base -c conda-forge

# updata 22.02.17
conda create -n base_py39x_torch1x2 python==3.9.10
pip3 install torch==1.10.2+cu113 torchvision==0.11.3+cu113 torchaudio==0.10.2+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html
pip3 install cv2box

# using
conda create --clone base_py39x_torch1x2 --name poseviz

# 还原conda base环境
conda list --revisions
conda install --rev 0

# conda bash
source /opt/anaconda3/etc/profile.d/conda.sh
conda activate full

# opencv support h264(avc1)
pip uninstall opencv-python opencv-contrib-python
memba install -c conda-forge opencv

cuda cudnn安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# driver
sudo nvidia-uninstall

# cuda
sudo chmod +x ./cuda..
sudo ./cuda..
sudo rm /usr/local/cuda
sudo ln -s /usr/local/cuda.. /usr/local/cuda

# cudnn
tar -xzvf cudnn..
sudo cp ./include/cudnn*.h /usr/local/cuda/include
sudo cp ./lib/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

# check
nvcc -V

onnxruntime + cuda + tensorrt

cmake=3.24.0 onnxruntime=1.13 cuda=11.6 cudnn=8.4.1.50 tensorrt=8.4.1.5

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Python 3.x

# cmake
python3 -m pip install cmake
which cmake

# use proxy
git clone --recursive https://github.com/microsoft/onnxruntime.git --depth 1 --branch v1.13.1

# if you got network issue, update submodule manually
# git submodule init
# git submodule update

# three ways to install tensorrt
# 1.
# mod ~/.bashrc add ./TensorRT-8.4.1.5/lib
# 2.
# sudo cp ./TensorRT-8.4.1.5/lib/libnvinfer_builder_resource.so.8.4.1 /usr/lib
# 3.
sudo gedit /etc/ld.so.conf
# add ./TensorRT-8.4.1.5/lib
sudo ldconfig

# build
./build.sh --use_cuda --cudnn_home /usr/local/cuda/lib64 --cuda_home /usr/local/cuda --use_tensorrt --tensorrt_home ./TensorRT-8.4.1.5 --build_wheel --parallel --skip_tests
pip install ./build/Linux/Debug/dist/onnxruntime_gpu-1.13.0-cp39-cp39-linux_x86_64.whl

# change python version
pip install -r requirements-dev.txt
rm -r ./build

docker

onnxruntime tensorrt tensorrt matrix cuda cuda docker hub

1
2
3
4
5
# docker build interrupt
FROM {none image id} rewrite DOCKERFILE

# https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg
docker build -t onnxruntime-trt -f Dockerfile.tensorrt . --build-arg HTTPS_PROXY=http://xxxx:7890

Cheat sheet

tmux

pathlib



My wiki
http://example.com/posts/65245/
作者
ykk648
发布于
2021年12月13日
许可协议