ai

modelscope环境

1.创建虚拟环境


conda create -n modelscope python=3.10
conda activate modelscope

windows:
activate modelscope


pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/

安装显卡驱动和cuda 安装cuda对应版本的pytorch:

pytorch下载地址:

https://download.pytorch.org/whl/cu117/torch_stable.html

https://download.pytorch.org/whl/torch

安装依赖:

pip install -r modelscpe-requirements.txt

pip install gevent pip install flask gpu版再安装 pip install tf_keras

模型文件目录设置:

import os
os.environ['MODELSCOPE_CACHE'] = './model_data'
os.environ["CUDA_VISIBLE_DEVICES"] = "1" # 指定gpu卡

测试:

python -c "from modelscope.pipelines import pipeline;print(pipeline('word-segmentation')('今天天气不错,适合 出去游玩'))"

只下载模型文件: 使用sdk下载模型文件示例:

#模型下载
from modelscope import snapshot_download
import os
os.environ['MODELSCOPE_CACHE'] = './model_data'
model_dir = snapshot_download('Qwen/Qwen2.5-72B-Instruct')

requirements.txt如下:

absl-py==2.1.0
addict==2.4.0
aiohappyeyeballs==2.4.4
aiohttp==3.11.11
aiosignal==1.3.2
aliyun-python-sdk-core==2.16.0
aliyun-python-sdk-kms==2.16.5
astunparse==1.6.3
async-timeout==5.0.1
attrs==24.3.0
blinker==1.9.0
certifi==2024.12.14
cffi==1.17.1
charset-normalizer==3.4.0
click==8.1.8
colorama==0.4.6
crcmod==1.7
cryptography==44.0.0
datasets==2.16.0
dill==0.3.7
filelock==3.16.1
Flask==3.1.0
flatbuffers==24.12.23
frozenlist==1.5.0
fsspec==2023.10.0
gast==0.6.0
gevent==24.11.1
google-pasta==0.2.0
greenlet==3.1.1
grpcio==1.68.1
h5py==3.12.1
huggingface-hub==0.27.0
idna==3.10
itsdangerous==2.2.0
Jinja2==3.1.5
jmespath==0.10.0
joblib==1.4.2
keras==3.7.0
libclang==18.1.1
Markdown==3.7
markdown-it-py==3.0.0
MarkupSafe==3.0.2
mdurl==0.1.2
ml-dtypes==0.4.1
modelscope==1.21.0
mpmath==1.3.0
multidict==6.1.0
multiprocess==0.70.15
namex==0.0.8
networkx==3.4.2
numpy==1.26.4
opt_einsum==3.4.0
optree==0.13.1
oss2==2.19.1
packaging==24.2
pandas==2.2.3
pillow==11.0.0
propcache==0.2.1
protobuf==5.29.2
pyarrow==18.1.0
pyarrow-hotfix==0.6
pycparser==2.22
pycryptodome==3.21.0
Pygments==2.18.0
python-dateutil==2.9.0.post0
pytz==2024.2
PyYAML==6.0.2
regex==2024.11.6
requests==2.32.3
rich==13.9.4
safetensors==0.4.5
scikit-learn==1.6.0
scipy==1.14.1
sentence-transformers==3.3.1
simplejson==3.19.3
six==1.17.0
sortedcontainers==2.4.0
sympy==1.13.3
tensorboard==2.18.0
tensorboard-data-server==0.7.2
tensorflow==2.18.0
tensorflow-io-gcs-filesystem==0.31.0
termcolor==2.5.0
threadpoolctl==3.5.0
tokenizers==0.21.0
tqdm==4.67.1
transformers==4.47.1
typing_extensions==4.12.2
tzdata==2024.2
urllib3==2.3.0
Werkzeug==3.1.3
wrapt==1.17.0
xxhash==3.5.0
yarl==1.18.3
zope.event==5.0
zope.interface==7.2

关于作者

程序员,软件工程师,java, golang, rust, c, python,vue, Springboot, mybatis, mysql,elasticsearch, docker, maven, gcc, linux, ubuntu, centos, axum,llm, paddlepaddle, onlyoffice,minio,银河麒麟,中科方德,rpm