阿里云A10推理qwen

硬件配置

bash 复制代码
vCPU:32核
内存:188 GiB
宽带:5 Mbps
GPU:NVIDIA A10 24G

cuda 安装

bash 复制代码
wget https://developer.download.nvidia.com/compute/cuda/12.1.0/local_installers/cuda-repo-rhel7-12-1-local-12.1.0_530.30.02-1.x86_64.rpm
sudo rpm -i cuda-repo-rhel7-12-1-local-12.1.0_530.30.02-1.x86_64.rpm
sudo yum clean all
sudo yum -y install nvidia-driver-latest-dkmssudo yum -y install cuda


#cudnn
wget https://developer.download.nvidia.com/compute/cudnn/9.0.0/local_installers/cudnn-local-repo-rhel7-9.0.0-1.0-1.x86_64.rpm
sudo rpm -i cudnn-local-repo-rhel7-9.0.0-1.0-1.x86_64.rpm
sudo yum clean all
sudo yum -y install cudnn

Anconda

bash 复制代码
chmod +xwr Anaconda3-2022.10-Linux-x86_64.sh
./Anaconda3-2022.10-Linux-x86_64.sh
Base: Python=3.9

torch

bash 复制代码
conda install pytorch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 pytorch-cuda=12.1 -c pytorch -c nvidia

env_test.py

python 复制代码
import torch # 如果pytorch安装成功即可导入
print(torch.cuda.is_available()) # 查看CUDA是否可用
print(torch.cuda.device_count()) # 查看可用的CUDA数量
print(torch.version.cuda) # 查看CUDA的版本号

bash 复制代码
pip install transformers==4.32.0 accelerate tiktoken einops scipy transformers_stream_generator==0.0.4 peft deepspeed
git clone https://github.com/Dao-AILab/flash-attention 
cd flash-attention && pip install .
pip install csrc/layer_norm
pip install csrc/rotary
pip install modelscope

问题:

1、subprocess.calledprocesserror: command '['which', 'g++']' returned non-zero exit status 1.

解决:

bash 复制代码
yum install make automake gcc gcc-c++ kernel-devel
yum group install "Development Tools" "Development Libraries"

2、RuntimeError: Error compiling objects for extension

解决:Pytroch和cuda不匹配,重新安装对应的cuda或者pytorch

3、nvidia-smi :Failed to initialize NVML: Driver/library version mismatch

解决:

bash 复制代码
yum remove nvidia-*
#重装cuda12.1

4、WARNING:root:Some parameters are on the meta device device because they were offloaded to the cpu.

内存不够:

test:

python 复制代码
from modelscope import AutoModelForCausalLM, AutoTokenizer
from modelscope import GenerationConfig

# Note: The default behavior now has injection attack prevention off.
#trust_remote_code=True 表示你信任远程的预训练模型,愿意运行其中的代码
tokenizer = AutoTokenizer.from_pretrained("qwen/Qwen-14B", trust_remote_code=True)

# use bf16
# model = AutoModelForCausalLM.from_pretrained("qwen/Qwen-14B", device_map="auto", trust_remote_code=True, bf16=True).eval()
# use fp16
# model = AutoModelForCausalLM.from_pretrained("qwen/Qwen-14B", device_map="auto", trust_remote_code=True, fp16=True).eval()
# use cpu only
# model = AutoModelForCausalLM.from_pretrained("qwen/Qwen-14B", device_map="cpu", trust_remote_code=True).eval()
# use auto mode, automatically select precision based on the device.
model = AutoModelForCausalLM.from_pretrained("qwen/Qwen-14B", device_map="auto", trust_remote_code=True).eval()

# Specify hyperparameters for generation. But if you use transformers>=4.32.0, there is no need to do this.
# model.generation_config = GenerationConfig.from_pretrained("Qwen/Qwen-14B", trust_remote_code=True)

inputs = tokenizer('蒙古国的首都是乌兰巴托(Ulaanbaatar)\n冰岛的首都是雷克雅未克(Reykjavik)\n埃塞俄比亚的首都是', return_tensors='pt')
inputs = inputs.to(model.device)
pred = model.generate(**inputs)
print(tokenizer.decode(pred.cpu()[0], skip_special_tokens=True))
# 蒙古国的首都是乌兰巴托(Ulaanbaatar)\n冰岛的首都是雷克雅未克(Reykjavik)\n埃塞俄比亚的首都是亚的斯亚贝巴(Addis Ababa)...
相关推荐
Ven%2 小时前
centos查看硬盘资源使用情况命令大全
linux·运维·centos
上辈子杀猪这辈子学IT3 小时前
【Zookeeper集群搭建】安装zookeeper、zookeeper集群配置、zookeeper启动与关闭、zookeeper的shell命令操作
linux·hadoop·zookeeper·centos·debian
minihuabei3 小时前
linux centos 安装redis
linux·redis·centos
昔我往昔15 小时前
阿里云文本内容安全处理
安全·阿里云·云计算
Diamond技术流18 小时前
从0开始学习Linux——远程连接工具
linux·学习·centos·ssh·xshell·ftp
NETFARMER运营坛18 小时前
如何优化 B2B 转化率?这些步骤你不可不知
大数据·安全·阿里云·ai·ai写作
188_djh1 天前
# Python基础到实战一飞冲天(一)--linux基础(一)
linux·开发语言·python·ubuntu·centos·os·operationsystem
嘟嘟Listing1 天前
阿里云docker安装禅道记录
阿里云·docker·云计算
阿里云大数据AI技术1 天前
【EMNLP2024】阿里云人工智能平台 PAI 多篇论文入选 EMNLP2024
人工智能·阿里云·云计算·emnlp
潘帕斯的雄鹰1 天前
【1个月速成Java】基于Android平台开发个人记账app学习日记——第7天,申请阿里云SMS短信服务SDK
java·学习·阿里云·sms·短信服务sdk