Write the Code. Change the World.

12月 13

通过 git 的方式,很难下载到 huggingface。于是就网上找方法,还真找到了方法。

https://zhuanlan.zhihu.com/p/663712983

上边链接总结了多种方法。这里,只选他说的最好用的方法,使用 huggingface-cli。不做选择其他选择。这里是尝试快速下载过模型。

准备

  1. 科学上网
  2. 该有的 python 环境

操作

以下载 https://huggingface.co/mlc-ai/mlc-chat-Llama-2-7b-chat-hf-q4f16_1/tree/main 模型为例。

打开终端

# 安装 huggingface-cli
pip install -U huggingface_hub

# 使用
# --resume-download 要下载的模型名
# --local-dir 下载保存的位置
huggingface-cli download --resume-download mlc-ai/mlc-chat-Llama-2-7b-chat-hf-q4f16_1 --local-dir mlc

好了,仅仅这样就好了。下载速度还是很快的,也有进度条。

win 的终端终究没 mac 的 iterm2 好用。不过 win 的进步速度比 mac 快多了。感觉 mac 几乎在吃老本。在多显示器的快捷键操作上,win 的体验却要比 mac 好。仅有一点 win 比 mac 差,就是多显示器中,某个显示器内的窗口切换。 win 会将所有的显示器都切换了,mac 会针对选择的显示器进行切换。

阅读全文 >>

12月 12

python 环境处理。 ERROR: Could not find a version that satisfies the requirement torch (from llama) (from versions: none)

参考阅读

https://download.pytorch.org/whl/torch/

https://pytorch.org/get-started/locally/

https://blog.csdn.net/qq_44832009/article/details/129351554

https://blog.csdn.net/qq_40630902/article/details/118356845

https://www.python.org/downloads/windows/

阅读全文 >>

12月 11

docker 的确是个好东西。该早一点就用起来。当下还在熟悉和练习中。

渐渐去丰富和完善。

.env

# 时区
TZ=Asia/Shanghai

# 项目对应文件夹
SOURCE_DIR=./www

# nginx https://nginx.org/
NGINX_NAME=nginx
NGINX_VERSION=1.25.3
NGINX_HTTP_HOST_PORT=80
NGINX_HTTPS_HOST_PORT=443
NGINX_CONFD_DIR=./conf/nginx/conf.d
NGINX_CONF_FILE=./conf/nginx/nginx.conf
NGINX_SSL_CERTIFICATE_DIR=./conf/nginx/ssl
NGINX_LOG_DIR=./logs/nginx

# php8.3
PHP_LOG_DIR=./logs/php8.3

# mysql
MYSQL_DATA=./data/mysql8.2-data
MYSQL_PORT=3306

# redis
REDIS_PORT=6379

阅读全文 >>

12月 04

记录一些问题

  1. 通过 docker-comppse.yml 配置多个服务(有 php,nginx,mysql 等),并运行。如果在 php 的 bash 中访问使用 nginx 或 mysql 这些服务呢。

当前,在项目中,无法通过 127.0.0.1 来连接 mysql 容器中的 mysql。可以通过修改 手动 修改 ip 的方式来搞定。

# 查看当前容器的 ip
ip addr

# php 和其他容器公用宿主机的 ip 修改项目中连接 mysql 的 ip 得到
172.19.0.1

docker php 安装 mysql_pdo 扩展

docker exec -it xxx bash

# 安装 pdo pdo_mysql 扩展
docker-php-ext-install pdo pdo_mysql

# 安装 mysqli 扩展
docker-php-ext-install mysqli

# 退出 重启 (xxx 容器 id)
exit
docker restart xxx

bash: ip: command not found

# 进入容器中
apt-get update

apt-get install -y iproute2

# 这个时候就有了
ip addr show

文章

https://www.jianshu.com/p/2217cfed29d7

https://blog.csdn.net/longfeng995/article/details/130704949

https://ricen.eu.org/index.php?control=doc&view=detail&id=326&i=1

阅读全文 >>

12月 01

常见命令一

# docker 信息
docker info
docker version

# 查看镜像
docker images

# 运行一个镜像
# --name 别名
# -p 端口映射( 宿主机端口:容器服务端口 )
# -d 以守护进程的方式运行(不加就会卡住占用窗口)
docker run --name my-nginx -d -p 80:80 nginx

# 查看活着的容器
docker ps

# 查看活所有容器
docker ps -a

# 停止容器
docker stop xxx

# 启动一个关闭的容器
docker start xxx

# 查看容器状态
docker stats

# 进入容器(以bash的形式进行交互模式)
docker exec -it xxx bash

# 退出容器(容器依然在运行)
exit

# 重启容器 (xxx 为容器 id 的前三个字符即可)
docker restart xxx

# 删除容器 (删除前需先停止)
docker rm xxx

# 删除镜像
docker rmi nginx

阅读全文 >>

11月 28

tauri 时间相关的处理。一般,找 tauri 的 api,就是找 rust 的。tauri 获取当前时间,获取时间戳。

https://docs.rs/chrono/0.4.26/chrono/#date-and-time

https://www.cnblogs.com/yjmyzz/p/event-with-tauri.html

获取当前年月日时分秒

use chrono::{DateTime, Local};

fn now_datetime() -> String {
  let datetime: DateTime<Local> = Local::now();
  let timestamp_str = datetime.format("%Y-%m-%d %H:%M:%S.%f").to_string();
  timestamp_str
}

需要在 Cargo.toml 中,加入以下配置。

[dependencies]
…
chrono = "0.4"

阅读全文 >>

11月 28

tauri dev 项目的时候,axios 是没有问题。当 build 后,安装使用,axios 就会出现问题。这个时候,需要给 axios 增加一个 adapter 就好。 当然 tauri 的 allowlist 的配置也是要好的。

https://github.com/persiliao/axios-tauri-api-adapter

操作

pnpm add axios-tauri-api-adapter

# 在封装 axios 的地方加入下边的配置
import axiosTauriApiAdapter from 'axios-tauri-api-adapter';

const defaultConfig: AxiosRequestConfig = {
  baseURL: VITE_APP_BASE_API,
  timeout: 20000,
  withCredentials: false,
  adapter: axiosTauriApiAdapter
}

然后修改 tauri.conf.json 文件。

  "tauri": {
    "allowlist": {
      "all": true,
      "http": {
        "all": true,
        "request": true,
        "scope": ["http://**", "https://**"]
      }
    }
  }

好了,再去打包就没问题了。

pnpm tauri build

阅读全文 >>