diff --git a/.github/workflows/upload_to_pypi.yaml b/.github/workflows/upload_to_pypi.yaml new file mode 100644 index 00000000..ac8d0bed --- /dev/null +++ b/.github/workflows/upload_to_pypi.yaml @@ -0,0 +1,39 @@ +name: upload-to-pypi + +on: + create: + tags: + - "*" + +env: + WORKSPACE_PREFIX: $(echo $GITHUB_WORKSPACE |cut -d '/' -f 1-4) + SLURM_PARTITION: llm_s + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + +jobs: + build-and-upload: + runs-on: [t_cluster] + steps: + - name: mask env + run: | + echo "::add-mask::${{env.WORKSPACE_PREFIX}}" + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: install dependencies + run: | + pip install setuptools wheel twine + + - name: get latest tag + run: | + latest_tag=$(git describe --tags --abbrev=0) + echo "$latest_tag" > version.txt + + - name: build and upload package + run: | + export PYTHONPATH=$PWD:$PYTHONPATH + source /mnt/petrelfs/share_data/llm_env/env/llm-flash2.0 + srun -p ${SLURM_PARTITION} --kill-on-bad-exit=1 --job-name=internlm-ut-${GITHUB_RUN_ID}-${GITHUB_JOB} -N 1 -n 1 --gres=gpu:1 python setup.py sdist bdist_wheel + twine upload -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} dist/* diff --git a/doc/en/install.md b/doc/en/install.md index f34484de..ea862392 100644 --- a/doc/en/install.md +++ b/doc/en/install.md @@ -25,6 +25,14 @@ export CXX=${GCC_HOME}/bin/c++ ``` ### Environment Installation +Install through pip command: +```bash +pip install InternEvo==xxx (xxx is the version you want to install) +``` +This installs only InternEvo project, do not involve the required packages or submodules. + +Or install through source code: + Clone the project `InternEvo` and its dependent submodules from the github repository, as follows: ```bash git clone git@github.com:InternLM/InternEvo.git --recurse-submodules @@ -83,4 +91,4 @@ For the local standard image built with dockerfile or pulled, use the following ```bash docker run --gpus all -it -m 500g --cap-add=SYS_PTRACE --cap-add=IPC_LOCK --shm-size 20g --network=host --name myinternlm internlm/internlm:torch1.13.1-cuda11.7.1-flashatten1.0.5-centos7 bash ``` -The default directory in the container is `/InternEvo`, please start training according to the [Usage](./usage.md). +The default directory in the container is `/InternLM`, please start training according to the [Usage](./usage.md). diff --git a/doc/install.md b/doc/install.md index 63d392b7..ae3b13bf 100644 --- a/doc/install.md +++ b/doc/install.md @@ -25,16 +25,22 @@ export CXX=${GCC_HOME}/bin/c++ ``` ### 环境安装 -将项目`internlm`及其依赖子模块,从 github 仓库中 clone 下来,命令如下: +可以通过pip命令直接安装,命令如下: ```bash -git clone git@github.com:InternLM/InternLM.git --recurse-submodules +pip install InternEvo==xxx (xxx是需要安装的版本号信息) +``` +这种方式仅安装了InternEvo项目,其依赖的软件包及子模块尚未安装。 + +也可以通过源码安装,将项目`InternEvo`及其依赖子模块,从 github 仓库中 clone 下来,命令如下: +```bash +git clone git@github.com:InternLM/InternEvo.git --recurse-submodules ``` 推荐使用 conda 构建一个 Python-3.10 的虚拟环境, 并基于`requirements/`文件安装项目所需的依赖包: ```bash -conda create --name internlm-env python=3.10 -y -conda activate internlm-env -cd internlm +conda create --name internevo-env python=3.10 -y +conda activate internevo-env +cd InternEvo pip install -r requirements/torch.txt pip install -r requirements/runtime.txt ``` @@ -62,7 +68,7 @@ cd ../../ 用户可以使用提供的 dockerfile 结合 docker.Makefile 来构建自己的镜像,或者也可以从 https://hub.docker.com/r/internlm/internlm 获取安装了 InternLM 运行环境的镜像。 #### 镜像配置及构造 -dockerfile 的配置以及构造均通过 docker.Makefile 文件实现,在 InternLM 根目录下执行如下命令即可 build 镜像: +dockerfile 的配置以及构造均通过 docker.Makefile 文件实现,在 InternEvo 根目录下执行如下命令即可 build 镜像: ``` bash make -f docker.Makefile BASE_OS=centos7 ``` diff --git a/requirements/runtime.txt b/requirements/runtime.txt index 814f69bb..cfe30e83 100644 --- a/requirements/runtime.txt +++ b/requirements/runtime.txt @@ -14,4 +14,5 @@ botocore torch-scatter pyecharts py-libnuma +tensorboard -f https://data.pyg.org/whl/torch-1.13.1+cu117.html diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..c46d89fb --- /dev/null +++ b/setup.py @@ -0,0 +1,37 @@ +import os +import re +import sys +import subprocess +from setuptools import setup, find_packages +from setuptools.command.install import install + +pwd = os.path.dirname(__file__) + +def readme(): + with open(os.path.join(pwd, 'README.md'), encoding='utf-8') as f: + content = f.read() + return content + +def get_version(): + with open(os.path.join(pwd, 'version.txt'), 'r') as f: + content = f.read() + return content + +setup( + name='InternEvo', + version=get_version(), + description='an open-sourced lightweight training framework aims to support model pre-training without the need for extensive dependencies', + long_description=readme(), + long_description_content_type='text/markdown', + packages=find_packages(), + + classifiers=[ + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Intended Audience :: Developers', + 'Intended Audience :: Education', + 'Intended Audience :: Science/Research', + ], +)