Cloud Resource Allocation
Navigate to the cloud provider's trial portal and request the allocated GPU compute units. Upon approval, the quota is credited to the account immediately. Select an instance tier that explicitly supports resource pack deduction to utilize the trial credits effectively. Calculate the estimated runtime based on the hourly CU consumption rate of the chosen GPU hardware.
Instance Configuration
Access the machine learning console and initiate a new DSW (Data Science Workshop) instance. Select a GPU-backed environment, preferably one pre-configured with a stable PyTorch release. Instances typically provision ephemeral system disks; halting the environment will erase all local files. To persist data, attach a network-attached storage (NAS) volume during creation. Once provisioned, launch the interactive web terminal.
Weight Acquisition
Large language model repositories exceed standard Git size limits. Install Git Large File Storage to handle binary weight files.
apt-get update && apt-get install -y git-lfs
# Initialize LFS and clone the repository
git lfs install
git clone https://huggingface.co/THUDM/chatglm-6b
# Resume or complete the binary download
cd chatglm-6b && git lfs pull
If network interruptions occur during the clone operation, re-enter the directorry and execute git lfs pull to fetch the remaining LFS-tracked assets.
Environment Setup & Path Configuration
Clone the official inference repository and establish an isolated Python environment. Resolve compilation dependencies if wheel builds fail during dependency installation.
git clone https://github.com/THUDM/ChatGLM-6B.git
cd ChatGLM-6B
python3 -m venv llm_env
source llm_env/bin/activate
# Install core dependencies
pip install -r requirements.txt
# Fallback for compilation errors
apt-get install -y python3-dev build-essential
Instead of manually editing multiple scripts, abstract the model location into a centralized configuration module. This approach prevents path resolution errors during execution.
# config.py
import os
# Define absolute path to locally cached weights
LOCAL_MODEL_DIR = os.getenv("MODEL_CACHE_PATH", "/mnt/workspace/chatglm-6b")
Modify the primary entry points (cli_demo.py and web_demo.py) to import this configuration. Replace hardcoded remote identifiers with the localized path variable before initializing the tokenizer and model loader.
# Inference loader snippet
from config import LOCAL_MODEL_DIR
from transformers import AutoTokenizer, AutoModel
def initialize_model():
tokenizer = AutoTokenizer.from_pretrained(
LOCAL_MODEL_DIR,
trust_remote_code=True
)
model = AutoModel.from_pretrained(
LOCAL_MODEL_DIR,
trust_remote_code=True
).half().cuda()
return tokenizer, model
Inference Execution
Execute the web-based inferencce script. The initialization phase loads approximately 13GB of parameters into RAM before transferring them to the VRAM.
python web_demo.py
Upon successful initialization, the framework exposes a localhost URL and a public tunnel address for browser-based interaction. Response latency on a V100 GPU typically falls within the 1-2 second range for initial token generation.
Quota Monitoring
Trial credits operate under a strict validity window and consumption cap. Monitor usage via the billing dashboard under resource package management. The interface provides granular breakdowns of compute unit depletion per active instance. Pause or terminate idle environments immediately to preserve remaining quota.