WebLLM
redis Connection refused
redis 容器自身,对 redis 的操作(连接使用)都 ok。 宿主机或其他容器连接 redis 总是报 Connection refused
错误。这里使用了 redis.conf
。 将 redis.conf
的 bind 修改如下。
# 修改 redis.conf bind (默认是 bind 127.0.0.1 -::1)
bind 0.0.0.0 -::1
# 重启 redis
docker restart xxx(redis 容器 id)
重点
其他容器连接 redis 时,host 可以写 redis 这个和 docker-compose.yaml
中配置的 service 相对应。这个并不是容器名。连接 mysql 也可以这样。
services:
mysql:
…
redis:
…
redis 其他配置
**docker-compose.yaml 中
# volume 配置 (其中,宿主机的 redis.conf 不存在,就会使用默认的 redis.conf)
# 这里主要三个方面:配置文件、数据、日志
volumes:
- ./conf/redis/redis.conf:/etc/redis/redis.conf
- ${DATA_DIR}/redis:/data:rw
- ${LOG_DIR}/redis:/logs
# 设置密码启动 redis**
# 123456 是 redis 密码
command: redis-server /etc/redis/redis.conf --requirepass "123456"
redis.conf 配置
配置项 | 描述 |
---|---|
bind | 指定本机网卡对应的IP地址,限制本机访问,默认 bind 127.0.0.1 |
daemonize | 指定是否为守护进程方式运行,默认值为no |
logfile | 指定日志文件路径,默认值为 logfile ’ ', 默认为控制台打印,并没有日志文件生成 |
appendonly | 是否开启持久化,默认值为 no |
当 daemonize 设置了yes,表示redis在后台运行,当执行 docker-compose 执行启动 redis 进程时,docker 发现自己无事可做,容器自动结束,所以导致 redis 启动失败。
appendonly 为 yes 时,volume 需要配置 :rw,指定可写可读。
容器启动后设置密码
# 找到容器 id
docker ps
# 进入容器
docker exec -it xxx(redis 容器 id-前三位即可) bash
# 进入 redis
redis-cli
# redis 使用 (如果没设置密码,可以使用了。如果设置了密码,则提示 no auth)
redis get key
# 可以查看密码信息
config get requirepass
# 设置密码
config set requirepass yourPassword
# 输入密码
auth yourPassword
# 也可以在连接的时候带上密码
redic-cli -a yourPassword
docker 网络
常用命令
# 显示网络
docker network ls
# 查看某个网络信息
docker network inspect xxx
# 删除网路
docker network rm xxx
# 批量删除网络
docker network rm $(docker network ls -q)
批量删除网络,有默认的三个网络是不能删除的。无论是批量删,还是单独删,都不可以。这三个网络是 bradge、host、none
。
NETWORK ID NAME DRIVER SCOPE
a0457db48e55 bridge bridge local
f07f326dbd2b host host local
437d811528b0 none null local
操作
- 设置主机名。
- 设置 ssh 连接一段时间后,断开的问题。
- 自定义用户,禁用 root 用户登录(使用普通用户登录,并使用公钥登录)。
- 安装 docker 环境。
操作
# 先安装依赖
yum install -y yum-utils device-mapper-persistent-data lvm2
# 添加阿里云仓库
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 安装
yum -y install docker-ce
# 启动
systemctl start docker
# 设置开机自启动
systemctl enable docker
# docker info
再来安装 docker-compose
打开 https://github.com/docker/compose/tags 选择想要的版本,点击进去。

这里我选择的 v2.23.3,打开后的链接是这个。
https://github.com/docker/compose/releases/tag/v2.23.3
选择对应系统的文件,我这里选择的是 docker-compose-linux-x86_64

