2023/9/26

結果是 git-daemon-run
會create gitdaemon user, belongs to nogroup

git-daemon-run 只是幫忙git-daemon 啟動跟設置的一些 script。
使用 sv, 不是用 systemd,所以不太適用了。
直接寫 systemd 的 service 來啟動 git-daemon 比較方便,當然,要手動create git-daemon 的 user 和 group

2023/9/23

about ubuntu 22.04

一些 ubuntu22.04 相關的版本, so 問題,都會記錄在這邊。

因為 用 libssl3,所以一堆用 libssl1 的都會說沒有 supported ssl。
只好裝libssl1
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb
sudo dpkg -i libssl1.1_1.1.0g-2ubuntu4_amd64.deb

2023/9/21

Docker : run nvidia cuda ready images

ref: nvidia 有做好一堆有 support cuda 的 docker image : nvidia in docker image

但是docker 要 supoort 這些 cuda ready 的 image,要安裝 nvidia-container-toolkit
sudo apt install nvidia-container-toolkit
之後設定runtime support:
sudo nvidia-ctk runtime configure --runtime=docker
然後重新啟動 docker daemon:
sudo systemctl restart docker
這樣之後,docker command 就會 support --gpus all 這個 option

另外,image 的 cuda 版本不能比 host 的 cuda 版本新,實際用 torch.rand(2000,128,device=torch.device('cuda')) 測試,他會說使用了新的function.


有一個 dockerfile,是從 yolov5s_android" 看到的:
FROM nvidia/cuda:11.7.1-cudnn8-devel-ubuntu18.04

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update --fix-missing
RUN apt-get install -y python3 python3-pip
RUN pip3 install --upgrade pip
RUN pip3 install torch==1.7.1+cu110 torchvision==0.8.2+cu110 -f https://download.pytorch.org/whl/cu110/torch_stable.html

