|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -ex |
| 4 | + |
| 5 | +# create conda |
| 6 | +yes '' | "${SHELL}" <(curl -L micro.mamba.pm/install.sh) |
| 7 | +source ~/.bashrc |
| 8 | + |
| 9 | +micromamba self-update |
| 10 | + |
| 11 | +micromamba create -n slime python=3.12 pip -c conda-forge -y |
| 12 | +micromamba activate slime |
| 13 | +export CUDA_HOME="$CONDA_PREFIX" |
| 14 | + |
| 15 | +export BASE_DIR=${BASE_DIR:-"/root"} |
| 16 | +cd $BASE_DIR |
| 17 | +# install sglang |
| 18 | +git clone -b v0.5.0rc0 https://github.com/sgl-project/sglang.git |
| 19 | +cd sglang |
| 20 | +# Install the python packages |
| 21 | +pip install -e "python[all]" |
| 22 | + |
| 23 | +# install cuda 12.8 as it's the default cuda version for torch |
| 24 | +micromamba install -n slime cuda cuda-nvtx cuda-nvtx-dev -c nvidia/label/cuda-12.8.0 -y |
| 25 | +micromamba install -n slime -c conda-forge cudnn -y |
| 26 | +pip install cmake ninja |
| 27 | + |
| 28 | +# reinstall sglang deps |
| 29 | +pip install git+https://github.com/fzyzcjy/torch_memory_saver.git --no-cache-dir --force-reinstall --no-build-isolation |
| 30 | + |
| 31 | +# install megatron deps |
| 32 | +TORCH_CUDA_ARCH_LIST="9.0;9.0a" \ |
| 33 | + pip -v install --no-build-isolation \ |
| 34 | + git+https://github.com/fanshiqing/grouped_gemm@v1.1.4 |
| 35 | +# apex |
| 36 | +TORCH_CUDA_ARCH_LIST="9.0;9.0a" NVCC_APPEND_FLAGS="--threads 4" \ |
| 37 | +\ |
| 38 | + pip -v install --disable-pip-version-check --no-cache-dir \ |
| 39 | + --no-build-isolation \ |
| 40 | + --config-settings "--build-option=--cpp_ext --cuda_ext --parallel 8" git+https://github.com/NVIDIA/apex.git |
| 41 | +# transformer engine |
| 42 | +TORCH_CUDA_ARCH_LIST="9.0;9.0a" \ |
| 43 | + pip -v install transformer_engine[pytorch] |
| 44 | +# flash attn |
| 45 | +# the newest version megatron supports is v2.7.4.post1 |
| 46 | +MAX_JOBS=64 pip -v install flash-attn==2.7.4.post1 |
| 47 | +# megatron |
| 48 | +cd $BASE_DIR |
| 49 | +git clone https://github.com/NVIDIA/Megatron-LM.git |
| 50 | +cd Megatron-LM/ |
| 51 | +git checkout 48406695c4efcf1026a7ed70bb390793918dd97b |
| 52 | +pip install -e . |
| 53 | + |
| 54 | +# mbridge |
| 55 | +pip install git+https://github.com/ISEEKYAN/mbridge.git --no-deps |
| 56 | + |
| 57 | +# install slime and apply patches |
| 58 | + |
| 59 | +# if slime does not exist locally, clone it |
| 60 | +if [ ! -d "$BASE_DIR/slime" ]; then |
| 61 | + cd $BASE_DIR |
| 62 | + git clone https://github.com/THUDM/slime.git |
| 63 | + cd slime/ |
| 64 | +fi |
| 65 | + |
| 66 | +pip install -e . |
| 67 | +# apply patch |
| 68 | +cd $BASE_DIR/sglang |
| 69 | +git apply $BASE_DIR/slime/docker/patch/v0.5.0rc0-cuda126/sglang.patch |
| 70 | +cd $BASE_DIR/Megatron-LM |
| 71 | +git apply $BASE_DIR/slime/docker/patch/v0.5.0rc0-cuda126/megatron.patch |
0 commit comments