Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Text Generation WebUI/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ ENV GPU_CHOICE=$GPU_CHOICE
RUN apt update && apt install -y git &&\
git config --global --add safe.directory /home/node/app/text-generation-webui &&\
chmod +x ./text-generation-webui/start_linux.sh &&\
find ./text-generation-webui -maxdepth 1 -type f -name "requirements*" -exec sed -i 's/transformers==/transformers[torch,flax,timm,sentencepiece,onnx,ftfy,tokenizers]==/g' {} \; &&\
find ./text-generation-webui -maxdepth 1 -type f -name "requirements*" -exec sh -c 'echo "\nsacremoses\noptimum\nauto-gptq\nautoawq\nbitsandbytes" >> {}' \; &&\
find ./text-generation-webui/requirements -maxdepth 2 -type f -name "requirements*" -exec sed -i 's/transformers==/transformers[torch,flax,timm,sentencepiece,onnx,ftfy,tokenizers]==/g' {} \; &&\
find ./text-generation-webui/requirements -maxdepth 2 -type f -name "requirements*" -exec sh -c 'echo "\nsacremoses\noptimum\nauto-gptq\nautoawq\nbitsandbytes" >> {}' \; &&\
Comment on lines +26 to +27
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix newline insertion and optimize find -exec usage
The current echo "\n…" invocation won’t interpret \n as newlines in POSIX shells, so literal \n will be appended. Also, spawning a separate sed process per file can be slow.

Apply this diff to correctly insert newlines and batch the sed calls:

-    find ./text-generation-webui/requirements -maxdepth 2 -type f -name "requirements*" -exec sed -i 's/transformers==/transformers[torch,flax,timm,sentencepiece,onnx,ftfy,tokenizers]==/g' {} \; &&\
-    find ./text-generation-webui/requirements -maxdepth 2 -type f -name "requirements*" -exec sh -c 'echo "\nsacremoses\noptimum\nauto-gptq\nautoawq\nbitsandbytes" >> {}' \; &&\
+    # Batch-edit all matching files in one go, then append new lines correctly via printf
+    find ./text-generation-webui/requirements -maxdepth 2 -type f -name "requirements*" \
+      -exec sed -i 's/transformers==/transformers[torch,flax,timm,sentencepiece,onnx,ftfy,tokenizers]==/g' {} + &&\
+    find ./text-generation-webui/requirements -maxdepth 2 -type f -name "requirements*" \
+      -exec sh -c 'printf "\n%s\n" sacremoses optimum auto-gptq autoawq bitsandbytes >> "$1"' _ {} + &&\
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
find ./text-generation-webui/requirements -maxdepth 2 -type f -name "requirements*" -exec sed -i 's/transformers==/transformers[torch,flax,timm,sentencepiece,onnx,ftfy,tokenizers]==/g' {} \; &&\
find ./text-generation-webui/requirements -maxdepth 2 -type f -name "requirements*" -exec sh -c 'echo "\nsacremoses\noptimum\nauto-gptq\nautoawq\nbitsandbytes" >> {}' \; &&\
# Batch-edit all matching files in one go, then append new lines correctly via printf
find ./text-generation-webui/requirements -maxdepth 2 -type f -name "requirements*" \
-exec sed -i 's/transformers==/transformers[torch,flax,timm,sentencepiece,onnx,ftfy,tokenizers]==/g' {} + &&\
find ./text-generation-webui/requirements -maxdepth 2 -type f -name "requirements*" \
-exec sh -c 'printf "\n%s\n" sacremoses optimum auto-gptq autoawq bitsandbytes >> "$1"' _ {} + &&\
🤖 Prompt for AI Agents
In Text Generation WebUI/Dockerfile at lines 26-27, the echo command appends a
literal "\n" instead of a newline, and the sed command runs separately for each
file, which is inefficient. Fix this by replacing the echo command with printf
to correctly insert newlines, and optimize the sed command to process multiple
files in a single invocation or use xargs to batch the calls, reducing the
number of spawned processes.

USE_CUDA118=FALSE LAUNCH_AFTER_INSTALL=FALSE INSTALL_EXTENSIONS=FALSE ./text-generation-webui/start_linux.sh &&\
apt remove git -y &&\
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb &&\
Expand Down
Loading