python虛擬環(huán)境管理
創(chuàng)建虛擬環(huán)境
python -m venv <新環(huán)境名>
該命令會在當(dāng)前文件夾下創(chuàng)建一個新環(huán)境名的目錄,保存新環(huán)境需要的依賴庫蚤吹。
激活虛擬環(huán)境
Linux環(huán)境:
source <新環(huán)境名>/bin/activate
windows環(huán)境:
.\<新環(huán)境名>\Scripts\activate.bat
conda虛擬環(huán)境管理
查看有哪些虛擬環(huán)境
conda env list
創(chuàng)建虛擬環(huán)境
conda create -n <new_env> python=3.6
<new_env>為自己命名的虛擬環(huán)境名稱,該文件可在Anaconda安裝目錄 envs文件下找到造成。
克隆虛擬環(huán)境
conda create -n <new_env> --clone <from_env>
使用激活(或切換不同python版本)的虛擬環(huán)境:
python --version # 可以檢查當(dāng)前python的版本
Linux: conda activate <虛擬環(huán)境名>
Windows: activate <虛擬環(huán)境名>
對虛擬環(huán)境中安裝額外的包
conda install -n your_env_name [package]
或者在虛擬環(huán)境之下:
conda install [package]
關(guān)閉虛擬環(huán)境
Linux: source deactivate
Windows: deactivate
刪除虛擬環(huán)境
conda remove -n your_env_name(虛擬環(huán)境名稱) --all
conda remove --name your_env_name package_name # 刪除環(huán)境中的某個包
安裝cuda 和 cudnn(廢棄)
conda install cudatoolkit=11.8 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/
conda install cudnn=6.0 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/
安裝torch
pip install torch==2.0.1 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
表示安裝Torch2.1版本并且支持CUDA11.8累奈。
或者使用官網(wǎng)生成需要安裝版本的命令行:官網(wǎng)生成安裝鏈接
注意:CDUA的本地驅(qū)動要另外安裝。
安裝顯卡驅(qū)動
GeForce? 驅(qū)動程序 531.61 是 12.1版本的驅(qū)動麦锯。
- nvidia-smi命令驗證驅(qū)動以及版本是否正確。
安裝CUDA ToolKit
CUDA Toolkit 選擇和驅(qū)動相同的版本下載琅绅。
- nvcc -V 驗證編譯器是否正常工作扶欣。
modelscope中安裝Sambert-Hifigan語音合成模型
python 3.7-3.9
安裝 kantts
pip install kantts -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
pip install ffmpy ffmpeg ffmpeg-python imageio-ffmpeg bitstring
conda install ffmpeg
jupyter 允許遠程訪問
1、生成配置文件
jupyter notebook --generate-config
或
jupyter lab --generate-config
2千扶、修改配置文件: 將 c.ServerApp.ip 的值改為主機的IP
3料祠、啟動jupyter lab
jupyter lab --allow-root
jupyter指定不同端口
jupyter --port=<PORT_NUMBER>
jupyter安裝插件擴展
pip install jupyter-lsp python-lsp-server
apt install nodejs npm
啟動text-generation-webui
python server.py --listen --api --api-blocking-port 8800
git中合并主倉庫的內(nèi)容
git remote add upstream https://github.com/langgenius/dify.git
git fetch upstream
git checkout main
git rebase upstream/main
git push origin main
PDF文檔轉(zhuǎn)TXT文件
from langchain.document_loaders import PyPDFium2Loader
filename = "file.pdf"
documents = PyPDFium2Loader(file_path=filename).load()
text_list = []
for document in documents:
text_list.append(document.page_content)
text = "\n\n".join(text_list)
with open(filename+".txt", 'w', encoding='utf-8') as file:
file.write(text)