const 发布的文章

“const”

sudo systemctl stop docker
sudo systemctl stop docker.socket

sudo mv /var/lib/docker ~/
sudo ln -s ~/docker /var/lib/docker

sudo systemctl start docker.socket
sudo systemctl start docker

docker ps -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ee82839b65bb ubuntu:22.04 "/bin/bash" 7 weeks ago Exited (137) 10 minutes ago epic_chatelet
bf9c8c24edc5 ubuntu:20.04 "bash" 8 months ago Exited (0) 10 minutes ago angry_goldstine

docker start bf
docker exec -it bf /bin/bash
docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bf9c8c24edc5 ubuntu:20.04 "bash" 8 months ago Up 14 seconds angry_goldstine

Docker 容器里运行 Windows 系统,可选择 Win7,Win10,Win11 等,支持远程桌面连接,也可以直接在网页里面查看.

输入网址访问效果:
http://192.168.10.144:8006/?resize=scale&autoconnect=true

截图 2024-03-11 09-40-18.png

当然也是可以通过3389端口来访问的.

截图 2024-03-11 09-41-14.png

官方的github地址:https://github.com/dockur/windows
能够看到star狂升.

直接上命令:

docker run -it --rm --name windows -p 8006:8006 -p 13389:3389 --device=/dev/kvm --cap-add NET_ADMIN --stop-timeout 120 dockurr/windows

因为要下载安装光盘,有好几个G,估计要花点时间,然后下次就可以直接使用了.

docker ps
CONTAINER ID   IMAGE             COMMAND                  CREATED      STATUS             PORTS                                                                                    NAMES
e9f8d4c38625   dockurr/windows   "/usr/bin/tini -s /r…"   2 days ago   Up About an hour   0.0.0.0:8006->8006/tcp, :::8006->8006/tcp, 0.0.0.0:13389->3389/tcp, :::13389->3389/tcp   windows

启动停止还是使用docker start/stop就可以了.启动后,就直接网页或者远程桌面就可以访问了.

BrowserWindow网页显示文本内容:
In Chrome, you can display inline html pages by navigating URL with data: protocol such as

data:text/html;charset=utf-8,<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>MyYTitle</title> <style type="text/css"> </style></head> <body>Hello world from Lyon, FR</body>

It works the same in Electron. Can you try opening a window with

loadURL('data:text/html;charset=utf-8,<YOUR HTML/>');

~/work/2023/go_all_2023/bin/go_display 192.168.4.202 "data:text/html;charset=utf-8,<h1>Hello World</h1>"

~/work/2023/go_all_2023/bin/go_display 192.168.4.202 "data:text/html;charset=utf-8,<head><style>html, body {height: 100%;margin: 0;padding: 0;width: 100%;font-family: 宋体;font-size: 100px;color: green;font-weight: bold;}body{display: table;}.my-block {text-align: center;display: table-cell;vertical-align: middle;}</style></head><body><div class='my-block'>Hello World</div></body></html>"

判断错误的代码与类型

server.on('error', function (error) {
        write_log('Error1: ' + error);
        write_log('error.code' + error.code)
        write_log('error.message' + error.message)
        server.close();
        if (error.code == EADDRINUSE)
            app.quit();
    });

新建一个electron项目
首先安装yarn

sudo apt update && sudo apt install libfuse2 curl gnupg
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn

手动下载node并链接

wget https://nodejs.org/dist/v20.10.0/node-v20.10.0-linux-arm64.tar.gz -O /opt/node.tar.gz
tar xvf /opt/node.tar.gz -C/opt
ln -s /opt/node/bin/node /usr/bin/node
ln -s /opt/node/bin/npm /usr/bin/npm

mkdir first-app && cd first-app

新建一个package.json文件,内容如下, 这个文件的内容,可以根据你自己的需要来修改:

cat package.json 
{
  "name": "first-app",
  "version": "1.0.0",
  "description": "my first app",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dist": "electron-builder --linux appImage"
  },
  "author": "hesy <pzhy@qq.com>",
  "license": "ISC",
  "devDependencies": {
    "electron": "^29.1.5",
    "electron-builder": "^24.13.3"
  },
  "build": {
    "appId": "const.net.cn",
    "appImage": {
      "category": "Utility"
    },
    "executableName": "firstapp"
  }
}

