20 篇文章带有标签 “macbookpro”

Qwen (通义千问)

快速开始

克隆代码

git clone https://github.com/QwenLM/Qwen.git
cd Qwen

创建虚拟环境

python -m venv env
source env/bin/activate

安装依赖

pip install -r requirements.txt

创建大模型链接

mkdir Qwen
ln -s /Users/junjian/HuggingFace/Qwen/Qwen-14B-Chat Qwen/Qwen-14B-Chat
ln -s /Users/junjian/HuggingFace/Qwen/Qwen-1_8B Qwen/Qwen-1_8B
ln -s /Users/junjian/HuggingFace/Qwen/Qwen-1_8B-Chat Qwen/Qwen-1_8B-Chat
ln -s /Users/junjian/HuggingFace/Qwen/Qwen-7B-Chat Qwen/Qwen-7B-Chat

聊天

  • 命令行聊天
python cli_demo.py
  • Web 聊天
python web_demo.py

FastChat

克隆代码

git clone https://github.com/lm-sys/FastChat
cd FastChat

创建虚拟环境 python -m venv env source env

MLX LLMS Examples

MLX Examples

克隆代码

git clone https://github.com/ml-explore/mlx-examples
cd mlx-examples

创建虚拟环境

python -m venv env
source env/bin/activate

pip install -r llms/phi2/requirements.txt
pip install -r llms/qwen/requirements.txt

创建大模型链接 mkdir llms/phi2/microsoft ln -s /Users/junjian/HuggingFace/microsoft/phi-2 llms/phi2/microsoft/phi-2 mkdir llms/qwen/Qwen ln -s /Users/junjian/HuggingFace/Qwen/Qwen-14B-Chat llms/qwen/Qwen/Qwen-14B-Chat ln -s /Users/junjian/HuggingFace/Qwen/Qwen-1_8B llms/qwen/Qwen/Qwen-1_8B ln -s /Users/junjian/HuggingFace/Qwen/Qwen-1_8B-Chat llms/qwen/Qwen/Qwen-1_8

Copilot for CLI

Copilot for CLI

GitHub CLI

在 macOS 安装 GitHub CLI

  • 安装
brew install gh
  • 升级
brew upgrade gh
  • 登录
gh auth login
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations on this host? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? How would you like to authenticate GitHub CLI? Login with a web browser

! First copy your one-time code: EA2E-F864
Press Enter to open github.com in your browser... 
✓ Authentication complete.
  • 查看登录状态
gh auth status
github.com
  ✓ Logged in to github.com account wang-junjian (keyring)
  - Active account: true
  - Git operations protocol: https
  - Token: gho_************************************
  - Token scopes: 'gist', 'read:org', 'repo', 'workflow'

SeamlessM4T — Massively Multilingual & Multimodal Machine Translation(大规模多语言和多模式机器翻译)

Seamless Communication

  • ASR: Automatic speech recognition for 96 languages.
  • S2ST: Speech-to-Speech translation from 100 source speech languages into 35 target speech languages.
  • S2TT: Speech-to-text translation from 100 source speech languages into 95 target text languages.
  • T2ST: Text-to-Speech translation from 95 source text languages into 35 target speech languages.
  • T2TT: Text-to-text translation (MT) from 95 source text languages into 95 target text languages.

SeamlessM4T 概述

安装 [Seamless Communication][seamless_communication]

克隆仓库 git clone https://github.

在 Mac 上安装 NGINX

安装

brew update
brew install nginx

启动服务

brew services start nginx
Docroot is: /opt/homebrew/var/www

The default port has been set in /opt/homebrew/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /opt/homebrew/etc/nginx/servers/.

To start nginx now and restart at login:
  brew services start nginx
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/nginx/bin/nginx -g daemon\ off\;
  • 编辑 /opt/homebrew/etc/nginx/nginx.conf 修改端口号
  • 编辑 /opt/homebrew/var/www/index.html 修改默认页面

停止服务

brew services stop nginx

重启服务 brew services restar

macOS 能连上 WiFi 但无法上网

问题描述

我的 MacBook Pro M2 Max 能够连接上 WiFi,但是无法上网,我进行了以下尝试:

  1. 路由器(没有问题);
  2. 重启电脑;
  3. 断开 WiFi 重新连接;

解决方案

最后,我在抖音上看到了一个解决方案,我尝试了一下,果然解决了问题。

打开访达,按下Command + Shift + G,输入/Library/Preferences/SystemConfiguration/,除com.apple.Boot.plist文件外,删除其他所有文件,然后重启电脑。

在 MacBook Pro M2 Max 上测试 ChatGLM2-6B

ChatGLM2-6B

ChatGLM2-6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本,在保留了初代模型对话流畅、部署门槛较低等众多优秀特性的基础之上,ChatGLM2-6B 引入了如下新特性:

  1. 更强大的性能:基于 ChatGLM 初代模型的开发经验,我们全面升级了 ChatGLM2-6B 的基座模型。ChatGLM2-6B 使用了 GLM 的混合目标函数,经过了 1.4T 中英标识符的预训练与人类偏好对齐训练,评测结果显示,相比于初代模型,ChatGLM2-6B 在 MMLU(+23%)、CEval(+33%)、GSM8K(+571%) 、BBH(+60%)等数据集上的性能取得了大幅度的提升,在同尺寸开源模型中具有较强的竞争力。
  2. 更长的上下文:基于 FlashAttention 技术,我们将基座模型的上下文长度(Context Length)由 ChatGLM-6B 的 2K 扩展到了 32K,并在对话阶段使用 8K 的上下文长度训练,允许更多轮次的对话。但当前版本的 ChatGLM2-6B 对单轮超长文档的理解能力有限,我们会在后续迭代升级中着重进行优化。
  3. 更高效的推理:基于 Multi-Query Attention 技术,ChatGLM2-6B 有更高效的推理速度和更低的显存占用:在官方的模型实现下,推理速度相比初代提升了 42%,INT4 量化下,6G 显存支持的对话长度由 1K 提升到了 8K。

加速 Docker 构建镜像

查看镜像信息

操作系统版本

cat /etc/os-release 
  • Debian
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
  • Ubuntu
PRETTY_NAME="Ubuntu Jammy Jellyfish (development branch)"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

Python 配置共享软件包缓存

共享软件包缓存的好处是,一旦用户已经下载了软件包的特定版本,它将不会再次下载并存储在单独的缓存中。这节省了磁盘使用量并加快了安装速度,因为它不需要再次下载软件包。

Conda 查看 Conda 当前环境的信息 conda info active environment : base active env location : /opt/miniconda shell level : 1 user config file : /Users/junjian/.condarc populated config files : conda version : 23.3.1 conda-build version : not installed python version : 3.10.9.final.0 virtual packages : __archspec=1=arm64 __osx=13.2.1=0 __unix=0=0 base environment : /opt/miniconda (writable) conda av data dir : /opt/miniconda/etc/conda conda av metadata url : None channel URLs : https://repo.anaconda.

OpenAI API Documentation Speech to Text

开发文档

Speech to text

API reference Audio

查看音频文件信息

file

data/podcast_clip.mp3: Audio file with ID3 version 2.4.0, contains: MPEG ADTS, layer III, v1, 64 kbps, 44.1 kHz, Stereo

ffprobe ffprobe -hide_banner data/podcast_clip.mp3 Input #0, mp3, from 'data/podcast_clip.mp3': Metadata: major_brand : M4A minor_version : 512 compatible_brands: M4A isomiso2 date : 2023-02-06 14:59 title : "Clip created on ListenNotes.com" encoder : Lavf58.76.100 Duration: 00:03:00.04, start: 0.025057, bitrate: 128 kb/s Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s Metadata: encoder : Lavc58.

在 MacBook Pro M2 Max 上测试 ChatGLM-6B

ChatGLM-6B 是一个开源的、支持中英双语的对话语言模型,基于 General Language Model (GLM) 架构,具有 62 亿参数。

聊天 ChatGLM-6B

下载

克隆

https://github.com/THUDM/ChatGLM-6B.git
cd ChatGLM-6B

下载模型

git clone https://huggingface.co/THUDM/chatglm-6b THUDM/chatglm-6b
  • 在国内为了加快下载速度,模型文件可以单独从 清华云 下载。

在 MacBook Pro M2 Max 上测试 LLaMA

LLaMA

LLaMA-13B 在大多数基准上的表现优于 GPT-3(175B),LLaMA-65B 与最好的型号 Chinchilla-70B 和 PaLM-540B 具有竞争力。

克隆

git clone https://github.com/facebookresearch/llama
cd llama

下载模型

修改 download.sh,配置下载模型的 地址(PRESIGNED_URL)下载目录(TARGET_FOLDER)

vim download.sh
PRESIGNED_URL="https://agi.gpt4.org/llama/LLaMA/*"             # replace with presigned url from email
TARGET_FOLDER="./"             # where all files should end up
bash download.sh

llama.cpp

构建

git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
make

拷贝 LLaMA 模型到当前目录 ls .

在 MacBook Pro M2 Max 上测试 Whisper

准备音频文件

macOS 上打开 QuickTimePlayer

  1. [文件] -> [新建音频录制]
  2. 录制
  3. 朗读:荷兰发布了一份主题为“宣布即将对先进半导体制造设备采取的出口管制措施”的公告表示,鉴于技术的发展和地缘政治的背景,政府已经得出结论,有必要扩大现有的特定半导体制造设备的出口管制。
  4. 停止
  5. 保存(test.m4a)

m4a 转换 wav

ffmpeg -i test.m4a -ar 16000 -ac 1 -c:a pcm_s16le test.wav

OpenAI Whisper

创建虚拟环境

conda create --name whisper python
conda activate whisper

安装

pip install --upgrade --no-deps --force-reinstall git+https://github.com/openai/whisper.git

wget https://raw.githubusercontent.com/openai/whisper/main/requirements.txt
pip install -r requirements.txt

测试 模型默认保存在 ~/.cache/whisper ls ~/.cache/whisper base.pt large-v2.

在 MacBook Pro M2 Max 上使用 FFmpeg

Apple 芯片上进行硬件加速的框架

Video Toolbox

VideoToolbox 是一个低级框架,可提供对硬件编码器和解码器的直接访问。它提供视频压缩和解压缩服务,以及存储在 CoreVideo 像素缓冲区中的光栅图像格式之间的转换。这些服务以会话对象(压缩、解压缩和像素传输)的形式提供。

VideoToolbox还包括一些命令行工具,例如vttool、vtenc、vtdecode等,可以在终端中使用。这些工具可以用来检查视频的属性、转码视频、将视频转换为图像序列等任务。

Audio Toolbox

AudioToolbox 是一个音频处理框架,支持音频处理的硬件加速,它提供了一系列用于音频编码、解码、转换和处理的API接口。

安装 FFmpeg

创建目录

mkdir /opt/ffmpeg && cd /opt/ffmpeg

方法一:使用 curl

curl https://evermeet.cx/ffmpeg/ffmpeg-6.0.7z | tar -xz
curl https://evermeet.cx/ffmpeg/ffprobe-6.0.7z | tar -xz
curl https://evermeet.cx/ffmpeg/ffplay-6.0.7z | tar -xz

在 MacBook Pro M2 Max 上安装 OpenVINO

安装 OpenVINO(手动编译)

brew install cmake
brew install automake
brew install --build-from-source libtool
brew install --build-from-source libunistring
brew install --build-from-source libidn2
brew install --build-from-source wget
brew install --build-from-source libusb

sudo conda install scons -y                                                                        

# 克隆时把依赖的子模块进行克隆(先克隆OpenVINO,再进行子模块克隆失败)
git clone --depth 1 --recurse-submodules https://github.com/openvinotoolkit/openvino.git

cd openvino
python3 -m pip install -r src/bindings/python/wheel/requirements-dev.txt

# 安装OpenCV(可选)
sudo conda install -c conda-forge opencv

mkdir build && cd build

# 配置(-DOPENVINO_EXTRA_MODULES=../openvino_contrib/modules/arm_plugin 好像不需要)
cmake -DCMAKE_BUILD_TYPE=Release ..

# 编译
cmake --build . --config Release --parallel $(sysctl -n hw.ncpu)
**没有生成 wheel**

# 安装
sudo mkdir /opt/openvino
sudo cmake -DCMAKE_INSTALL_PREFIX=/opt/openvino -P cmake_install.cmake

# 查看可用设备
./bin/arm64/Release/hello_query_device 
[ INFO ] Build ................................. 2023.0.0-1-b300df1be6c
[ INFO ] 
[ INFO ] Available devices: 
[ INFO ] CPU
[ INFO ] 	SUPPORTED_PROPERTIES: 
[ INFO ] 		Immutable: SUPPORTED_METRICS : SUPPORTED_METRICS SUPPORTED_CONFIG_KEYS RANGE_FOR_ASYNC_INFER_REQUESTS RANGE_FOR_STREAMS
[ INFO ] 		Immutable: SUPPORTED_CONFIG_KEYS : LP_TRANSFORMS_MODE DUMP_GRAPH PERF_COUNT CPU_THROUGHPUT_STREAMS CPU_BIND_THREAD CPU_THREADS_NUM CPU_THREADS_PER_STREAM BIG_CORE_STREAMS SMALL_CORE_STREAMS THREADS_PER_STREAM_BIG THREADS_PER_STREAM_SMALL SMALL_CORE_OFFSET ENABLE_HYPER_THREAD NUM_STREAMS INFERENCE_NUM_THREADS AFFINITY
[ INFO ] 		Mutable: PERF_COUNT : YES
[ INFO ] 		Immutable: AVAILABLE_DEVICES : NEON
[ INFO ] 		Immutable: FULL_DEVICE_NAME : arm_compute::NEON
[ INFO ] 		Immutable: OPTIMIZATION_CAPABILITIES : FP16 FP32
[ INFO ] 		Immutable: RANGE_FOR_ASYNC_INFER_REQUESTS : 1 12 1
[ INFO ] 		Mutable: PERFORMANCE_HINT : ""
[ INFO ] 		Immutable: RANGE_FOR_STREAMS : 1 12
[ INFO ] 		Mutable: CPU_THROUGHPUT_STREAMS : 1
[ INFO ] 		Mutable: CPU_BIND_THREAD : NO
[ INFO ] 		Mutable: CPU_THREADS_NUM : 0
[ INFO ] 		Mutable: CPU_THREADS_PER_STREAM : 12
[ INFO ] 		Mutable: BIG_CORE_STREAMS : 0
[ INFO ] 		Mutable: SMALL_CORE_STREAMS : 0
[ INFO ] 		Mutable: THREADS_PER_STREAM_BIG : 0
[ INFO ] 		Mutable: THREADS_PER_STREAM_SMALL : 0
[ INFO ] 		Mutable: SMALL_CORE_OFFSET : 0
[ INFO ] 		Mutable: ENABLE_HYPER_THREAD : YES
[ INFO ] 		Mutable: NUM_STREAMS : 1
[ INFO ] 		Mutable: INFERENCE_NUM_THREADS : 0
[ INFO ] 		Mutable: AFFINITY : NONE
[ INFO ] 

在 MacBook Pro M2 Max 上安装 PyTorch

安装 PyTorch

sudo conda create --name pytorch python
conda activate pytorch

conda install pytorch torchvision torchaudio -c pytorch

安装每日构建版本

pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu

升级

pip3 install --upgrade --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu

训练模型 import torch import torchvision import torchvision.transforms as transforms print(f"PyTorch version: {torch.

在 MacBook Pro M2 Max 上安装 TensorFlow

安装 TensorFlow

sudo conda create --name tensorflow python
conda activate tensorflow

# 不指定环境(-n),默认安装到base环境
sudo conda install -c apple -n tensorflow tensorflow-deps
pip install tensorflow-macos
pip install tensorflow-metal
sudo conda install notebook -y

pip install numpy  --upgrade
pip install pandas  --upgrade
pip install matplotlib  --upgrade
pip install scikit-learn  --upgrade
pip install scipy  --upgrade
pip install plotly  --upgrade

验证 import sys import tensorflow.keras import tensorflow as tf import platform print(f"Python Platform: {platform.

在 MacBook Pro M2 Max 上安装软件

Apple macOS Command

办公

WPS

Chrome 浏览器

Chrome 插件

Awesome Screenshot

Google 翻译

工具

数码测色计使用手册

LICEcap

My Zsh

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

V2rayU

Unzip One: RAR ZIP Extractor

FileZilla

macSVG

OmniGraffle

CleanMyMacX

ImageMagick(图像处理)

brew install imagemagick

asitop - Performance monitoring CLI tool for Apple Silicon

pip install asitop

jq

brew install jq

rar

brew install rar

unrar x <filename.rar>

开发 GitHub Desktop Visual Studi

在 MacBook Pro M2 Max 上构建开发环境

今天预订的 MacBook Pro M2Max 16寸 顶配 64G内存 2T硬盘到了,¥36097 。

硬件信息

芯片、内存

system_profiler SPHardwareDataType | head -n 9
Hardware:

    Hardware Overview:

      Model Name: MacBook Pro
      Model Identifier: Mac14,6
      Model Number: XXXXXXXXXXXX
      Chip: Apple M2 Max
      Total Number of Cores: 12 (8 performance and 4 efficiency)
      Memory: 64 GB

硬盘

system_profiler SPStorageDataType | head -n 8
Storage:

    Macintosh HD:

      Free: 1.37 TB (1,372,357,345,280 bytes)
      Capacity: 2 TB (1,995,218,165,760 bytes)
      Mount Point: /System/Volumes/Update/mnt1
      File System: APFS

更改主机名

sudo scutil --set HostName MBP

hostname
MBP

HomeBrew 安装 /bin/bash -c "$(