LLM笔记

作者: cnwinds | 来源:发表于2023-09-27 11:34 被阅读0次

python虚拟环境管理

创建虚拟环境

python -m venv <新环境名>

该命令会在当前文件夹下创建一个新环境名的目录,保存新环境需要的依赖库。

激活虚拟环境

Linux环境:

source <新环境名>/bin/activate

windows环境:

.\<新环境名>\Scripts\activate.bat

conda虚拟环境管理

查看有哪些虚拟环境

conda env list

创建虚拟环境

conda create -n <new_env> python=3.6

<new_env>为自己命名的虚拟环境名称,该文件可在Anaconda安装目录 envs文件下找到。

克隆虚拟环境

conda create -n <new_env> --clone <from_env>

使用激活(或切换不同python版本)的虚拟环境:

python --version  # 可以检查当前python的版本
Linux:  conda activate <虚拟环境名>
Windows: activate <虚拟环境名>

对虚拟环境中安装额外的包

conda install -n your_env_name [package]

或者在虚拟环境之下:

conda install [package]

关闭虚拟环境

Linux: source deactivate
Windows: deactivate

删除虚拟环境

conda remove -n your_env_name(虚拟环境名称) --all
conda remove --name your_env_name  package_name  # 删除环境中的某个包

安装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。
或者使用官网生成需要安装版本的命令行:官网生成安装链接
注意:CDUA的本地驱动要另外安装。

安装显卡驱动

GeForce® 驱动程序 531.61 是 12.1版本的驱动。

  • nvidia-smi命令验证驱动以及版本是否正确。

安装CUDA ToolKit

CUDA Toolkit 选择和驱动相同的版本下载。

  • 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中合并主仓库的内容

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文档转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)

相关文章

网友评论

      本文标题:LLM笔记

      本文链接:https://www.haomeiwen.com/subject/ulrhbdtx.html