From f71c4c2ee11071a2d399313287caccdd892d8259 Mon Sep 17 00:00:00 2001 From: "push-app-to-main[bot]" <203845782+push-app-to-main[bot]@users.noreply.github.com> Date: Fri, 13 Nov 2026 12:40:55 +0100 Subject: [PATCH] Add unsloth (ct) (#18697) Co-authored-by: push-app-to-main[bot] <203845782+push-app-to-main[bot]@users.noreply.github.com> --- ct/unsloth.sh | 68 ++++++++++++++++++++++++++++ install/unsloth-install.sh | 90 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 ct/unsloth.sh create mode 100644 install/unsloth-install.sh diff --git a/ct/unsloth.sh b/ct/unsloth.sh new file mode 100644 index 000000000..0649de3d0 --- /dev/null +++ b/ct/unsloth.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +_cs_boot="${COMMUNITY_SCRIPTS_CORE_DIR:-$(dirname "${BASH_SOURCE[0]}")/../../core}/core/build.func" +source "$_cs_boot" 2>/dev/null || source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/core/build.func") +# Copyright (c) 2021-2026 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/unslothai/unsloth + +APP="Unsloth" +var_tags="${var_tags:-ai;llm}" +var_cpu="${var_cpu:-4}" +var_ram="${var_ram:-8192}" +var_disk="${var_disk:-40}" +var_os="${var_os:-debian}" +var_version="${var_version:-13}" +var_gpu="${var_gpu:-yes}" +var_arm64="${var_arm64:-no}" +var_unprivileged="${var_unprivileged:-1}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -d /opt/unsloth ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + msg_info "Stopping Service" + systemctl stop unsloth + msg_ok "Stopped Service" + + if [[ -d /dev/dri || -e /dev/nvidia0 || -e /dev/kfd ]]; then + ENABLE_GPU="yes" setup_hwaccel + fi + + msg_info "Updating ${APP} (Patience)" + curl -fsSL https://unsloth.ai/install.sh -o /tmp/unsloth-install.sh + export UNSLOTH_STUDIO_HOME=/opt/unsloth + export UNSLOTH_SKIP_AUTOSTART=1 + export UNSLOTH_PYTHON=3.12 + $STD sh /tmp/unsloth-install.sh + unset UNSLOTH_SKIP_AUTOSTART UNSLOTH_PYTHON + rm -f /tmp/unsloth-install.sh + msg_ok "Updated ${APP}" + + msg_info "Starting Service" + systemctl start unsloth + msg_ok "Started Service" + msg_ok "Updated successfully!" + exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW}Access it using the following URL:${CL}" +echo -e "${GATEWAY}${BGN}http://${IP}:8888${CL}" +echo -e "${INFO}${YW}Login credentials: ~/unsloth.creds (inside the container)${CL}" diff --git a/install/unsloth-install.sh b/install/unsloth-install.sh new file mode 100644 index 000000000..005b0fb2d --- /dev/null +++ b/install/unsloth-install.sh @@ -0,0 +1,90 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2026 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/unslothai/unsloth + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt install -y \ + build-essential \ + libgomp1 \ + git +msg_ok "Installed Dependencies" + +UV_PYTHON="3.12" setup_uv +NODE_VERSION="22" setup_nodejs + +setup_hwaccel + +msg_info "Setting up Unsloth Studio (Patience)" +mkdir -p /opt/unsloth_data +curl -fsSL https://unsloth.ai/install.sh -o /tmp/unsloth-install.sh +export UNSLOTH_STUDIO_HOME=/opt/unsloth +export UNSLOTH_SKIP_AUTOSTART=1 +export UNSLOTH_PYTHON=3.12 +$STD sh /tmp/unsloth-install.sh +unset UNSLOTH_SKIP_AUTOSTART UNSLOTH_PYTHON +rm -f /tmp/unsloth-install.sh +[[ -x /opt/unsloth/unsloth_studio/bin/unsloth ]] || { + msg_error "Unsloth Studio was not installed to /opt/unsloth/unsloth_studio" + exit 1 +} +msg_ok "Set up Unsloth Studio" + +msg_info "Configuring Unsloth Studio" +cat </opt/unsloth.env +UNSLOTH_STUDIO_HOME=/opt/unsloth +HF_HOME=/opt/unsloth_data/huggingface +EOF +chmod 600 /opt/unsloth.env + +UNSLOTH_PASSWORD=$(UNSLOTH_STUDIO_HOME=/opt/unsloth \ + /opt/unsloth/unsloth_studio/bin/unsloth studio reset-password | + sed -n "s/^New password for 'unsloth': //p") +[[ -n "$UNSLOTH_PASSWORD" ]] || { + msg_error "Could not set the initial Unsloth admin password" + exit 1 +} + +cat <~/unsloth.creds +Unsloth Studio +Username: unsloth +Password: ${UNSLOTH_PASSWORD} +EOF +chmod 600 ~/unsloth.creds +msg_ok "Configured Unsloth Studio" + +msg_info "Creating Service" +cat </etc/systemd/system/unsloth.service +[Unit] +Description=Unsloth Studio +Wants=network-online.target +After=network-online.target + +[Service] +Type=simple +User=root +WorkingDirectory=/opt/unsloth_data +EnvironmentFile=/opt/unsloth.env +ExecStart=/opt/unsloth/unsloth_studio/bin/unsloth studio -H 0.0.0.0 -p 8888 +Restart=on-failure +RestartSec=10 + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now unsloth +msg_ok "Created Service" + +motd_ssh +customize +cleanup_lxc