GitHub加速

加速下载:git clone https://github.com.cnpmjs.org/microsoft/onnxruntime.git

  • Mac OS X
/etc/hosts
  • Linux
/etc/hosts

Python文件、目录、路径操作

  • 方法2
def touch(path):
    with open(path, 'a'):
        os.utime(path, None)
  • 方法3

OS X需要root特权

os.mknod(filename)
  • 多级目录
>>> os.makedirs('dirs/sub_dir')
  • 列出文件和目录
>>> os.listdir('/home/python')
['app', 'config', 'main.py', 'test']
  • 多级目录
>>> shutil.rmtree('/home/python')

使用YOLOv5训练自定义数据集

在 Ubuntu20.04 系统上使用4张GPU卡基于容器训练模型。

  • 运行容器
$ docker run --ipc=host --runtime=nvidia -it --name project_name-yolov5 \
    -v project_dir:/usr/src/app/project ultralytics/yolov5:latest
  • 替换所有模型网络的类别
$ sed -i 's/nc: 80/nc: 2/g' project/models/yolov5?.yaml
  • 验证替换结果
$ head -n 2 project/models/yolov5?.yaml
==> project/models/yolov5l.yaml <==
# parameters
nc: 2  # number of classes
==> project/models/yolov5m.yaml <==
# parameters
nc: 2  # number of classes
==> project/models/yolov5s.yaml <==
# parameters
nc: 2  # number of classes
==> project/models/yolov5x.yaml <==
# parameters
nc: 2  # number of classes

在Ubuntu上安装NVIDIA GPU驱动

在一台新安装的 Ubuntu20.04 系统上安装 NVIDIA GPU 驱动。

  1. 更新 initramfs
$ sudo update-initramfs -u
  1. 重启系统
$ sudo reboot
  1. 验证 nouveau 是否禁用成功(当什么也不显示出来时代表成功)
$ lsmod | grep nouveau
  1. 到[NVIDIA 驱动程序下载]页面下载对应型号的驱动
$ wget https://cn.download.nvidia.com/tesla/450.80.02/NVIDIA-Linux-x86_64-450.80.02.run
  1. 安装驱动
$ sudo sh NVIDIA-Linux-x86_64-450.80.02.run

配置Docker镜像源

加速 Docker Hub 镜像拉取速度。

## 另一种方法()
cat << EOF >/etc/docker/daemon.json
{
  "registry-mirrors": ["https://75oltije.mirror.aliyuncs.com"]
}
EOF

在Ubuntu上配置apt镜像源

在国内使用官方的镜像源安装 Ubuntu 应用非常慢,通常配置国内的镜像源来加快速度,如阿里云。

sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list

Linux系统DNS设置

之前在文件/etc/resolv.conf中设置了,过段时间总是自动恢复默认值。(注释中写的很详细,是不可编辑的由系统自动生成的文件)

Linux系统上修改用户名

今天同事安装了一台新的服务器Ubuntu20.04,但用户名和主机名不是我想要的,这里尝试了直接修改Linux文件的方式。

  • 方法一
$ uname -n

Welcome to Jekyll!

You’ll find this post in your _posts directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run jekyll serve, which launches a web server and auto-regenerates your site when a file is updated.

Jekyll requires blog post files to be named according to the following format:

YEAR-MONTH-DAY-title.MARKUP

Where YEAR is a four-digit number, MONTH and DAY are both two-digit numbers, and MARKUP is the file extension representing the format used in the file. After that, include the necessary front matter.

安装Harbor

  1. 生成CA证书
openssl req -x509 -new -nodes -sha512 -days 3650 \
 -subj "/C=CN/ST=Shandong/L=Jinan/O=LNSoft/OU=AI/CN=lnsoft.com" \
 -key ca.key \
 -out ca.crt
  1. 生成私钥
openssl genrsa -out lnsoft.com.key 4096
  1. 生成证书签名请求(CSR)

调整-subj选项中的值以反映您的组织。 如果使用FQDN连接Harbor主机,则必须将其指定为公用名(CN)属性,并在密钥和CSR文件名中使用它。

openssl req -sha512 -new \
    -subj "/C=CN/ST=Shandong/L=Jinan/O=LNSoft/OU=AI/CN=lnsoft.com" \
    -key lnsoft.com.key \
    -out lnsoft.com.csr

生成一个x509 v3扩展文件 cat > v3.

NFS配置

  • 查看服务状态
sudo systemctl status nfs-server
  • 查看开启的NFS协议
sudo cat /proc/fs/nfsd/versions
-2 +3 +4 +4.1 +4.2
  • 配置访问的路径
sudo nano /etc/exports
/data/nfs        172.16.33.0/24(rw,sync,fsid=0,crossmnt,no_subtree_check)
  • 应用配置
sudo exportfs -ra
  • 查看当前应用
sudo exportfs -v
  • 重启服务
sudo systemctl restart nfs-server
  • 查看NFS服务器导出列表
showmount -e 172.16.33.157
Export list for 172.16.33.157:
/data/nfs 172.16.33.0/24,172.16.128.164
  • 挂载NFS
sudo mount -t nfs 172.16.33.157:/ $(pwd)/nfs
  • 移除挂载
sudo umount $(pwd)/nfs