还要新建一个index.js文件,内容如下:

cat index.js
const { app, BrowserWindow } = require('electron')

function createWindow() {
  udplib.write_log("program start.")
  var win = new BrowserWindow({
    width: 1920,
    height: 1080,
    titleBarStyle: 'hidden',
    frame: false,
    show: false,
    webPreferences: {
      nodeIntegration: true,
      webSecurity: false
    }
  })

  win.loadURL('https://const.net.cn')
  win.show()
  //隐藏滚动条
  win.webContents.executeJavaScript(`
  let style = document.createElement('style');
  style.innerHTML = '::-webkit-scrollbar { display: none; }';
  document.head.appendChild(style);
`);

}

app.whenReady().then(createWindow)

可选命令,优化下载速度,不要用淘宝的了,淘宝的不能用了.
  yarn config set registry https://registry.npmmirror.com -g
  yarn config set electron_mirror https://npmmirror.com/mirrors/electron/ -g
接下来执行安装electron-builder命令

yarn add electron-builder --dev

成功后,就可以使用

yarn dist 生成可执行程序了.

/opt/first-app# yarn dist
yarn run v1.22.19
$ electron-builder --linux appImage
  • electron-builder  version=24.13.3 os=4.19.219
  • loaded configuration  file=package.json ("build" field)
  • writing effective config  file=dist/builder-effective-config.yaml
  • packaging       platform=linux arch=arm64 electron=29.1.5 appOutDir=dist/linux-arm64-unpacked
  • building        target=AppImage arch=arm64 file=dist/first-app-1.0.0-arm64.AppImage
  • default Electron icon is used  reason=application icon is not set
Done in 65.60s.

接下来就简单了,直接执行可执行文件就好了.

./dist/first-app-1.0.0-arm64.AppImage --no-sandbox

如果提示缺少了什么动态库,apt install 安装上就可以了.

2001.棋魂.棋灵王.棋靈王.双国粤日5音轨.TV.75集全.MOVIE.SP.漫画.Hikaru.no.Go.ヒカルの碁

magnet:?xt=urn:btih:d784bee99ae922f395cecf11c5037672dcfed840

magnet:?xt=urn:btih:26CL52M25ERPHFOOZ4I4KA3WOLOP5WCA&dn=&tr=http%3A%2F%2F104.143.10.186%3A8000%2Fannounce&tr=udp%3A%2F%2F104.143.10.186%3A8000%2Fannounce&tr=http%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=http%3A%2F%2Ftracker3.itzmx.com%3A6961%2Fannounce&tr=http%3A%2F%2Ftracker4.itzmx.com%3A2710%2Fannounce&tr=http%3A%2F%2Ftracker.publicbt.com%3A80%2Fannounce&tr=http%3A%2F%2Ftracker.prq.to%2Fannounce&tr=http%3A%2F%2Fopen.acgtracker.com%3A1096%2Fannounce&tr=https%3A%2F%2Ft-115.rhcloud.com%2Fonly_for_ylbud&tr=http%3A%2F%2Ftracker1.itzmx.com%3A8080%2Fannounce&tr=http%3A%2F%2Ftracker2.itzmx.com%3A6961%2Fannounce&tr=udp%3A%2F%2Ftracker1.itzmx.com%3A8080%2Fannounce&tr=udp%3A%2F%2Ftracker2.itzmx.com%3A6961%2Fannounce&tr=udp%3A%2F%2Ftracker3.itzmx.com%3A6961%2Fannounce&tr=udp%3A%2F%2Ftracker4.itzmx.com%3A2710%2Fannounce

两个链接都是同一个东西,好不容易找到的。

因为一个错误提示信息,才发现默认的opencv是没有把cuda编译进去的.

setUpNet DNN module was not built with CUDA backend; switching to CPU

保险起见,就在docker里面安装编译啥的了.

