Skip to content

Commit

Permalink
support pip install InternEvo (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
sallyjunjun authored Jan 25, 2024
1 parent 14e938c commit d71a6b3
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 7 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/upload_to_pypi.yaml
Original file line number Diff line number Diff line change
@@ -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/*
10 changes: 9 additions & 1 deletion doc/en/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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).
18 changes: 12 additions & 6 deletions doc/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down Expand Up @@ -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
```
Expand Down
1 change: 1 addition & 0 deletions requirements/runtime.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ botocore
torch-scatter
pyecharts
py-libnuma
tensorboard
-f https://data.pyg.org/whl/torch-1.13.1+cu117.html
37 changes: 37 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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',
],
)

0 comments on commit d71a6b3

Please sign in to comment.