2024/4/30

Docker : container access host network

就是用 "--add-host="host.docker.internal:host-gateway",docker 會再container 的dns中加入 host.docker.internal 到 host ip
測試可以用:
docker container run --rm \
  --add-host="host.docker.internal:host-gateway" \
  debian:stable-slim \
  bash -c "apt-get update && apt-get install -y iputils-ping && ping -c 3 host.docker.internal"

2024/4/26

text-generation-webui error , character 'None'

有時候開啟chat 頁面會沒反應,一開始的 hello 訊息也沒出來。
console 的 error 是:
ERROR    Could not find the character "None" inside characters/. No character has been loaded.
  ...
  ...
File "/home/charles-chang/text-generation-webui/modules/chat.py", line 673, in load_character
    raise ValueError
查source 是在 parameter tab 的 chat tab 的Character option 中,沒有選任何一個(Assistant, Example),所以是None
選了之後就好了。


download model

大多需要 lfs,所以 apt install git-lfs 之後,就可以用了。
需要license 的好像還是只能手動。

msys2. SDL2 Hello

ref: 安裝需要的 package:
pacman -S git mingw-w64-x86_64-toolchain mingw64/mingw-w64-x86_64-SDL2 mingw64/mingw-w64-x86_64-SDL2_mixer mingw64/mingw-w64-x86_64-SDL2_image mingw64/mingw-w64-x86_64-SDL2_ttf mingw64/mingw-w64-x86_64-SDL2_net mingw64/mingw-w64-x86_64-cmake make
測試:
$ sdl2-config --cflags --libs
-IC:/msys64/ucrt64/include/SDL2 -Dmain=SDL_main
-LC:/msys64/ucrt64/lib -lmingw32 -mwindows -lSDL2main -lSDL2
用上面ref 的 example:
#include &;t;stdio.h>
#include <SDL2/SDL.h>

const int WIDTH = 800, HEIGHT = 600;

int main(int argc, char *argv[]) {
  SDL_Window *window;
  SDL_Renderer *renderer;
  if(SDL_Init(SDL_INIT_EVERYTHING) < 0) {
    printf("SDL_Init failed: %s\n", SDL_GetError());
    return 1;
  }

  window = SDL_CreateWindow("Hello, World!",
                                        SDL_WINDOWPOS_UNDEFINED,
                                        SDL_WINDOWPOS_UNDEFINED,
                                        WIDTH, HEIGHT,
                                        SDL_WINDOW_ALLOW_HIGHDPI);
  if(window == NULL) {
    printf("Could not create window: %s\n", SDL_GetError());
    return 1;
  }
  
  renderer = SDL_CreateRenderer(window, -1, 0);
  SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
  SDL_RenderClear(renderer);

  SDL_RenderPresent(renderer);
  
  SDL_Event event;
  while(1) {
    if(SDL_PollEvent(&event)) {
      if(event.type == SDL_QUIT) {
        break;
      }
    }
  }

  SDL_DestroyWindow(window);

  SDL_Quit();
  return 0;
}
build:
$ gcc -o testsdl testsdl.c `sdl2-config --cflags --libs`

msys2, pacmain -s 失敗: 簽章等級不明

Error:
來自 David Macek <david.macek.0@gmail.com> 的簽章信任等級不明
然後這一篇 有說明一個危險的方法,disable signature verification.
Disabling signature checking

Warning: Use with caution. Disabling package signing will allow pacman to install untrusted packages automatically.
If you are not concerned about package signing, you can disable PGP signature checking completely. 
Edit /etc/pacman.conf and uncomment the following line under [options]:

SigLevel = Never

You need to comment out any repository-specific SigLevel settings too because they override the global settings. 
This will result in no signature checking, which was the behavior before pacman 4. 
If you decide to do this, you do not need to set up a keyring with pacman-key. 
You can change this option later if you decide to enable package verification.

text-generation-webui run microsoft_Phi-3-mini-128k-instruct error : trust_remote_code=True

load 玩model出現錯誤,console 顯示
ValueError: Loading models/microsoft_Phi-3-mini-128k-instruct requires you to execute the configuration file in that repo on your local machine. 
Make sure you have read the code there to avoid malicious use, then set the option `trust_remote_code=True` to remove this error.
在model tab 有一個checkbox 剛好就是 trust_remote_code,上面的說明:
Set trust_remote_code=True while loading the tokenizer/model. To enable this option, start the web UI with the --trust-remote-code flag.
所以是在啟動的時候...
./start_linux.sh --listen --trust-remote-code
哪個checckout 就check 了,model load and run OK

2024/4/25

bin_decode support 的compress method:
typedef enum {
    LV_IMAGE_COMPRESS_NONE = 0,
    LV_IMAGE_COMPRESS_RLE,  /*LVGL custom RLE compression*/
    LV_IMAGE_COMPRESS_LZ4,
} lv_image_compress_t;
在 decompress_image( ) 中,參考這個欄位。
lv_bin_decoder_open( ),

2024/4/5

Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).

To configure your current shell, you need to source
the corresponding env file under $HOME/.cargo.

This is usually done by running one of the following (note the leading DOT):
. "$HOME/.cargo/env"            # For sh/bash/zsh/ash/dash/pdksh
source "$HOME/.cargo/env.fish"  # For fish