installation.rst 5.39 KB
Newer Older
Muyang Li's avatar
Muyang Li committed
1
2
.. _installation-installation:

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Installation
============

We provide step-by-step tutorial videos to help you install and use **Nunchaku on Windows**,
available in both `English <nunchaku_windows_tutorial_en_>`_ and `Chinese <nunchaku_windows_tutorial_zh_>`_.
You can also follow the corresponding text guide at :doc:`Windows Setup Guide <setup_windows>`.
If you encounter any issues, these resources are a good place to start.

(Recommended) Option 1: Installing Prebuilt Wheels
--------------------------------------------------

Prerequisites
^^^^^^^^^^^^^

Ensure that you have `PyTorch ≥ 2.5 <pytorch_home_>`_ installed. For example, to install **PyTorch 2.7 with CUDA 12.8**, use:

.. code-block:: shell

    pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128

Installing Nunchaku
^^^^^^^^^^^^^^^^^^^

Once PyTorch is installed, you can install ``nunchaku`` from one of the following sources:

Muyang Li's avatar
Muyang Li committed
28
29
30
- `GitHub Releases <github_nunchaku_releases_>`_
- `Hugging Face <hf_nunchaku_>`_
- `ModelScope <ms_nunchaku_>`_
31
32
33

.. code-block:: shell

Muyang Li's avatar
Muyang Li committed
34
    pip install https://github.com/nunchaku-tech/nunchaku/releases/download/v0.3.1/nunchaku-0.3.1+torch2.7-cp311-cp311-linux_x86_64.whl
35

Muyang Li's avatar
Muyang Li committed
36
Make sure to replace each version number with the correct one for your environment. `cp311` stands for python version 3.11.x. You can find your own python version using
37
38
39
40
41

.. code-block:: shell

    python --version

42
43
44
45
46
47
For ComfyUI Users
^^^^^^^^^^^^^^^^^

If you're using the **ComfyUI portable package**,
ensure that ``nunchaku`` is installed into the Python environment bundled with ComfyUI. You can either:

Muyang Li's avatar
Muyang Li committed
48
- Use our :ref:`comfyui_nunchaku:install-wheel-json` workflow, or
49
50
- Manually install the wheel using the correct Python path.

Muyang Li's avatar
Muyang Li committed
51
52
Option 1: Using ``install_wheel.json`` Workflow
"""""""""""""""""""""""""""""""""""""""""""""""
53

Muyang Li's avatar
Muyang Li committed
54
55
56
With `ComfyUI-nunchaku <github_comfyui-nunchaku_>`_ v0.3.2+,
you can install Nunchaku using the provided
:ref:`comfyui_nunchaku:install-wheel-json` workflow directly in ComfyUI.
57

Muyang Li's avatar
Muyang Li committed
58
.. image:: https://huggingface.co/datasets/nunchaku-tech/cdn/resolve/main/ComfyUI-nunchaku/workflows/install_wheel.png
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

Option 2: Manual Installation
"""""""""""""""""""""""""""""

To find the correct Python path:

1. Launch ComfyUI.
2. Check the console log—look for a line like:

   .. code-block:: text

       ** Python executable: G:\ComfyUI\python\python.exe

3. Use that executable to install the wheel manually:

   .. code-block:: bat

       "G:\ComfyUI\python\python.exe" -m pip install <your-wheel-file>.whl

   **Example:** Installing for Python 3.11 and PyTorch 2.7:

   .. code-block:: bat

Muyang Li's avatar
Muyang Li committed
82
       "G:\ComfyUI\python\python.exe" -m pip install https://github.com/nunchaku-tech/nunchaku/releases/download/v0.3.1/nunchaku-0.3.1+torch2.7-cp311-cp311-linux_x86_64.whl
83
84
85
86
87
88
89
90
91

For Blackwell GPUs (50-series)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

If you're using a **Blackwell (RTX 50-series)** GPU:

- Use **PyTorch ≥ 2.7** with **CUDA ≥ 12.8**.
- Use **FP4 models** instead of **INT4 models** for best compatibility and performance.

92
93
.. _build-from-source:

94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
Option 2: Build from Source
---------------------------

Requirements
^^^^^^^^^^^^

- **CUDA version**:

  - Linux: ≥ 12.2
  - Windows: ≥ 12.6
  - Blackwell GPUs: CUDA ≥ 12.8 required

- **Compiler**:

  - Linux: ``gcc/g++ >= 11``
  - Windows: Latest **MSVC** via `Visual Studio <visual_studio_>`_

Muyang Li's avatar
Muyang Li committed
111
.. important::
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142

   Currently supported GPU architectures:

   - ``sm_75`` (Turing: RTX 2080)
   - ``sm_80`` (Ampere: A100)
   - ``sm_86`` (Ampere: RTX 3090, A6000)
   - ``sm_89`` (Ada: RTX 4090)
   - ``sm_120`` (Blackwell: RTX 5090)

Step 1: Set Up Environment
^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code-block:: shell

    conda create -n nunchaku python=3.11
    conda activate nunchaku

    # Install PyTorch
    pip install torch torchvision torchaudio

For Blackwell users (50-series), install PyTorch ≥ 2.7 with CUDA ≥ 12.8:

Step 2: Build and Install Nunchaku
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

**For Linux (if** ``gcc/g++`` **is not recent enough):**

.. code-block:: shell

    conda install -c conda-forge gxx=11 gcc=11

143
144
For Windows users, download and install the latest `Visual Studio <visual_studio_>`_ and use its development environment.
See :doc:`Window Setup Guide <setup_windows>` for more details.
145

146
**Clone the Repository:**
147
148
149

.. code-block:: shell

150
    git clone --recurse-submodules https://github.com/nunchaku-tech/nunchaku.git
151
152
    cd nunchaku

153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
**Build and Install:**

.. code-block:: shell

    pip install -e ".[dev,docs]"

This command installs Nunchaku in editable mode along with all development dependencies, making it ideal for contributing or running tests.

.. tip::
   If you only need to use Nunchaku (and not develop, test, or build the documentation),
   you can skip the development dependencies by running either ``pip install -e "."`` or ``python setup.py develop`` after cloning the repository.

.. tip::
   For a faster development workflow and efficient incremental builds, use ``python setup.py develop`` for the future builds.
   The first run will take longer as it compiles the entire project, but subsequent builds will be much faster.

**(Optional) Build a wheel for distribution:**
170
171
172
173
174
175
176
177

.. code-block:: shell

    NUNCHAKU_INSTALL_MODE=ALL NUNCHAKU_BUILD_WHEELS=1 python -m build --wheel --no-isolation

.. important::

   Set ``NUNCHAKU_INSTALL_MODE=ALL`` to ensure the wheel works on all supported GPU architectures. Otherwise, it may only run on the GPU type used for building.