Skip to content

Instantly share code, notes, and snippets.

@wuriyanto48
Last active April 11, 2025 09:18
Show Gist options
  • Save wuriyanto48/0e78d26d6b8853369581ee4813be4475 to your computer and use it in GitHub Desktop.
Save wuriyanto48/0e78d26d6b8853369581ee4813be4475 to your computer and use it in GitHub Desktop.

Install NVIDIA Docker

# add repo
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list

# Update & install
sudo apt update
sudo apt install -y nvidia-docker2

# Restart Docker
sudo systemctl restart docker

Testing

docker run --rm --gpus all nvidia/cuda:11.8.0-base-ubuntu22.04 nvidia-smi

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 525.85.12    Driver Version: 525.85.12    CUDA Version: 12.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
+-------------------------------+----------------------+----------------------+

Run

docker run -it -p 7860:7860 --platform=linux/amd64 --gpus all \
  registry.hf.space/jeffreyxiang-trellis:latest python app.py

How to avoid downloading models every time you run a container

After the Run step above, copy the /home/user folder to our Host Computer

docker cp replace_this_container_name:/home/user ./container_home_backup

Stop Container that was previously running

docker stop replace_this_container_name

Then rerun it by including the volume folder /home/user that we copied earlier

docker run -it -p 7860:7860 --gpus all \
  -v $(pwd)/container_home_backup:/home/user \
  registry.hf.space/jeffreyxiang-trellis:latest python app.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment