环境安装
环境安装
M1 Mac Anaconda
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh
sh Miniconda3-latest-MacOSX-arm64.sh
不自动激活 conda config --set auto*activate*base false
撤销设置 conda init --reverse $SHELL
创建激活Conda环境
conda create -n modelscope python=3.9
conda activate modelscope
查看环境
conda info --envs | grep "*"
删除环境
conda remove --name modelscope --all
安装Mac Pytorc
PyTorch 从 1.12 起对 Apple 的 M 系列芯片供了支持Metal Performance Shaders(MPS)后端来达成 GPU 加速
#pip install torch==1.12.0 torchvision==0.13.0 torchaudio==0.12.0
pip3 install torch torchvision torchaudio
验证是否支持 GPU 加速
python -c "import torch; print(torch.backends.mps.is_available())"
安装 tensorflow
conda install -c apple tensorflow-deps
GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1 python -m pip install tensorflow-macos==2.13.0
python -m pip install tensorflow-metal
TensorFlow 从2.4 版本开始支持 Mac M1 GPU 加速验证方法
python -c "import tensorflow as tf; print(len(tf.config.list_physical_devices('GPU')) > 0)"
安装 JAX
pip install jax flax
python -c "import jax; print(jax.devices())"
安装编译环境
Rust 和 Cargo
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
cv 需要安装 Cmake
brew install cmake
audio 需要安装 llvm
brew install llvm
安装 modelscope
# nlp,cv,audio,multi-modal,science
pip install "modelscope[nlp,multi-modal,science]" -f https://modelscope.oss-cn-lbeijing.aliyuncs.com/releases/repo.html
modelscope
AssertionError: device should be either cpu, cuda, gpu, gpu:X or cuda:X where X is the ordinal for gpu device.
Huggingface
qwen2 doc
Qwen/Qwen2.5-7B-Instruct
# pip install -U flash-attn --no-build-isolation
transformers-cli chat --model_name_or_path Qwen/Qwen2-7B-Instruct --torch_dtype auto --attn_implementation flash_attention_2 --device mps
翻译模型
nllb doc
facebook/nllb-200-distilled-600M, facebook/nllb-200-distilled-1.3B, acebook/nllb-200-1.3B, facebook/nllb-200-3.3B, facebook/nllb-moe-54b
mbart doc
facebook/mbart-large-cc25, facebook/mbart-large-50-many-to-many-mmt
madlad doc
google/madlad400-3b-mt, google/madlad400-7b-mt, google/madlad400-7b-mt-bt, google/madlad400-10b-mt
ModelSpace/GemmaX2-28-2B-v0.1, ModelSpace/GemmaX2-28-9B-v0.1
Mac M1 安装 modelscope 深度学习库
Grpcio fails installation for Tensorflow 2.5 on arm64 Apple Silicon