ifconfig可以查看,所有网络属性
转到网络配置目录cd /etc/netplan 查看文件ls 修改文件sudo vim 文件名.yaml
例:sudo vim 00-installer-config.yaml
(我这个是双网口的,eno1、eno2,如果单网口,只用配置一个eno1就可以了)
注意缩进!!!!!!!
# This is the network config written by 'subiquity'
network:
ethernets:
eno1:
dhcp4: no
addresses: [192.168.1.7/24]
optional: true
gateway4: 192.168.1.1
nameservers:
addresses: [255.255.255.0]
eno2:
dhcp4: no
addresses: [192.168.100.198/24]
optional: true
gateway4: 192.168.1.1
nameservers:
addresses: [255.255.255.0]
version: 2
配置完成后,运行sudo netplan apply , 重启网卡驱动,配置完成!!
打开/etc/apt/sources.list ,输入一下内容
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
完成后,sudo apt-get update 再 sudo apt-get upgrade
sudo apt-get install gcc
sudo apt-get install make
sudo apt install nvidia-cuda-toolkit
sudo apt install dkms build-essential linux-headers-generic
禁用 nouveau 驱动
sudo vim /etc/modprobe.d/blacklist.conf
在文件末尾加入:
blacklist rivafb
blacklist vga16fb
blacklist nouveau
blacklist nvidiafb
blacklist rivatv
options nouveau modeset=0
blacklist lbm-nouveau
alias nouveau off
alias lbm-nouveau off
禁用 nouveau 内核模块
echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf
sudo update-initramfs -u
卸载旧版本的nvidia驱动:sudo apt-get --purge remove nvidia-*
重启: sudo reboot
sudo chmod a+x NVIDIA-Linux-x86_64-450.66.run
sudo ./你的显卡驱动.run -no-x-check -no-nouveau-check -no-opengl-files
Would you like to register the kernel module sources with DKMS? This will allow DKMS to automatically build a new module, if you install a different kernel later. ——NO
Install NVIDIA’s 32-bit compatibility libraries?——NO
Would you like to run the nvidia-xconfig utility to automatically update your X configuration file so that the NVIDIA X driver will be used when you restart X? Any pre-existing X configuration file will be backed up. ——YES
安装完毕,重启: sudo reboot
挂载驱动: modprobe nvidia
检查是否安装成功:nvidia-smi
wget 下载链接(百度搜索cuda11.2)
sudo sh cuda_11.1.1_455.32.00_linux.run 开始安装
accept 回撤下一步
取消选择 Driver 显卡驱动
安装完成
配置cuda环境变量
~/.bashrc文件中添加:
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
更新变量:source ~/.bashrc
测试:nvcc -V
下载cudnn,linux(x64) 解压后
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
配置完成(高版本请使用以下命令)
tar -xvf cudnn-linux-x86_64-8.4.0.27_cuda11.6-archive.tar.xz
cd cudnn-linux-x86_64-8.4.0.27_cuda11.6-archive
sudo cp lib/* /usr/local/cuda-11.2/lib64/
sudo cp include/* /usr/local/cuda-11.2/include/
sudo chmod a+r /usr/local/cuda-11.2/lib64/*
sudo chmod a+r /usr/local/cuda-11.2/include/*
安装包链接:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
安装命令 bash Anaconda3-5.3.0-Linux-x86_64.sh
回车按住略过许可证,
Do you approve the license terms? [yes|no] 输入yes,
直接安装默认路径,
by running conda init? [yes|no] 再no,
在.bashrc中添加 export PATH="/root/anaconda3/bin:$PATH"
完成后source ~/.bashrc
创建虚拟环境:conda create -n ceak python=3.7
修改pip镜像源:
1.在“主目录”下创建.pip文件夹,进入文件夹使用命令touch pip.conf创建pip.conf文件
2.输入以下内容然后保存即可
[global]
timeout = 6000
index-url = http://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com
安装一个opencv 依赖的python包:pip install numpy
安装openh264:conda install -c conda-forge openh264
安装opencv依赖:
sudo apt install ubuntu-restricted-extras
sudo apt install build-essential cmake git python3-dev python3-numpy libavcodec-dev libavformat-dev libswscale-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libgtk-3-dev libpng-dev libjpeg-dev libopenexr-dev libtiff-dev libwebp-dev libopencv-dev
sudo apt remove -y x264 ffmpeg libx264-dev
sudo apt install x264 libx264-dev ffmpeg pkg-config
依赖安装完成
下载opencv源码(我是4.5.3):
https://github.com/opencv/opencv.git
当然你也可以走捷径:https://pan.baidu.com/s/1Z3KbRWyW_wYMYuUK6_SHjw
提取码:lyb8
解压后,opencv目录下新建build文件夹,再执行下边命令
cmake -D OPENCV_ENABLE_NONFREE=ON -D BUILD_opencv_python2=OFF -D WITH_GDAL=ON -D OPENCV_PYTHON3_VERSION=3.7 -D PYTHON_DEFAULT_EXECUTABLE=/home/roo/anaconda3/envs/ceak/bin/python -D PYTHON3_LIBRARY=/home/roo/anaconda3/envs/ceak/lib/python3.7 -D PYTHON3_EXECUTABLE=/home/roo/anaconda3/envs/ceak/bin/python -D PYTHON3_INCLUDE_DIR=/home/roo/anaconda3/envs/ceak/include/python3.7m -D PYTHON3_PACKAGES_PATH=/home/roo/anaconda3/envs/ceak/lib/python3.7/site-packages ..
(这里要注意,conda虚拟环境路径、python版本)
make -j$[$(nproc)-1]
sudo make install
opencv编译完成
安装:sudo apt install imagemagick
使用convert报错: ImageMagick is not installed
解决方法:\Lib\site-packages\moviepy\config_defaults.py中的 IMAGEMAGICK_BINARY
改为自己路径 magick.exe or /usr/bin/convert
报错:@/tmp/tmp5rk19_ox.txt
解决方法: 修改文件 /etc/ImageMagick-6/policy.xml
<policy domain="path" rights="none" pattern="@*" />
改成
<!-- <policy domain="path" rights="none" pattern="@*" /> -->
报错:ValueError: Could not find a backend to open `1.jpg`` with iomode `ri`. 或者
ValueError: Could not find a format to read the specified file in single-image mode
解决方法:修改\Lib\site-packages\moviepy\video\VideoClip.py
15行 添加 from PIL import Image 引入PIL进行读取图片
注释掉890行img = imread(img) 改为 img = np.array(Image.open(img))
Moviepy 重点要记:处理视频一定要最后再进行叠加或合并处理,可以提高速度,至于GPU加速解码,弄完之后速度并没有什么变化,2.0版本的尝试后太多问题。
sudo df -h 查看现磁盘使用情况
sudo fdisk -l 查看电脑挂载的硬盘
清除需要挂载的硬盘分区sudo fdisk /dev/sdb
格式化为ext4格式 sudo mkfs.ext4 /dev/sdb
创建挂载文件夹 sudo mkdir /baby
挂载硬盘到指定文件夹 mount /dev/sdb /baby
设置开机自启动挂载 /etc/fstab文件添加:/dev/sdb /baby ext4 defaults 0 0
挂载完成,重启检查硬盘是否已挂载sudo reboot
timedatectl status # 查看当前时间
timedatectl set-timezone "Asia/Shanghai" # 修改当前时间
修改完之后再查看时间是否被修改timedatectl status
重启sudo reboot
查看当前显卡当前使用的驱动版本: cat /proc/driver/nvidia/version
sudo apt-mark hold linux-image-generic linux-headers-generic # 禁止内核自动更新
# sudo apt-mark unhold linux-image-generic linux-headers-generic # 取消禁止
sudo apt-mark hold nvidia-driver-470 # 禁用显卡自动更新
pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html
pip install -r requirements.txt