# install openvino
RUN apt-get update && apt-get install -y --no-install-recommends \
    wget \
    cpio \
    sudo \
    lsb-release && \
    rm -rf /var/lib/apt/lists/*
# Add a user that UID:GID will be updated by vscode
ARG USERNAME=developer
ARG GROUPNAME=developer
ARG UID=1000
ARG GID=1000
ARG PASSWORD=developer
RUN groupadd -g $GID $GROUPNAME && \
    useradd -m -s /bin/bash -u $UID -g $GID -G sudo $USERNAME && \
    echo $USERNAME:$PASSWORD | chpasswd && \
    echo "$USERNAME   ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
USER $USERNAME
ENV HOME /home/developer

原文說明是:
git clone --recursive https://github.com/lp6m/yolov5s_android
cd yolov5s_android
docker build ./ -f ./docker/Dockerfile  -t yolov5s_android
docker run -it --gpus all -v `pwd`:/workspace yolov5s_android bash



241122 update

ref

curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
  && curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
    sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
    sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
    
sudo apt update

sudo apt install nvidia-container-toolkit

sudo nvidia-ctk runtime configure --runtime=docker

sudo systemctl restart docker
測試是否安裝成功,用 nvidia docker 來 run nvidia-smi:
sudo docker run --rm --runtime=nvidia --gpus all ubuntu nvidia-smi

RTX3090. python3.6 and pytorch1.10, pytorch1.7

ref: 很麻煩的 torch. cuda.
用新的顯卡(其實也沒多新,就 3090而已),使 sm85,需要某版本以上的 pytorch 才有support.
不然,雖然用 torch.cuda.is_available() 是 True, get_device_name() 也會正確顯示 RTX3090。
但是宣告一個在 GPU 的變數卻會有 Error:
>import torch
>print(torch.__version__)
1.10.2+cu102
>A = torch.rand(2000,128,device=torch.device('cuda'))
NVIDIA GeForce RTX 3090 with CUDA capability sm_86 is not compatible with the current PyTorch installation.
The current PyTorch install supports CUDA capabilities sm_37 sm_50 sm_60 sm_70.
If you want to use the NVIDIA GeForce RTX 3090 GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/
說其實 1.7.1 版的 pytorch 就已經 support RTX3090 了,是因為 pip repo 中的 pytorch package 配的 cuda 版本太舊,不 support RTX3090.
所以到 pytorch 網站下載新版 cuda 的 pytorch 來裝就可以了。

我的 機器 cuda 版本是 11.7,所以用:
pip install torch==1.10.0+cu113 torchvision==0.11.1+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html
這樣裝完後,上面的測試command 就不會有 Error 了。

到 cu113 的 torch_stable 去看,支援只有從 torch 1.10.0 開始,所以可以用 ref(2) 的作法,到-f 的位址 cu110/torch_stable.html 去看裡面有沒有 torch-1.7.1
結果真的只有 cu110 有,cu111 之後都是 torch-1.10.0 了。
pip3 install torch==1.7.1+cu110 torchvision==0.8.2+cu110 -f https://download.pytorch.org/whl/cu110/torch_stable.html

2023/9/19

android studio and gradle 8.0

一直出現Error:
compileDebugJavaWithJavac' task (current target is 1.8) and 'kaptGenerateStubsDebugKotlin' task (current target is 17) 
jvm target compatibility should be set to the same Java version.
一堆說是 Gradle 8.0 的問題,結果更新到 8.1 也一樣。
然後說要修改 app 的 build.gradle 指定 targetjvm version.
但是沒有清楚說明。

android studio 的 build system 是 gradle,所以每個版本都會有需要的 gradle 版本。
上面的問題出現在 gradle 8.0,所以使用 gradle 7.X 的最後一版的android studio : Android Studio Electric Eel | 2022.1.1 Patch 2
就沒有問題了。

其實使用gradle 8.0配合新的 build.gradle 內容也沒有問題。

TEST project:
  • Data Binging Basic : Failed
  • New Empty kotline Sample : OK

2023/9/13

build and run SNPE Android Example : image-classifiers

要先 run examples Models 的 inception_v3 的 script 去 download train 好 的 model 和 parameter.
這個 script 要用到 SDK/bin 的 script 和 python 中 tensorflow package 的 py。
所以要設定好 SDK 和 tensorflow 的位置。
另外他用絕對位址download 到 SDK 的 example 目錄,所以 example 的 code 不能 copy 出來。一定要在 SDK 目錄中。

需要用到 snpe 提供的 python module,所以要把 snpe sdk 的 lib/python 加到 PYTHONPATH 中,這個在 bin/envsetup.sh 會做。
envsetup 會設定 SNPE_ROOT, PYTHONPATH, PATH, LD_LIBRARY_PATH

2023/9/11

debugging C++ with VSCode, in ubuntu

ubuntu 跟 windows 使用 VSCode 沒什麼差別,反而是linux 的 c++ compiler 是 opensource 的,還比 windows 方便,不用買 MS 的 build tool 或是裝 msys 來 run g++
所以就是 host 先有 g++ 能 build source code,VSCode 就可以用他來 build.

其他也一樣,VSCode 是以 folder 作為管理 project 的單位。

另外。VSCode 需要的 project setting file : task.json,也是要針對 project folder,放在folder 的 .vscode 中。
以 C++ 來說,第一次 run, debug 的時候,VSCode 發現 project folder 沒有 task.json,就會依照 source language/tool 建一個。

參考: Using C++ on Linux in VS Code

先 create 一個 folder。在 folder 下 run vscode。 (或是在 vscode 中 open folder)。
folder 下就是 C++ source file.
開啟 C++ source file,選 run 或是 debug 就可以了。
就會自動產生 task.json
在source code 中可以設定 break point,之後 run 或是 debug 遇到 break point 都會暫停。

另外。VSCode 第一次開啟 C++ file,會要求安裝 C++ extension。