Switch to Docker SDK with CUDA for llama-cpp
Browse filesFiles changed (4)
- DockerfileAdded+28
- README.md+7-6
- app.py+15-19
- requirements.txt-2
12345678910111213141516171819202122232425262728FROM nvidia/cuda:12.4.0-devel-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractiveENV CMAKE_ARGS="-DGGML_CUDA=on"ENV FORCE_CMAKE=1
RUN apt-get update && apt-get install -y \ python3 \ python3-pip \ git \ cmake \ build-essential \ && rm -rf /var/lib/apt/lists/*
WORKDIR /app
RUN pip3 install --no-cache-dir --upgrade pip
RUN pip3 install --no-cache-dir llama-cpp-python
COPY requirements.txt .RUN pip3 install --no-cache-dir -r requirements.txt
COPY app.py .
EXPOSE 7860
CMD ["python3", "app.py"]2 unmodified lines3456767891 unmodified line1112131514151617186 unmodified lines252627282930319 unmodified lines414243434445464710 unmodified lines58596060616263646 unmodified lines71727373742 unmodified linesemoji: 🤖colorFrom: bluecolorTo: purplesdk: gradiosdk_version: 5.29.0sdk: dockerapp_file: app.pypinned: falselicense: apache-2.01 unmodified line - qwen - uncensored - llama-cpp - zerogpu - ggufsuggested_hardware: a10g-small---
# Qwen3.5-9B Uncensored API Interface6 unmodified lines- Fully uncensored (0/465 refusals)- Multimodal capable (text, image, video)- Supports 201 languages- Q4_K_M quantization via llama.cpp
## API Usage
9 unmodified lines system_prompt="You are a helpful assistant", temperature=0.7, top_p=0.8, max_tokens=2048, max_tokens=1024, api_name="/api_generate")print(result)10 unmodified lines "You are a helpful assistant", 0.7, 0.8, 2048 1024 ] }'```6 unmodified lines| system_prompt | string | "" | System instruction || temperature | float | 0.7 | Sampling temperature (0.0-2.0) || top_p | float | 0.8 | Nucleus sampling (0.0-1.0) || max_tokens | int | 2048 | Maximum tokens to generate || max_tokens | int | 1024 | Maximum tokens to generate |122345678991011121112131415161718192021131415161718192021222312 unmodified lines363738403940413 unmodified lines45464750484953505152535 unmodified lines5960616562636440 unmodified lines105106107112108109110111165 unmodified lines277278279284280import osimport gradio as grimport spacesfrom huggingface_hub import hf_hub_downloadfrom llama_cpp import Llama
MODEL_REPO = "HauhauCS/Qwen3.5-9B-Uncensored-HauhauCS-Aggressive"MODEL_FILE = "Qwen3.5-9B-Uncensored-HauhauCS-Aggressive-Q4_K_M.gguf"
llm = Noneprint("Downloading model...")model_path = hf_hub_download(repo_id=MODEL_REPO, filename=MODEL_FILE)print(f"Model downloaded to: {model_path}")
def load_model(): global llm if llm is None: model_path = hf_hub_download(repo_id=MODEL_REPO, filename=MODEL_FILE) llm = Llama( model_path=model_path, n_ctx=8192, n_gpu_layers=-1, verbose=False, ) return llmprint("Loading model...")llm = Llama( model_path=model_path, n_ctx=8192, n_gpu_layers=-1, verbose=False,)print("Model loaded!")
def format_messages(message: str, history: list, system_prompt: str = "") -> str:12 unmodified lines return formatted
@spaces.GPUdef generate_response( message: str, history: list,3 unmodified lines top_k: int = 20, max_tokens: int = 2048,) -> str: model = load_model() prompt = format_messages(message, history, system_prompt) output = model( output = llm( prompt, max_tokens=max_tokens, temperature=temperature,5 unmodified lines return output["choices"][0]["text"].strip()
@spaces.GPUdef api_generate( prompt: str, system_prompt: str = "",40 unmodified lines - Fully uncensored (0/465 refusals) - Multimodal capable (text, image, video) - Supports 201 languages - Running on ZeroGPU with Q4_K_M quantization - Running with Q4_K_M quantization via llama.cpp Use the chat interface below or access via API. """165 unmodified lines api_name="api_generate", )
demo.launch()demo.launch(server_name="0.0.0.0", server_port=7860)1234gradio>=4.0.0huggingface_hub>=0.20.0spacesllama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu124DockerfileAdded+28
README.md+7-6
app.py+15-19
requirements.txt-2