docker pull ubuntu:22.04
docker run --gpus all -it --name my_ubuntu2204 ubuntu:22.04 /bin/bash

得到一个docker 容器,根据docker ps 可以查看容器的ID是d3开头的,简单起见,就直接docker start d3就可以了.

docker exec -it d3 /bin/bash

安装必要的工具

apt -y update
apt -y upgrade
apt -y install linux-headers-$(uname -r)
apt -y install wget unzip cmake gcc g++
apt -y install python3 python3-dev python3-numpy
apt -y install libavcodec-dev libavformat-dev libswscale-dev
apt -y install libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev
apt -y install libgtk-3-dev
apt -y install libpng-dev libjpeg-dev libopenexr-dev libtiff-dev libwebp-dev

安装cuda

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/12.4.1/local_installers/cuda-repo-ubuntu2204-12-4-local_12.4.1-550.54.15-1_amd64.deb
dpkg -i cuda-repo-ubuntu2204-12-4-local_12.4.1-550.54.15-1_amd64.deb
cp /var/cuda-repo-ubuntu2204-12-4-local/cuda-*-keyring.gpg /usr/share/keyrings/
apt update
apt -y install cuda-toolkit-12-4
apt-get install -y cuda-drivers

下载opencv4.9.0

wget https://github.com/opencv/opencv/archive/refs/tags/4.9.0.tar.gz
wget https://github.com/opencv/opencv_contrib/archive/refs/tags/4.9.0.zip
unzip opencv_contrib-4.9.0.zip
tar xvf opencv-4.9.0.tar.gz
cd opencv-4.9.0
mkdir build && cd build 
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_CUDA=ON -D WITH_CUDNN=ON -D WITH_CUBLAS=ON -D WITH_TBB=ON -D OPENCV_DNN_CUDA=ON -D OPENCV_ENABLE_NONFREE=ON  -D OPENCV_EXTRA_MODULES_PATH=/home/hesy/opencv_contrib-4.9.0/modules -D BUILD_EXAMPLES=OFF -D HAVE_opencv_python3=ON ..

