網頁

2025年6月12日 星期四

安裝 Flux & ComfyUI

參考 https://www.jetson-ai-lab.com/tutorial_comfyui_flux.html

$ sudo jtop
CUDA: 12.2.140
cuDNN: 8.9.4.25
TensorRT: 8.6.2.3

因為需要從 cuda-12.2 更新到 cuda-12.6
而在更新的過程中,會移除 Deepstream-7.0
所以需要自己安裝 Deepstream-7.1

記錄下目前的版本資料
$ dpkg -l>dekg_jp6.0.txt

$ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh
$ chmod +x Miniconda3-latest-Linux-aarch64.sh
$ ./Miniconda3-latest-Linux-aarch64.sh
$ conda update conda
$ conda create -n comfyui python=3.10
$ conda init bash
$ cat .bashrc
$ conda activate comfyui
$ conda info --envs
$ conda deactivate
$ conda activate comfyui
$ conda list

$ wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/arm64/cuda-keyring_1.1-1_all.deb
$ sudo dpkg -i cuda-keyring_1.1-1_all.deb
$ sudo apt-get update
$ sudo apt-get -y install cuda-toolkit-12-6 cuda-compat-12-6
$ update-alternatives --list cuda
$ update-alternatives --display cuda
$ sudo update-alternatives --config cuda
cuda-12.6

$ sudo apt-get install cudnn=9.5.1-1
$ sudo apt-get install python3-libnvinfer=9.5.1-1
The following packages will be REMOVED:
  deepstream-7.0 libnvparsers-dev nvidia-tensorrt-dev
$ sudo apt-get install python3-libnvinfer-dev=10.6.0.26-1+cuda12.6
$ sudo jtop
CUDA: 12.6.77
cuDNN: 9.5.1
TensorRT: 10.6.0.26
$ wget --content-disposition 'https://api.ngc.nvidia.com/v2/resources/org/nvidia/deepstream/7.1/files?redirect=true&path=deepstream-7.1_7.1.0-1_arm64.deb' -O deepstream-7.1_7.1.0-1_arm64.deb
$ sudo apt-get install ./deepstream-7.1_7.1.0-1_arm64.deb

$ export BNB_CUDA_VERSION=126
$ export LD_LIBRARY_PATH=/usr/local/cuda-12.6/lib64:$LD_LIBRARY_PATH

$ git clone https://github.com/timdettmers/bitsandbytes.git
$ cd bitsandbytes

$ pip uninstall numpy
$ pip install "numpy<2.0"
$ mkdir -p build
$ cd build
$ cmake .. -DCOMPUTE_BACKEND=cuda -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-12.6
$ make -j$(nproc)
$ cd ..
$ python setup.py install

$ pip install http://jetson.webredirect.org/jp6/cu124/+f/5fe/ee5f5d1a75229/torch-2.3.0-cp310-cp310-linux_aarch64.whl
$ pip install http://jetson.webredirect.org/jp6/cu124/+f/988/cb71323efff87/torchvision-0.18.0a0+6043bc2-cp310-cp310-linux_aarch64.whl
$ pip install http://jetson.webredirect.org/jp6/cu124/+f/0aa/a066463c02b4a/torchaudio-2.3.0+952ea74-cp310-cp310-linux_aarch64.whl

$ python3
>>> import bitsandbytes as bnb
>>> print(bnb.__version__)

$ git clone https://github.com/comfyanonymous/ComfyUI.git
$ cd ComfyUI
$ pip install -r requirements.txt
$ cd custom_nodes
$ git clone https://github.com/ltdrdata/ComfyUI-Manager.git
$ cd ..
$ mkdir workflows
$ cd workflows
$ wget https://www.jetson-ai-lab.com/assets/workflow_agx_orin_4steps.json
$ cd ..
到 https://huggingface.co/black-forest-labs/FLUX.1-schnell/tree/main
下載 flux1-schnell.safetensors 放到 models/unet
下載 ae.safetensors 放到 models/vae/FLUX1
到 https://huggingface.co/stabilityai/stable-diffusion-3-medium/tree/main/text_encoders
下載 clip_l.safetensors 和 t5xxl_fp8_e4m3fn.safetensors 放到 models/clip
$ python main.py --port=8080
http://127.0.0.1:8080/
Load workflow_agx_orin_4steps.json 時,需修改 "Load VAE" 的 vae_name 到 FLUX1/ae.safetensors

記錄下目前的版本資料
$ dpkg -l>dekg_jp6.0_cuda-12.6.txt

若需要將 cuda-12.6 還回 cuda-12.2
$ cd jetpack_6.0
$ ./download.sh
$ ./install.sh
參考記錄下來的版本資料 dekg_jp6.0.txt dekg_jp6.0_cuda-12.6.txt
移除不必要的 package
$ sudo apt-get remove --purge package

參考 https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-cuda/tags
$ xhost +
$ docker run -it --rm --net=host --runtime nvidia\
  -e DISPLAY=$DISPLAY \
  -v /tmp/.X11-unix/:/tmp/.X11-unix \
  nvcr.io/nvidia/l4t-cuda:11.4.19-runtime
$ docker run -it --rm --net=host --runtime nvidia\
  -e DISPLAY=$DISPLAY \
  -v /tmp/.X11-unix/:/tmp/.X11-unix \
  nvcr.io/nvidia/l4t-cuda:12.2.12-runtime
$ docker run -it --rm --net=host --runtime nvidia\
  -e DISPLAY=$DISPLAY \
  -v /tmp/.X11-unix/:/tmp/.X11-unix \
  nvcr.io/nvidia/l4t-cuda:12.6.11-runtime
docker: Error response from daemon: failed to create task for container: 
failed to create shim task: OCI runtime create failed: 
failed to create NVIDIA Container Runtime: failed to construct OCI spec modifier: 
requirements not met: unsatisfied condition: cuda>=12.6 (cuda=12.2): unknown.


$ docker run -it --rm --net=host --runtime nvidia\
  -e DISPLAY=$DISPLAY \
  -v /tmp/.X11-unix/:/tmp/.X11-unix \
  -w /opt/nvidia/deepstream/deepstream-7.0 \
  nvcr.io/nvidia/deepstream-l4t:7.0-samples-multiarch

docker run -it --rm --net=host --runtime nvidia\
  -e DISPLAY=$DISPLAY \
  -v /tmp/.X11-unix/:/tmp/.X11-unix \
  -w /opt/nvidia/deepstream/deepstream-7.1 \
  nvcr.io/nvidia/deepstream-l4t:7.1-samples-multiarch

沒有留言:

張貼留言