mirror of
https://github.com/datawhalechina/self-llm.git
synced 2026-09-19 01:36:47 +08:00
Remove unused files and update dependencies
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
### pip、conda 换源
|
||||
|
||||
更多详细内容可移步至[MirrorZ Help](https://help.mirrors.cernet.edu.cn/)查看。
|
||||
|
||||
#### pip 换源
|
||||
|
||||
临时使用镜像源安装,如下所示:`some-package` 为你需要安装的包名
|
||||
|
||||
```shell
|
||||
pip install -i https://mirrors.cernet.edu.cn/pypi/web/simple some-package
|
||||
```
|
||||
|
||||
设置pip默认镜像源,升级 pip 到最新的版本 (>=10.0.0) 后进行配置,如下所示:
|
||||
|
||||
```shell
|
||||
python -m pip install --upgrade pip
|
||||
pip config set global.index-url https://mirrors.cernet.edu.cn/pypi/web/simple
|
||||
```
|
||||
|
||||
如果您的 pip 默认源的网络连接较差,临时使用镜像源升级 pip:
|
||||
|
||||
```shell
|
||||
python -m pip install -i https://mirrors.cernet.edu.cn/pypi/web/simple --upgrade pip
|
||||
```
|
||||
|
||||
#### conda 换源
|
||||
|
||||
镜像站提供了 Anaconda 仓库与第三方源(conda-forge、msys2、pytorch 等,各系统都可以通过修改用户目录下的 .condarc 文件来使用镜像站。
|
||||
|
||||
不同系统下的.condarc目录如下:
|
||||
|
||||
- Linux: ${HOME}/.condarc
|
||||
- macOS: ${HOME}/.condarc
|
||||
- Windows: C:\Users\<YourUserName>\.condarc
|
||||
|
||||
注意:
|
||||
|
||||
- Windows 用户无法直接创建名为 .condarc 的文件,可先执行 conda config --set show_channel_urls yes 生成该文件之后再修改。
|
||||
|
||||
快速配置
|
||||
|
||||
```shell
|
||||
cat <<'EOF' > ~/.condarc
|
||||
channels:
|
||||
- defaults
|
||||
show_channel_urls: true
|
||||
default_channels:
|
||||
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
|
||||
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
|
||||
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
|
||||
custom_channels:
|
||||
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
|
||||
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
|
||||
EOF
|
||||
```
|
||||
@@ -0,0 +1,5 @@
|
||||
### AutoDL 开放端口
|
||||
|
||||
将 `autodl `的端口映射到本地的 [http://localhost:6006](http://localhost:6006/) 仅在此处展示一次,以下两个 Demo 都是同样的方法把 `autodl `中的 `6006 `端口映射到本机的 `http://localhost:6006`的方法都是相同的,方法如图所示。
|
||||
|
||||

|
||||
@@ -0,0 +1,78 @@
|
||||
### 模型下载
|
||||
|
||||
#### hugging face
|
||||
|
||||
使用`huggingface`官方提供的`huggingface-cli`命令行工具。安装依赖:
|
||||
|
||||
```shell
|
||||
pip install -U huggingface_hub
|
||||
```
|
||||
|
||||
然后新建python文件,填入以下代码,运行即可。
|
||||
|
||||
- resume-download:断点续下
|
||||
- local-dir:本地存储路径。(linux环境下需要填写绝对路径)
|
||||
|
||||
```python
|
||||
import os
|
||||
|
||||
# 下载模型
|
||||
os.system('huggingface-cli download --resume-download internlm/internlm-chat-7b --local-dir your_path')
|
||||
```
|
||||
|
||||
#### hugging face 镜像下载
|
||||
|
||||
与使用hugginge face下载相同,只需要填入镜像地址即可。使用`huggingface`官方提供的`huggingface-cli`命令行工具。安装依赖:
|
||||
|
||||
```shell
|
||||
pip install -U huggingface_hub
|
||||
```
|
||||
|
||||
然后新建python文件,填入以下代码,运行即可。
|
||||
|
||||
- resume-download:断点续下
|
||||
- local-dir:本地存储路径。(linux环境下需要填写绝对路径)
|
||||
|
||||
```python
|
||||
import os
|
||||
|
||||
# 设置环境变量
|
||||
os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
|
||||
|
||||
# 下载模型
|
||||
os.system('huggingface-cli download --resume-download internlm/internlm-chat-7b --local-dir your_path')
|
||||
```
|
||||
|
||||
更多关于镜像使用可以移步至 [HF Mirror](https://hf-mirror.com/) 查看。
|
||||
|
||||
#### modelscope
|
||||
|
||||
使用`modelscope`中的`snapshot_download`函数下载模型,第一个参数为模型名称,参数`cache_dir`为模型的下载路径。
|
||||
|
||||
注意:`cache_dir`最好为决定路径。
|
||||
|
||||
安装依赖:
|
||||
|
||||
```shell
|
||||
pip install modelscope
|
||||
pip install transformers
|
||||
```
|
||||
|
||||
在当前目录下新建python文件,填入以下代码,运行即可。
|
||||
|
||||
```python
|
||||
import torch
|
||||
from modelscope import snapshot_download, AutoModel, AutoTokenizer
|
||||
import os
|
||||
model_dir = snapshot_download('Shanghai_AI_Laboratory/internlm-chat-7b', cache_dir='your path', revision='master')
|
||||
```
|
||||
|
||||
|
||||
#### git-lfs
|
||||
|
||||
来到[git-lfs](https://git-lfs.com/)网站下载安装包,然后安装`git-lfs`。安装好之后在终端输入`git lfs install`,然后就可以使用`git-lfs`下载模型了。当然这种方法需要你有一点点 **Magic** 。
|
||||
|
||||
|
||||
```shell
|
||||
git clone https://huggingface.co/internlm/internlm-7b
|
||||
```
|
||||
@@ -91,155 +91,15 @@
|
||||
- [x] [pip、conda 换源](#pip、conda-换源) @不要葱姜蒜
|
||||
- [x] AutoDL 开放端口 @不要葱姜蒜
|
||||
|
||||
- 模型下载
|
||||
- [模型下载](./General-Setting) @不要葱姜蒜
|
||||
- [x] hugging face @不要葱姜蒜
|
||||
- [x] hugging face 镜像下载 @不要葱姜蒜
|
||||
- [x] modelscope @不要葱姜蒜
|
||||
- [x] git-lfs @不要葱姜蒜
|
||||
- [ ] Openxlab
|
||||
|
||||
## 通用环境配置
|
||||
|
||||
### pip、conda 换源
|
||||
|
||||
更多详细内容可移步至[MirrorZ Help](https://help.mirrors.cernet.edu.cn/)查看。
|
||||
|
||||
#### pip 换源
|
||||
|
||||
临时使用镜像源安装,如下所示:`some-package` 为你需要安装的包名
|
||||
|
||||
```shell
|
||||
pip install -i https://mirrors.cernet.edu.cn/pypi/web/simple some-package
|
||||
```
|
||||
|
||||
设置pip默认镜像源,升级 pip 到最新的版本 (>=10.0.0) 后进行配置,如下所示:
|
||||
|
||||
```shell
|
||||
python -m pip install --upgrade pip
|
||||
pip config set global.index-url https://mirrors.cernet.edu.cn/pypi/web/simple
|
||||
```
|
||||
|
||||
如果您的 pip 默认源的网络连接较差,临时使用镜像源升级 pip:
|
||||
|
||||
```shell
|
||||
python -m pip install -i https://mirrors.cernet.edu.cn/pypi/web/simple --upgrade pip
|
||||
```
|
||||
|
||||
#### conda 换源
|
||||
|
||||
镜像站提供了 Anaconda 仓库与第三方源(conda-forge、msys2、pytorch 等,各系统都可以通过修改用户目录下的 .condarc 文件来使用镜像站。
|
||||
|
||||
不同系统下的.condarc目录如下:
|
||||
|
||||
- Linux: ${HOME}/.condarc
|
||||
- macOS: ${HOME}/.condarc
|
||||
- Windows: C:\Users\<YourUserName>\.condarc
|
||||
|
||||
注意:
|
||||
|
||||
- Windows 用户无法直接创建名为 .condarc 的文件,可先执行 conda config --set show_channel_urls yes 生成该文件之后再修改。
|
||||
|
||||
快速配置
|
||||
|
||||
```shell
|
||||
cat <<'EOF' > ~/.condarc
|
||||
channels:
|
||||
- defaults
|
||||
show_channel_urls: true
|
||||
default_channels:
|
||||
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
|
||||
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
|
||||
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
|
||||
custom_channels:
|
||||
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
|
||||
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
|
||||
EOF
|
||||
```
|
||||
|
||||
### AutoDL 开放端口
|
||||
|
||||
将 `autodl `的端口映射到本地的 [http://localhost:6006](http://localhost:6006/) 仅在此处展示一次,以下两个 Demo 都是同样的方法把 `autodl `中的 `6006 `端口映射到本机的 `http://localhost:6006`的方法都是相同的,方法如图所示。
|
||||
|
||||

|
||||
|
||||
### 模型下载
|
||||
|
||||
#### hugging face
|
||||
|
||||
使用`huggingface`官方提供的`huggingface-cli`命令行工具。安装依赖:
|
||||
|
||||
```shell
|
||||
pip install -U huggingface_hub
|
||||
```
|
||||
|
||||
然后新建python文件,填入以下代码,运行即可。
|
||||
|
||||
- resume-download:断点续下
|
||||
- local-dir:本地存储路径。(linux环境下需要填写绝对路径)
|
||||
|
||||
```python
|
||||
import os
|
||||
|
||||
# 下载模型
|
||||
os.system('huggingface-cli download --resume-download internlm/internlm-chat-7b --local-dir your_path')
|
||||
```
|
||||
|
||||
#### hugging face 镜像下载
|
||||
|
||||
与使用hugginge face下载相同,只需要填入镜像地址即可。使用`huggingface`官方提供的`huggingface-cli`命令行工具。安装依赖:
|
||||
|
||||
```shell
|
||||
pip install -U huggingface_hub
|
||||
```
|
||||
|
||||
然后新建python文件,填入以下代码,运行即可。
|
||||
|
||||
- resume-download:断点续下
|
||||
- local-dir:本地存储路径。(linux环境下需要填写绝对路径)
|
||||
|
||||
```python
|
||||
import os
|
||||
|
||||
# 设置环境变量
|
||||
os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
|
||||
|
||||
# 下载模型
|
||||
os.system('huggingface-cli download --resume-download internlm/internlm-chat-7b --local-dir your_path')
|
||||
```
|
||||
|
||||
更多关于镜像使用可以移步至 [HF Mirror](https://hf-mirror.com/) 查看。
|
||||
|
||||
#### modelscope
|
||||
|
||||
使用`modelscope`中的`snapshot_download`函数下载模型,第一个参数为模型名称,参数`cache_dir`为模型的下载路径。
|
||||
|
||||
注意:`cache_dir`最好为决定路径。
|
||||
|
||||
安装依赖:
|
||||
|
||||
```shell
|
||||
pip install modelscope
|
||||
pip install transformers
|
||||
```
|
||||
|
||||
在当前目录下新建python文件,填入以下代码,运行即可。
|
||||
|
||||
```python
|
||||
import torch
|
||||
from modelscope import snapshot_download, AutoModel, AutoTokenizer
|
||||
import os
|
||||
model_dir = snapshot_download('Shanghai_AI_Laboratory/internlm-chat-7b', cache_dir='your path', revision='master')
|
||||
```
|
||||
|
||||
|
||||
#### git-lfs
|
||||
|
||||
来到[git-lfs](https://git-lfs.com/)网站下载安装包,然后安装`git-lfs`。安装好之后在终端输入`git lfs install`,然后就可以使用`git-lfs`下载模型了。当然这种方法需要你有一点点 **Magic** 。
|
||||
|
||||
|
||||
```shell
|
||||
git clone https://huggingface.co/internlm/internlm-7b
|
||||
```
|
||||
- Issue && PR
|
||||
- [ ] Issue 提交 @鸿儒
|
||||
- [ ] PR 提交 @鸿儒
|
||||
|
||||
## 致谢
|
||||
|
||||
|
||||
Reference in New Issue
Block a user