最新的命令
直接拉官方的docker(https://hub.docker.com/r/nvidia/cuda/tags)

docker pull nvidia/cuda:12.3.2-cudnn9-devel-ubuntu22.04
docker run --gpus all -it --name my-opencv -v /home/hesy:/home/hesy nvidia/cuda:12.3.2-cudnn9-devel-ubuntu22.04 /bin/bash
apt -y update
apt -y upgrade
apt -y install linux-headers-$(uname -r)
apt -y install wget unzip cmake gcc g++
apt -y install python3 python3-dev python3-numpy
apt -y install libavcodec-dev libavformat-dev libswscale-dev
apt -y install libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev
apt -y install libgtk-3-dev libfreeimage3 libfreeimage-dev
apt -y install libpng-dev libjpeg-dev libopenexr-dev libtiff-dev libwebp-dev libdc1394-dev

mkdir -p /home/hesy/opencv && cd /home/hesy/opencv
wget https://github.com/opencv/opencv/archive/refs/tags/4.9.0.tar.gz
wget https://github.com/opencv/opencv_contrib/archive/refs/tags/4.9.0.zip
unzip opencv_contrib-4.9.0.zip
tar xvf opencv-4.9.0.tar.gz
cd opencv-4.9.0
mkdir build && cd build 
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_CUDA=ON -D WITH_CUDNN=ON -D WITH_CUBLAS=ON -D WITH_TBB=ON -D OPENCV_DNN_CUDA=ON -D OPENCV_ENABLE_NONFREE=ON  -D OPENCV_EXTRA_MODULES_PATH=/home/hesy/opencv/opencv_contrib-4.9.0/modules -D BUILD_EXAMPLES=OFF -D HAVE_opencv_python3=ON ..
make

编译报错:(
error: 'cudnnSetRNNDescriptor_v6' was not declared in this scope; did you mean 'cudnnSetRNNDescriptor_v8
error: 'cudnnRNNForwardInference' was not declared in this scope
error: 'cudnnGetRNNWorkspaceSize' was not declared in this scope; did you mean 'cudnnGetRNNWeightSpaceSize'?

在网上( https://github.com/opencv/opencv/issues/24983 )看到相关说法是cudnn9不行,用cudnn8.9.7就可以了.去下载一个8.9.7试试看

重新开一个新的docker,使用nvidia/cuda:12.3.2-devel-ubuntu22.04,不带cudnn版本的容器.在容器执行下面的命令

apt -y update
apt -y upgrade
apt -y install linux-headers-$(uname -r)
apt -y install wget unzip cmake gcc g++
apt -y install python3 python3-dev python3-numpy
apt -y install libavcodec-dev libavformat-dev libswscale-dev
apt -y install libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev
apt -y install libgtk-3-dev libfreeimage3 libfreeimage-dev
apt -y install libpng-dev libjpeg-dev libopenexr-dev libtiff-dev libwebp-dev libdc1394-dev

下载cudnn8.9.7的本地安装包,官方网站要注册登录才能下载.不复杂,几分钟时间就能搞定.
https://developer.download.nvidia.com/compute/cudnn/secure/8.9.7/local_installers/12.x/cudnn-local-repo-ubuntu2204-8.9.7.29_1.0-1_amd64.deb

dpkg -i cudnn-local-repo-ubuntu2204-8.9.7.29_1.0-1_amd64.deb
cp /var/cudnn-local-repo-*/cudnn-local-*-keyring.gpg /usr/share/keyrings/
apt update
apt -y install libcudnn8 libcudnn8-dev libcudnn8-samples

校验 编译mnistCUDNN

cp -r /usr/src/cudnn_samples_v8/ /home/hesy
cd  /home/hesy/cudnn_samples_v8/mnistCUDNN
make clean && make

执行检测,看到pass表示测试通过

# 在/home/hesy/cudnn_samples_v8/mnistCUDNN中执行./mnistCUDNN进行测试
./mnistCUDNN

测试结果:

root@3a452f9297bd:/home/hesy/cudnn_samples_v8/mnistCUDNN# ./mnistCUDNN 
Executing: mnistCUDNN
cudnnGetVersion() : 8907 , CUDNN_VERSION from cudnn.h : 8907 (8.9.7)
Host compiler version : GCC 11.4.0

There are 1 CUDA capable devices on your machine :
device 0 : sms 128  Capabilities 8.9, SmClock 2520.0 Mhz, MemSize (Mb) 24003, MemClock 10501.0 Mhz, Ecc=0, boardGroupID=0
Using device 0
***
Result of classification: 1 3 5

Test passed!

参考: https://juejin.cn/post/7319717702376882227

本来以为这个东西简简单单,没想到一通折腾就是一二天.

cudnn安装成功了,继续折腾编译opencv

mkdir -p /home/hesy/opencv && cd /home/hesy/opencv
wget https://github.com/opencv/opencv/archive/refs/tags/4.9.0.tar.gz
wget https://github.com/opencv/opencv_contrib/archive/refs/tags/4.9.0.zip
unzip opencv_contrib-4.9.0.zip
tar xvf opencv-4.9.0.tar.gz
cd opencv-4.9.0
mkdir build && cd build 
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_CUDA=ON -D WITH_CUDNN=ON -D WITH_CUBLAS=ON -D WITH_TBB=ON -D OPENCV_DNN_CUDA=ON -D OPENCV_ENABLE_NONFREE=ON  -D OPENCV_EXTRA_MODULES_PATH=/home/hesy/opencv/opencv_contrib-4.9.0/modules -D BUILD_EXAMPLES=OFF -D HAVE_opencv_python3=ON ..
make

发现下载IPPICV非常慢,有条件的就上代理吧,另外不知道多线程行不行,所以没敢make -j. 最后发现实在是太慢了,还是

make -j32

快得飞起.但是但是,最后一点点会只用1个cpu,慢得很,只能慢慢等了.前97%感觉没有后3%花的时间多.


export http_proxy="socks5://127.0.0.1:10008"
export https_proxy="socks5://127.0.0.1:10008"