笔记笔记
  • Home
  • AI&ML
  • Example
  • Zoo
  • 关于
⌘ K
Ubuntu
NVIDIA
Python 环境
systemctl
最后更新时间:
Copyright © 2023-2024 | Powered by dumi | GuoDapeng | 冀ICP备20004032号-1 | 冀公网安备 冀公网安备 13024002000293号

TABLE OF CONTENTS

‌
‌
‌
‌

Python 环境

Poetry

依赖项管理和打包的工具。

Poetry

curl -sSL https://install.python-poetry.org | python3 -

出现 Add export PATH="/home/admin1/.local/bin:$PATH" to your shell configuration file. 提示。 在 sudo vi ~/.bashrc 添加即可。

项目配置

# 创建项目
poetry new StructBERTTrain
# 设置虚拟环境在项目目录
poetry config virtualenvs.in-project true
# 设置镜像源
poetry source add --priority=primary mirrors https://pypi.tuna.tsinghua.edu.cn/simple/
# 查看配置
poetry config --list
# 创建虚拟环境
poetry env use python3
# 进入虚拟环境
poetry shell
# 安装依赖;新建项目一遍没有依赖
poetry install
# 查看依赖树;新项目也没啥可看的
poetry show --tree

添加依赖

ModelScope

如果在 Ubuntu shell 卡住不动,可以尝试使用
> export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
环境变量

poetry add modelscope
poetry add numpy==1.24.1
pip install torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
# 如果出现这个错误,说明没有安装 modelscope[nlp]
# ModuleNotFoundError: ZeroShotClassificationPipeline: No module named 'transformers'
pip install "modelscope[nlp]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
poetry add fastapi

ModelScope