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 lines3456789101 unmodified line121314151617186 unmodified lines2526272829309 unmodified lines4041424344454610 unmodified lines575859606162636 unmodified lines707172732 unmodified linesemoji: 🤖colorFrom: bluecolorTo: purplesdk: gradiosdk_version: 5.29.0app_file: app.pypinned: falselicense: apache-2.01 unmodified line- qwen- uncensored- llama-cpp- zerogpu---# Qwen3.5-9B Uncensored API Interface6 unmodified lines- Fully uncensored (0/465 refusals)- Multimodal capable (text, image, video)- Supports 201 languages## API Usage9 unmodified linessystem_prompt="You are a helpful assistant",temperature=0.7,top_p=0.8,max_tokens=2048,api_name="/api_generate")print(result)10 unmodified lines"You are a helpful assistant",0.7,0.8,2048]}'```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 |2 unmodified lines34567891 unmodified line11121314151617186 unmodified lines252627282930319 unmodified lines4142434445464710 unmodified lines585960616263646 unmodified lines717273742 unmodified linesemoji: 🤖colorFrom: bluecolorTo: purplesdk: dockerapp_file: app.pypinned: falselicense: apache-2.01 unmodified line- qwen- uncensored- llama-cpp- 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 Usage9 unmodified linessystem_prompt="You are a helpful assistant",temperature=0.7,top_p=0.8,max_tokens=1024,api_name="/api_generate")print(result)10 unmodified lines"You are a helpful assistant",0.7,0.8,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 | 1024 | Maximum tokens to generate |
12345678910111213141516171819202122232412 unmodified lines373839404142433 unmodified lines474849505152535455565 unmodified lines6263646566676840 unmodified lines109110111112113114115165 unmodified lines281282283284import gradio as grimport spacesfrom huggingface_hub import hf_hub_downloadfrom llama_cpp import LlamaMODEL_REPO = "HauhauCS/Qwen3.5-9B-Uncensored-HauhauCS-Aggressive"MODEL_FILE = "Qwen3.5-9B-Uncensored-HauhauCS-Aggressive-Q4_K_M.gguf"llm = Nonedef load_model():global llmif 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 llmdef format_messages(message: str, history: list, system_prompt: str = "") -> str:12 unmodified linesreturn formatted@spaces.GPUdef generate_response(message: str,history: list,3 unmodified linestop_k: int = 20,max_tokens: int = 2048,) -> str:model = load_model()prompt = format_messages(message, history, system_prompt)output = model(prompt,max_tokens=max_tokens,temperature=temperature,5 unmodified linesreturn 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 quantizationUse the chat interface below or access via API."""165 unmodified linesapi_name="api_generate",)demo.launch()123456789101112131415161718192021222312 unmodified lines3637383940413 unmodified lines4546474849505152535 unmodified lines59606162636440 unmodified lines105106107108109110111165 unmodified lines277278279280import osimport gradio as grfrom huggingface_hub import hf_hub_downloadfrom llama_cpp import LlamaMODEL_REPO = "HauhauCS/Qwen3.5-9B-Uncensored-HauhauCS-Aggressive"MODEL_FILE = "Qwen3.5-9B-Uncensored-HauhauCS-Aggressive-Q4_K_M.gguf"print("Downloading model...")model_path = hf_hub_download(repo_id=MODEL_REPO, filename=MODEL_FILE)print(f"Model downloaded to: {model_path}")print("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 linesreturn formatteddef generate_response(message: str,history: list,3 unmodified linestop_k: int = 20,max_tokens: int = 2048,) -> str:prompt = format_messages(message, history, system_prompt)output = llm(prompt,max_tokens=max_tokens,temperature=temperature,5 unmodified linesreturn output["choices"][0]["text"].strip()def api_generate(prompt: str,system_prompt: str = "",40 unmodified lines- Fully uncensored (0/465 refusals)- Multimodal capable (text, image, video)- Supports 201 languages- Running with Q4_K_M quantization via llama.cppUse the chat interface below or access via API."""165 unmodified linesapi_name="api_generate",)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/cu12412gradio>=4.0.0huggingface_hub>=0.20.0
DockerfileAdded+28
README.md+7-6
app.py+15-19
requirements.txt-2