Datawhale跨模态实践打卡|一、Mac配置环境

项目地址 :

https://github.com/datawhalechina/vced

环境配置

方式一:安装源码

由于我的brew版本旧了,出现诸多问题,直接重装了brew,这是一个国内镜像源的下载地址:

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

安装rust

brew install rustup
rustup-init    //选1
source "$HOME/.cargo/env

安装成功,查看rust版本

➜  ~ rustc --version                         
rustc 1.65.0 (897e37553 2022-11-02)

安装 ffmpfg

brew tap homebrew-ffmpeg/ffmpeg
brew install homebrew-ffmpeg/ffmpeg/ffmpeg
brew install homebrew-ffmpeg/ffmpeg/ffmpeg $(brew options homebrew-ffmpeg/ffmpeg/ffmpeg --compact)

这步真的巨慢,要install的太多了,耐心等待

终于安装成功

➜  ~ ffmpeg          
ffmpeg version 5.1.2 Copyright (c) 2000-2022 the FFmpeg developers
  built with Apple clang version 14.0.0 (clang-1400.0.29.202)

安装miniconda

minicondaanaconda的简化版,方便python版本管理
直接到官网找对应的版本下载,这里下载的 pkg,直接安装,然后检查是否安装成功:

➜  ~ conda --version
conda 4.12.0

中途有一个小插曲,命令行前面多了一个(base)

conda config --set auto_activate_base False

即可消除

给conda配国内镜像源

conda config --set show_channel_urls yes
sudo vim .condarc

复制以下信息到.condarc

channels:
 - defaults
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

最后

conda clean -i 
  • 查看装了哪些包
conda list
  • 查看conda环境
conda env list
  • 创建虚拟环境
conda create --name clip python=3.9
  • 激活虚拟环境
conda activate clip
  • 关闭虚拟环境
conda deactivate

配置pip源

mkdir ~/.pip
vim ~/.pip/.pip.conf

复制以下内容到pip.conf

[global]
trusted-host =  pypi.tuna.tsinghua.edu.cn
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

更新pip

pip3 install --upgrade pip

开始安装包

安装clip

cd ~/vced-main
pip install git+https://github.com/openai/CLIP.git

安装了几遍终于安装成功

Successfully built clip
Installing collected packages: wcwidth, urllib3, typing-extensions, tqdm, regex, pillow, numpy, idna, ftfy, charset-normalizer, torch, requests, torchvision, clip
Successfully installed charset-normalizer-2.1.1 clip-1.0 ftfy-6.1.1 idna-3.4 numpy-1.23.4 pillow-9.3.0 regex-2022.10.31 requests-2.28.1 torch-1.13.0 torchvision-0.14.0 tqdm-4.64.1 typing-extensions-4.4.0 urllib3-1.26.12 wcwidth-0.2.5

方式二:安装docker

下载 Docker 并安装,检查Docker版本

docker --version

报错

zsh: command not found: docker

到活动监视器可以看到,确实是有Docker。最后发现问题是没配环境,所以找不到docker,我们将路径复制粘贴到 .bash_profile 文件中:

vim ~/.bash_profile

//复制以下这两句
export DOCKER_PATH="/Applications/Docker.app/Contents/Resources/bin"
export PATH=".$PATH:$DOCKER_PATH"
//复制以上这两句

source ~/.bash_profile

再检查

➜  ~ docker --version
Docker version 20.10.21, build baeda1f

Docker 安装成功。可能是因为我升级了macOS13,docker总是未响应,还是用安装源码的方式来运行。

启动项目

依赖安装完毕,在conda环境下:

启动 server

# 进入 server 文件夹
cd code/service
# 安装相关依赖
pip install -r requirements.txt
# 启动服务端
python app.py

启动服务端时报错

ModuleNotFoundError: No module named 'docarray'

我立马pip install docarray还是给我报错,翻到 jina 官方文档看了我应该用conda的安装方式,重新安装

conda install -c conda-forge docarray

祈祷着不要再报错了,但是就是说、没用,搜搜看这个docarray是什么,好像相当重要,退出conda咱给它pip install全局安装得了,这下好了,又开始说找不到jina

ModuleNotFoundError: No module named 'jina'

继续全局安装jina,这次终于ok了

启动 web

# 进入 web 文件夹
cd code/web
# 安装相关依赖
pip install -r requirements.txt
# 启动服务端
streamlit run app.py

Streamlit默认启动的端口为8501,也可以通过 localhost:8501 进行访问

以上。

参考链接

[1] rust
[2] ffmpeg
[3] ffmpeg
[4] 命令行前(base)
[5] conda
[6] docarray
[7] docarray

你可能感兴趣的:(跨模态,macos,ffmpeg)