在Jetson AGX Orin上体验ChatSQL

在Jetson AGX Orin上体验ChatSQL

阅读了 https://zhuanlan.zhihu.com/p/630230870

这篇文字之后,张小白就想玩一玩。考虑到它用到了大模型技术,还是先在Jetson AGX Orin上试试比较保险。

先创建conda环境:(考虑到pytorch的Jetson版本目前只有python3.8的版本)

conda create -n chatsql python=3.8

conda activate chatsql

cd /home1/zhanghui

git clone https://github.com/yysirs/ChatSQL.git

cd ChatSQL

pip install -r requirements.txt

等等,凡是在Jetson上安装torch都要小心。

在 requirements.txt注释掉torch

pip install -r requirements.txt

真是的,不知道在哪里又引发了torch。。。那就装完了再卸载吧!唉。

cd ..

安装torch 2.0.0 Jetson专用版:

pip install ./torch-2.0.0+nv23.05-cp38-cp38-linux_aarch64.whl

cd ChatSQL

mkdir DB

mkdir logs

# 生成本地数据库+插入数据

python local_database.py

# 基于GLM生成SQL

python main_gui.py

看日志也在连huggingface.co...

将ChatGLM2-6B的模型拷贝过来。

mkdir THUDM

cd THUDM

cp -r /home1/zhanghui/ChatGLM2-6B/THUDM/chatglm2-6b chatglm2-6b

编辑 main_gui.py,做如下改动:

os.environ["CUDA_VISIBLE_DEVICES"] = "0" tokenizer = AutoTokenizer.from_pretrained("./THUDM/chatglm2-6b", trust_remote_code=True) model = AutoModel.from_pretrained("./THUDM/chatglm2-6b", trust_remote_code=True).half().cuda()

python main_gui.py

添加图片注释,不超过 140 字(可选)

奇怪,好像没有变化。

----------------------------华丽的分割线---------------------------

考虑到刚刚源码编译了Pytorch的新版本,张小白不由得想,如果编译一个python 3.9的pytorch包,岂不是可以在conda 3.9的环境下运行了。

心动不如行动,那就开始试试吧!

conda create -n chatsql3.9 python=3.9

conda activate chatsql3.9

cd /home1/zhanghui

mkdir python3.9

cd python3.9

git clone https://github.com/cubenlp/ChatSQL

cd ChatSQL

pip install -r requirements.txt

这里可以看到它装了pytorch 2.0.1(但是显然不是jetson版本的)

我们来下载pytorch的源码:

git clone --recursive --branch v2.0.1http://github.com/pytorch/pytorch

设置环境变量:

export USE_NCCL=1

export USE_DISTRIBUTED=1 # skip setting this if you want to enable OpenMPI backend

export USE_QNNPACK=0

export USE_PYTORCH_QNNPACK=0

export TORCH_CUDA_ARCH_LIST="7.2;8.7"

export PYTORCH_BUILD_VERSION=2.0.1

export PYTORCH_BUILD_NUMBER=1

#sudo nvpmodel -m 0

#sudo jetson_clocks

cd pytorch

#pip install -r requirements.txt

#pip install scikit-build

#pip install ninja

python3 setup.py bdist_wheel

源码编译完成后,将dist下的whl文件复制到张小白常用的安装位置 /home1/zhanghui

安装一下:

pip install torch-2.0.1-cp39-cp39-linux_aarch64.whl --force-reinstall

按照官网提示操作一下:

cd /home1/zhanghui

cd python3.9

cd ChatSQL

mkdir DB

mkdir logs

# 生成本地数据库+插入数据

python local_database.py

# 基于GLM生成SQL

python main_gui.py

这个还整出新的问题来了吗?

pip install sklearn

打开:scikit-learn · GitHub

cd ..

mkdir scikit-learn

cd scikit-learn

git clone https://github.com/scikit-learn/scikit-learn -b 1.3.1

cd scikit-learn

python setup.py install

pip install Cython

再来:python setup.py install

回到ChatSQL目录:

cd /home1/zhanghui

cd python3.9/ChatSQL

python main_gui.py

还是一样。。并不是 scikit-learn包的问题。

换回到Python3.8的chatsql conda环境吧

conda deactivate

conda activate chatsql

cd /home1/zhanghui

cd ChatSQL

pip install ./torch-2.1.0a0+41361538.nv23.06-cp38-cp38-linux_aarch64.whl

python main_gui.py

绕了一圈,又绕回来了!

给维护者提了issue:python main_gui.py 报连不上HF · Issue #18 · cubenlp/ChatSQL · GitHub

答复不尽人如意。。。

仔细看日志:

requests.exceptions.SSLError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/models/sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 (Caused by SSLError(SSLCertVerificationError(1, "[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: Hostname mismatch, certificate is not valid for 'Hugging Face – The AI community building the future.'. (_ssl.c:1131)")))

貌似它在下载HuggingFace的 sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 这个包,张小白有点眼熟,不如直接下载好了传到本地试试。

将这个目录传到Orin的ChatSQL目录下。

再来:

python main_gui.py

感觉还是路径不对。

修改 prompt.py,将

embedder = SentenceTransformer('paraphrase-multilingual-MiniLM-L12-v2')

改为:

embedder = SentenceTransformer('/home1/zhanghui/ChatSQL/sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2')

再来:

python main_gui.py

根据提示,打开 http://192.168.199.181:7860

貌似暂时不能在其他机器访问。

登录到Orin的桌面打开 http://127.0.0.1:7860看看:

界面出来了。

提问:

貌似SQL生成了,但是没有找到数据。应该是库跟脚本不对应造成的。

换一个命令:

好像也是如此。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

张小白TWO

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值