3X Your Interview Chances
AI Resume Builder
Import LinkedIn, get AI suggestions, land more interviews
3 min to read
Hunyuan3D-2 is an advanced open-source 3D modeling tool developed by Tencent, designed to generate high-resolution 3D assets from images and text. This guide provides a step-by-step approach to installing and configuring Hunyuan3D-2 on an Ubuntu machine.
Before installing Hunyuan3D-2, ensure your system meets the following requirements:
Open a terminal and execute:
sudo apt update
sudo apt install git build-essential
If Python is not installed, install it using:
sudo apt install python3 python3-pip python3-venv
Download the Hunyuan3D-2 source code from GitHub:
git clone https://github.com/tencent/Hunyuan3D-2.git
cd Hunyuan3D-2
Creating a virtual environment ensures package dependencies remain isolated:
python3 -m venv hunyuan3d-env
source hunyuan3d-env/bin/activate
Install PyTorch based on your CUDA version. For CUDA 12.1, use:
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
For other CUDA versions, check the official PyTorch installation guide.
Install additional dependencies listed in requirements.txt
:
pip install -r requirements.txt
Hunyuan3D-2 requires pretrained models from Hugging Face. Install the Hugging Face CLI:
pip install huggingface_hub[cli]
Then download the models:
mkdir weights
huggingface-cli download tencent/Hunyuan3D-2 --local-dir ./weights
You may need to log in to Hugging Face to access the models.
For better performance, install xformers
and flash_attn
:
pip install xformers --index-url https://download.pytorch.org/whl/cu121
pip install flash_attn --index-url https://download.pytorch.org/whl/cu121
Run Python and check if PyTorch is installed correctly:
python
>>> import torch
>>> print(torch.__version__)
If the version prints without errors, PyTorch is installed successfully.
To start Hunyuan3D-2, navigate to the project directory and run:
cd path/to/Hunyuan3D-2/hy3dgen/
python app.py
This launches the application, allowing you to generate 3D models.
Hunyuan3D-2 supports both image-to-3D and text-to-3D generation.
Use the following Python snippet to create a 3D model from an image:
from hy3dgen.shapegen import Hunyuan3DDiTFlowMatchingPipeline
pipeline = Hunyuan3DDiTFlowMatchingPipeline.from_pretrained('tencent/Hunyuan3D-2')
mesh = pipeline(image='path/to/your/image.png')
For text-to-3D model generation, use:
from hy3dgen.shapegen import Hunyuan3DDiTFlowMatchingPipeline
pipeline = Hunyuan3DDiTFlowMatchingPipeline.from_pretrained('tencent/Hunyuan3D-2')
mesh = pipeline(text='A detailed description of your desired object.')
Ensure your NVIDIA drivers are up-to-date and match your CUDA version.
If dependency issues arise, specify exact package versions in requirements.txt
.
Try reducing input image sizes or increasing RAM if memory errors occur.
Ensure a stable internet connection and login to Hugging Face before downloading.
By following this guide, you can successfully install and run Hunyuan3D-2 on your Ubuntu machine. This tool provides powerful 3D generation capabilities from images and text prompts, making it an excellent choice for artists, developers, and researchers.
For further details, visit the Hunyuan3D-2 GitHub repository.
References:
[1] Digital Alps - Hunyuan3D-2 Overview
[2] Lizedin
[3] YouTube - Hunyuan3D-2 Demos
[4] YouTube - Hunyuan3D-2 Review
[5] Reddit - Stable Diffusion Discussion
[6] Hacker News - Hunyuan3D-2