下载
cd /usr/local/src
wget https://github.com/docker/compose/releases/download/v2.23.3/docker-compose-linux-x86_64
mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version
ubuntu 安装 docker
移除旧版本
如果你已经安装了旧版本的 Docker,首先卸载旧版本:
sudo apt remove docker docker-engine docker.io containerd runc
安装依赖包
sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
添加 Docker 的官方 GPG 密钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
设置 Docker 的稳定版存储库
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
安装 Docker Engine
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io
验证安装
运行以下命令验证 Docker 是否正确安装:
sudo docker run hello-world
将用户添加到 docker 用户组
为了避免在每次运行 Docker
命令时都需要使用 sudo
,可以将当前用户添加到 docker
用户组:
sudo usermod -aG docker $USER
请注意,在更改用户组后,你可能需要注销并重新登录才能使更改生效。
安装 Docker Compose
下载 Docker Compose 的二进制文件:
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
授予执行权限:
sudo chmod +x /usr/local/bin/docker-compose
验证 Docker Compose 是否正确安装:
docker-compose --version
mac docker 配置国内镜像
通过 docker 客户端工具。点击设置->Docker Engine。增加以下配置。
{
…,
"registry-mirrors": [
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn"
]
}
点击 Apply & Restart 按钮,保存并重启。
# 查看
docker info
感觉用了镜像速度也那样。
在自己的服务器环境使用语音转视频,需要配置 ice server。而这个玩意先得创建通信资源。创建通信资源,在后台就可以实现。ice server 可以使用编程语言去获取。

相关文档
代码
这里以 python 来获取。只需要准备好连接字符串(endpoint)就好,这个就是需要去后台创建通信资源。
# issue-relay-tokens.py
from azure.communication.networktraversal import CommunicationRelayClient
from azure.identity import DefaultAzureCredential
from azure.communication.identity import CommunicationIdentityClient
# You can find your endpoint and access token from your resource in the Azure Portal
connection_str = "endpoint=https://xxxx.communication.azure.com/;accesskey=xxxx"
endpoint = "https://xxxx.communication.azure.com/"
# To use Azure Active Directory Authentication (DefaultAzureCredential) make sure to have
# AZURE_TENANT_ID, AZURE_CLIENT_ID and AZURE_CLIENT_SECRET as env variables.
# We also need Identity client to get a User Identifier
# identity_client = CommunicationIdentityClient(endpoint, DefaultAzureCredential())
# relay_client = CommunicationRelayClient(endpoint, DefaultAzureCredential())
#You can also authenticate using your connection string
identity_client = CommunicationIdentityClient.from_connection_string(connection_str)
relay_client = CommunicationRelayClient.from_connection_string(connection_str)
identity_client.create_user()
relay_configuration = relay_client.get_relay_configuration()
for iceServer in relay_configuration.ice_servers:
assert iceServer.username is not None
print('Username: ' + iceServer.username)
assert iceServer.credential is not None
print('Credential: ' + iceServer.credential)
assert iceServer.urls is not None
for url in iceServer.urls:
print('Url:' + url)
执行 python .\issue-relay-tokens.py
,如果配置都正确,就会得到 ice 相关信息。
Username: xxx1
Credential: cre1
Url:stun:relay.communication.microsoft.com:3478
Url:turn:relay.communication.microsoft.com:3478
Username: xxx2
Credential: cre2
Url:stun:20.202.255.225:3478
Url:turn:20.202.255.225:3478
转换截图

通过文字输入,输出视频+语音虚拟形象输出。可以尝试尝试。
使用微软 Speech Studio
样例
https://speech.microsoft.com/portal/talkingavatar
训练声音
https://speech.microsoft.com/portal/customvoice/overview
精简版训练
https://learn.microsoft.com/zh-cn/azure/ai-services/speech-service/custom-neural-voice-lite
申请授权
https://speech.microsoft.com/portal/customvoice/accessrequirement
通过 git 的方式,很难下载到 huggingface。于是就网上找方法,还真找到了方法。
https://zhuanlan.zhihu.com/p/663712983
上边链接总结了多种方法。这里,只选他说的最好用的方法,使用 huggingface-cli。不做选择其他选择。这里是尝试快速下载过模型。
准备
- 科学上网
- 该有的 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 会针对选择的显示器进行切换。
使用 hf_transfer
hf_transfer 依附并兼容 huggingface-cli,是 hugging face 官方专门为提高下载速度基于 Rust 开发的一个模块
安装: pip install -U hf-transfer
开启(linux/mac): export HF_HUB_ENABLE_HF_TRANSFER = 1
开启(win): $env:HF_HUB_ENABLE_HF_TRANSFER = 1
使用: huggingface-cli download --resume-download mlc-ai/mlc-chat-Llama-2-7b-chat-hf-q4f16_1 --local-dir mlc
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