venv
https://docs.python.org/zh-cn/3/library/venv.html
创建
1 | python -m venv -h |
激活
1 | python3 -m venv /opt/stable-diffusion/sd-venv |
(sd-venv) cs@debian:/opt/stable-diffusion/
1 | #查看当前pip源 |
停止
1 | #停止使用虚拟环境 |
list
1 | pip list | grep gradio |
gradio 3.23.0
show
1 | pip show gradio |
Name: gradio
Version: 3.23.0
Summary: Python library for easily interacting with trained machine learning models
Home-page: None
Author: None
Author-email: Abubakar Abid team@gradio.app, Ali Abid team@gradio.app, Ali Abdalla team@gradio.app, Dawood Khan team@gradio.app, Ahsen Khaliq team@gradio.app, Pete Allen team@gradio.app, Ömer Faruk Özdemir team@gradio.app
License: None
Location: /home/cs/oss/sd/venv/lib/python3.9/site-packages
Requires: websockets, fastapi, markupsafe, fsspec, pydantic, huggingface-hub, altair, orjson, python-multipart, aiohttp, ffmpy, markdown-it-py, pillow, semantic-version, uvicorn, pyyaml, typing-extensions, pandas, huggingface-hub, httpx, numpy, aiofiles, matplotlib, requests, pydub, mdit-py-plugins, jinja2
Required-by:
if torch.cuda.is_available():
device = torch.device('cuda')
else:
device = torch.device('cpu')
#等价
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
加载cuda异常
1 | >>> import torch |
nvidia-modprobe 版本过低或未安裝,与显卡驱动的版本不匹配,将nvidia-modprobe更新至与显卡驱动的版本一致即可。 apt-get install nvidia-modprobe
重装pytorch和CUDA也无济于事,后面查到是因为ubuntu在suspend出现的问题,重启服务器物理机就可以了。
1 | source /home/cs/data/sd-venv/bin/activate |
7z x yajiu.7z
python wheel 安装包的制作与安装
http://coolpython.net/informal_essay/20-09/python-wheel-make-and-install.html