-
Notifications
You must be signed in to change notification settings - Fork 327
[MUSA] Add shell script to generate requirements-musa.txt and update doc #1175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,4 @@ dist | |
| .idea | ||
| .vscode | ||
| tmp/ | ||
| requirements-musa.txt | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -24,16 +24,16 @@ The easiest way to install Lightllm is using the official image. You can directl | |||||
| $ docker pull ghcr.io/modeltc/lightllm:main | ||||||
| $ | ||||||
| $ # Run,The current LightLLM service relies heavily on shared memory. | ||||||
| $ # Before starting, please make sure that you have allocated enough shared memory | ||||||
| $ # Before starting, please make sure that you have allocated enough shared memory | ||||||
| $ # in your Docker settings; otherwise, the service may fail to start properly. | ||||||
| $ # | ||||||
| $ # 1. For text-only services, it is recommended to allocate more than 2GB of shared memory. | ||||||
| $ # 1. For text-only services, it is recommended to allocate more than 2GB of shared memory. | ||||||
| $ # If your system has sufficient RAM, allocating 16GB or more is recommended. | ||||||
| $ # 2.For multimodal services, it is recommended to allocate 16GB or more of shared memory. | ||||||
| $ # 2.For multimodal services, it is recommended to allocate 16GB or more of shared memory. | ||||||
| $ # You can adjust this value according to your specific requirements. | ||||||
| $ # | ||||||
| $ # If you do not have enough shared memory available, you can try lowering | ||||||
| $ # the --running_max_req_size parameter when starting the service. | ||||||
| $ # If you do not have enough shared memory available, you can try lowering | ||||||
| $ # the --running_max_req_size parameter when starting the service. | ||||||
| $ # This will reduce the number of concurrent requests, but also decrease shared memory usage. | ||||||
| $ docker run -it --gpus all -p 8080:8080 \ | ||||||
| $ --shm-size 2g -v your_local_path:/data/ \ | ||||||
|
|
@@ -42,21 +42,21 @@ The easiest way to install Lightllm is using the official image. You can directl | |||||
| You can also manually build the image from source and run it: | ||||||
|
|
||||||
| .. code-block:: console | ||||||
|
|
||||||
| $ # move into lightllm root dir | ||||||
| $ cd /lightllm | ||||||
| $ # Manually build the image | ||||||
| $ docker build -t <image_name> -f ./docker/Dockerfile . | ||||||
| $ | ||||||
| $ # Run, | ||||||
| $ # Run, | ||||||
| $ docker run -it --gpus all -p 8080:8080 \ | ||||||
| $ --shm-size 2g -v your_local_path:/data/ \ | ||||||
| $ <image_name> /bin/bash | ||||||
|
|
||||||
| Or you can directly use the script to launch the image and run it with one click: | ||||||
|
|
||||||
| .. code-block:: console | ||||||
|
|
||||||
| $ # View script parameters | ||||||
| $ python tools/quick_launch_docker.py --help | ||||||
|
|
||||||
|
|
@@ -84,6 +84,10 @@ You can also install Lightllm from source: | |||||
| $ # Install Lightllm dependencies (cuda 12.4) | ||||||
| $ pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu124 | ||||||
| $ | ||||||
| $ # Install Lightllm dependencies (Moore Threads GPU) | ||||||
| $ ./generate_requirements_musa.sh | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The command
Suggested change
|
||||||
| $ pip install -r requirements-musa.txt | ||||||
| $ | ||||||
| $ # Install Lightllm | ||||||
| $ python setup.py install | ||||||
|
|
||||||
|
|
@@ -101,5 +105,5 @@ You can also install Lightllm from source: | |||||
| .. code-block:: console | ||||||
|
|
||||||
| $ pip install -U --index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/Triton-Nightly/pypi/simple/ triton-nightly --no-deps | ||||||
|
|
||||||
| For specific reasons, please refer to: `issue <https://github.com/triton-lang/triton/issues/3619>`_ and `fix PR <https://github.com/triton-lang/triton/pull/3638>`_ | ||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,105 @@ | ||||||
| #!/bin/bash | ||||||
| # Script to generate requirements-musa.txt from requirements.txt | ||||||
| # MUSA is not compatible with CUDA packages, so they need to be removed | ||||||
| # Torch-related packages are pre-installed in the MUSA docker container | ||||||
|
|
||||||
| set -e | ||||||
|
|
||||||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||||||
| INPUT_FILE="${SCRIPT_DIR}/requirements.txt" | ||||||
| OUTPUT_FILE="${SCRIPT_DIR}/requirements-musa.txt" | ||||||
|
|
||||||
| if [ ! -f "$INPUT_FILE" ]; then | ||||||
| echo "Error: requirements.txt not found at $INPUT_FILE" | ||||||
| exit 1 | ||||||
| fi | ||||||
|
|
||||||
| echo "Generating requirements-musa.txt from requirements.txt..." | ||||||
|
|
||||||
| # Define patterns to remove (CUDA-specific packages) | ||||||
| # These packages are not compatible with MUSA | ||||||
| CUDA_PACKAGES=( | ||||||
| "^cupy" # cupy-cuda12x and similar | ||||||
| "^cuda_bindings" # CUDA bindings | ||||||
| "^nixl" # NIXL (NVIDIA Inter-node eXchange Library) | ||||||
| "^flashinfer" # flashinfer-python (CUDA-specific attention kernel) | ||||||
| "^sgl-kernel" # SGL kernel (CUDA-specific) | ||||||
| ) | ||||||
|
|
||||||
| # Define torch-related packages (pre-installed in MUSA container, remove version pins) | ||||||
| TORCH_PACKAGES=( | ||||||
| "^torch==" | ||||||
| "^torchvision==" | ||||||
| ) | ||||||
|
|
||||||
| # Create the output file with a header comment | ||||||
| cat > "$OUTPUT_FILE" << 'EOF' | ||||||
| # Requirements for MUSA (Moore Threads GPU) | ||||||
| # Auto-generated from requirements.txt by generate_requirements_musa.sh | ||||||
| # CUDA-specific packages have been removed | ||||||
| # Torch-related packages have version pins removed (pre-installed in MUSA container) | ||||||
|
|
||||||
| EOF | ||||||
|
|
||||||
| # Process the requirements file | ||||||
| while IFS= read -r line || [ -n "$line" ]; do | ||||||
| # Skip empty lines and comments (but keep them in output) | ||||||
| if [[ -z "$line" || "$line" =~ ^[[:space:]]*# ]]; then | ||||||
| echo "$line" >> "$OUTPUT_FILE" | ||||||
| continue | ||||||
| fi | ||||||
|
|
||||||
| # Extract package name (before ==, >=, <=, ~=, etc.) | ||||||
| pkg_name=$(echo "$line" | sed -E 's/^([a-zA-Z0-9_-]+).*/\1/') | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The regular expression used to extract the package name is not robust. It doesn't account for dots (
Suggested change
|
||||||
|
|
||||||
| # Check if this is a CUDA package to skip | ||||||
| skip=false | ||||||
| for pattern in "${CUDA_PACKAGES[@]}"; do | ||||||
| if [[ "$pkg_name" =~ $pattern ]]; then | ||||||
| echo " Removing CUDA package: $line" | ||||||
| skip=true | ||||||
| break | ||||||
| fi | ||||||
| done | ||||||
|
|
||||||
| if $skip; then | ||||||
| continue | ||||||
| fi | ||||||
|
|
||||||
| # Check if this is a torch-related package (remove version pin) | ||||||
| for pattern in "${TORCH_PACKAGES[@]}"; do | ||||||
| if [[ "$line" =~ $pattern ]]; then | ||||||
| # Remove version pin, keep just the package name | ||||||
| pkg_only=$(echo "$line" | sed -E 's/==.*//') | ||||||
| echo " Unpinning version for: $pkg_only (pre-installed in MUSA container)" | ||||||
| echo "$pkg_only" >> "$OUTPUT_FILE" | ||||||
| skip=true | ||||||
| break | ||||||
| fi | ||||||
| done | ||||||
|
|
||||||
| if $skip; then | ||||||
| continue | ||||||
| fi | ||||||
|
|
||||||
| # Keep the package as-is | ||||||
| echo "$line" >> "$OUTPUT_FILE" | ||||||
|
|
||||||
| done < "$INPUT_FILE" | ||||||
|
Comment on lines
+45
to
+88
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Throughout this loop, For example:
|
||||||
|
|
||||||
| # Add MUSA-specific packages at the end | ||||||
| cat >> "$OUTPUT_FILE" << 'EOF' | ||||||
|
|
||||||
| # MUSA-specific packages | ||||||
| torch_musa | ||||||
| torchada | ||||||
| EOF | ||||||
|
|
||||||
| echo "" | ||||||
| echo "Successfully generated: $OUTPUT_FILE" | ||||||
| echo "" | ||||||
| echo "Summary of changes:" | ||||||
| echo " - Removed CUDA-specific packages: cupy-cuda12x, cuda_bindings, nixl, flashinfer-python, sgl-kernel" | ||||||
| echo " - Unpinned torch-related packages: torch, torchvision (pre-installed in MUSA container)" | ||||||
| echo " - Added MUSA-specific packages: torch_musa, torchada" | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command
./generate_requirements_musa.shrequires the script to have execute permissions. A user cloning the repository might not have this permission set by default, forcing them to runchmod +xfirst. To provide a smoother experience, you can invoke the script withbashdirectly, which doesn't require the execute bit.