728x90

출처

nfs 패키지 설치

bluesanta@bluesanta-A520M-ITX-ac:~$ sudo apt install nfs-common

NFS 를 통해 공유 폴더 마운트

bluesanta@bluesanta-A520M-ITX-ac:~$ sudo mkdir /share_disk
bluesanta@bluesanta-A520M-ITX-ac:~$ sudo mount -t nfs 192.168.0.58:/volumeUSB2/usbshare /share_disk
728x90
728x90

가상환경 만들기

bluesanta@bluesanta-A520M-ITX-ac:~$ mkdir Application
bluesanta@bluesanta-A520M-ITX-ac:~$ cd Application/
bluesanta@bluesanta-A520M-ITX-ac:~/Application$ mkdir stable_diffusion
bluesanta@bluesanta-A520M-ITX-ac:~/Application$ cd stable_diffusion
bluesanta@bluesanta-A520M-ITX-ac:~/Application/stable_diffusion$ sudo apt install python3-venv
bluesanta@bluesanta-A520M-ITX-ac:~/Application/stable_diffusion$ python3 -m venv .venv
bluesanta@bluesanta-A520M-ITX-ac:~/Application/stable_diffusion$ source .venv/bin/activate
(.venv) bluesanta@bluesanta-A520M-ITX-ac:~/Application/stable_diffusion$

PyTorch 설치 (CUDA 12.x 기반 호환)

현재 PyTorch 공식 빌드는 CUDA 12.4~12.6까지 지원

(.venv) bluesanta@bluesanta-A520M-ITX-ac:~/Application/stable_diffusion$ pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124

Transformer 및 최적화 라이브러리 설치

(.venv) bluesanta@bluesanta-A520M-ITX-ac:~/Application/stable_diffusion$ pip install transformers datasets accelerate

8-bit/4-bit 양자화용

(.venv) bluesanta@bluesanta-A520M-ITX-ac:~/Application/stable_diffusion$ pip install bitsandbytes

LoRA 등 효율적 파인튜닝용

(.venv) bluesanta@bluesanta-A520M-ITX-ac:~/Application/stable_diffusion$ pip install peft

ONNX, OpenVINO 등 하드웨어 가속용

(.venv) bluesanta@bluesanta-A520M-ITX-ac:~/Application/stable_diffusion$ pip install optimum

Flash Attention 설치

RTX 4060은 Ada Lovelace 아키텍처를 사용하므로, Transformer 연산 속도를 획기적으로 높여주는 Flash Attention을 설치

(.venv) bluesanta@bluesanta-A520M-ITX-ac:~/Application/stable_diffusion$ pip install flash-attn --no-build-isolation

CUDA 12.4 설치

cuda_version_check.py

import torch
import torch.backends.cudnn as cudnn

print(f"PyTorch version: {torch.__version__}")
print(f"CUDA available: {torch.cuda.is_available()}")
print(f"GPU Name: {torch.cuda.get_device_name(0)}")
print(f"cuDNN version: {torch.backends.cudnn.version()}")

# 현재 연결된 GPU 장치 수
print(f"Device Count: {torch.cuda.device_count()}")

# 간단한 텐서 연산 테스트
x = torch.randn(3, 3).cuda()
print("Tensor operation success!")

if cudnn.is_acceptable(torch.randn(1, device='cuda')):
    print(f"cuDNN version: {cudnn.version()}")
    print("cuDNN is working perfectly!")

실행

(.venv) bluesanta@bluesanta-A520M-ITX-ac:~/Application/stable_diffusion$ python cuda_version_check.py 
PyTorch version: 2.6.0+cu124
CUDA available: True
GPU Name: NVIDIA GeForce RTX 4060
cuDNN version: 90100
Device Count: 1
Tensor operation success!
cuDNN version: 90100
cuDNN is working perfectly!
728x90
728x90

리눅스 버전 확인

bluesanta@bluesanta-A520M-ITX-ac:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.3 LTS
Release:        24.04
Codename:       noble

NVIDIA 드라이버 버전 확인

bluesanta@bluesanta-A520M-ITX-ac:~$ nvidia-smi
Fri Jan  2 21:13:47 2026       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 580.95.05              Driver Version: 580.95.05      CUDA Version: 13.0     |
+-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce RTX 4060        Off |   00000000:01:00.0 Off |                  N/A |
|  0%   41C    P8            N/A  /  115W |     378MiB /   8188MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
 
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A            2210      G   /usr/lib/xorg/Xorg                      183MiB |
|    0   N/A  N/A            2428      G   /usr/bin/gnome-shell                    143MiB |
+-----------------------------------------------------------------------------------------+

CUDA 12.4 설치

NVIDIA 저장소 키 및 리스트 등록

bluesanta@bluesanta-A520M-ITX-ac:~$ sudo apt update
bluesanta@bluesanta-A520M-ITX-ac:~$ sudo apt install build-essential dkms wget
bluesanta@bluesanta-A520M-ITX-ac:~$ wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-ubuntu2404.pin
bluesanta@bluesanta-A520M-ITX-ac:~$ sudo mv cuda-ubuntu2404.pin /etc/apt/preferences.d/cuda-repository-pin-600
bluesanta@bluesanta-A520M-ITX-ac:~$ wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb
bluesanta@bluesanta-A520M-ITX-ac:~$ sudo dpkg -i cuda-keyring_1.1-1_all.deb
bluesanta@bluesanta-A520M-ITX-ac:~$ sudo apt update

CUDA 12.4 Toolkit 설치

bluesanta@bluesanta-A520M-ITX-ac:~$ sudo apt install cuda-toolkit-12-4

CUDA Toolkit 설치 여부 확인

bluesanta@bluesanta-A520M-ITX-ac:~$ whereis cuda
cuda: /usr/lib/cuda /usr/include/cuda /usr/local/cuda
bluesanta@bluesanta-A520M-ITX-ac:~$ ls -l /usr/local | grep cuda
lrwxrwxrwx  1 root root   22  1월  2 22:32 cuda -> /etc/alternatives/cuda
lrwxrwxrwx  1 root root   25  1월  2 22:32 cuda-12 -> /etc/alternatives/cuda-12
drwxr-xr-x 15 root root 4096  1월  2 22:32 cuda-12.4

환경 변수 등록

설치가 완료되면 /usr/local/cuda-12.4 폴더가 생성됩니다. 이제 시스템이 이 폴더를 인식하도록 설정

bluesanta@bluesanta-A520M-ITX-ac:~$ vi ~/.bashrc

~/.bashrc 내용 추가

# 파일 맨 아래에 다음 세 줄 추가
export PATH=/usr/local/cuda-12.4/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-12.4/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export CUDA_HOME=/usr/local/cuda-12.4

CUDA Toolkit 설치 (Ubuntu 24.04 기준) - 위에 설치 된것 같지만 다시 확인 필요

bluesanta@bluesanta-A520M-ITX-ac:~$ sudo apt update
bluesanta@bluesanta-A520M-ITX-ac:~$ sudo apt install build-essential dkms
bluesanta@bluesanta-A520M-ITX-ac:~$ sudo apt install nvidia-cuda-toolkit

cuDNN 9 (CUDA 12용) 설치

bluesanta@bluesanta-A520M-ITX-ac:~$ sudo apt install libcudnn9-cuda-12

설치 확인

bluesanta@bluesanta-A520M-ITX-ac:~$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Thu_Mar_28_02:18:24_PDT_2024
Cuda compilation tools, release 12.4, V12.4.131
Build cuda_12.4.r12.4/compiler.34097967_0
728x90
728x90

출처

리눅스 버전 확인

bluesanta@bluesanta-AI-Series:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.3 LTS
Release:        24.04
Codename:       noble
bluesanta@bluesanta-AI-Series:~$ lsmod | grep amdgpu
amdgpu              19836928  5
amddrm_ttm_helper      12288  1 amdgpu
amdttm                131072  2 amdgpu,amddrm_ttm_helper
amddrm_buddy           24576  1 amdgpu
amdxcp                 16384  1 amdgpu
amddrm_exec            12288  1 amdgpu
drm_suballoc_helper    20480  1 amdgpu
amd_sched              61440  1 amdgpu
amdkcl                 36864  4 amd_sched,amdttm,amddrm_exec,amdgpu
drm_panel_backlight_quirks    12288  1 amdgpu
drm_display_helper    278528  1 amdgpu
cec                    94208  2 drm_display_helper,amdgpu
i2c_algo_bit           16384  1 amdgpu
drm_ttm_helper         16384  1 amdgpu
video                  77824  1 amdgpu
bluesanta@bluesanta-AI-Series:~$ dkms status
amdgpu/6.16.6-2255209.24.04, 6.14.0-37-generic, x86_64: installed

ComfyUI 설치

가상환경실행

bluesanta@bluesanta-AI-Series:~$ cd Application/stable_diffusion/
bluesanta@bluesanta-AI-Series:~/Application/stable_diffusion$ source .venv/bin/activate
(.venv) bluesanta@bluesanta-AI-Series:~/Application/stable_diffusion$ 

ComfyUI 다운로드

(.venv) bluesanta@bluesanta-AI-Series:~/Application/stable_diffusion$ git clone https://github.com/comfyanonymous/ComfyUI.git

ComfyUI 참조 패키지 설치

(.venv) bluesanta@bluesanta-AI-Series:~/Application/stable_diffusion$ cd ComfyUI/
(.venv) bluesanta@bluesanta-AI-Series:~/Application/stable_diffusion/ComfyUI$ pip install -r requirements.txt

ComfyUI 실행

(.venv) bluesanta@bluesanta-AI-Series:~/Application/stable_diffusion/ComfyUI$ python main.py
Checkpoint files will always be loaded safely.
Total VRAM 14844 MB, total RAM 29688 MB
pytorch version: 2.9.1+rocm7.10.0
Set: torch.backends.cudnn.enabled = False for better AMD performance.
AMD arch: gfx1150
ROCm version: (7, 2)
Set vram state to: NORMAL_VRAM
Device: cuda:0 AMD Radeon 890M Graphics : native
Using async weight offloading with 2 streams
Enabled pinned memory 28203.0
Using sub quadratic optimization for attention, if you have memory or speed issues try using: --use-split-cross-attention
Python version: 3.12.3 (main, Nov  6 2025, 13:44:16) [GCC 13.3.0]
ComfyUI version: 0.7.0
****** User settings have been changed to be stored on the server instead of browser storage. ******
****** For multi-user setups add the --multi-user CLI argument to enable multiple user profiles. ******
ComfyUI frontend version: 1.35.9
[Prompt Server] web root: /home/bluesanta/Application/stable_diffusion/.venv/lib/python3.12/site-packages/comfyui_frontend_package/static
Total VRAM 14844 MB, total RAM 29688 MB
pytorch version: 2.9.1+rocm7.10.0
Set: torch.backends.cudnn.enabled = False for better AMD performance.
AMD arch: gfx1150
ROCm version: (7, 2)
Set vram state to: NORMAL_VRAM
Device: cuda:0 AMD Radeon 890M Graphics : native
Using async weight offloading with 2 streams
Enabled pinned memory 28203.0
 
Import times for custom nodes:
   0.0 seconds: /home/bluesanta/Application/stable_diffusion/ComfyUI/custom_nodes/websocket_image_save.py
 
Context impl SQLiteImpl.
Will assume non-transactional DDL.
No target revision found.
Starting server
 
To see the GUI go to: http://127.0.0.1:8188

ComfyUI Manager 설치

(.venv) bluesanta@bluesanta-AI-Series:~/Application/stable_diffusion/ComfyUI$ cd custom_nodes/
(.venv) bluesanta@bluesanta-AI-Series:~/Application/stable_diffusion/ComfyUI/custom_nodes$ git clone https://github.com/Comfy-Org/ComfyUI-Manager.git
(.venv) bluesanta@bluesanta-AI-Series:~/Application/stable_diffusion/ComfyUI/custom_nodes$ pip install -r ComfyUI-Manager/requirements.txt
728x90
728x90

출처

리눅스 버전 확인

bluesanta@bluesanta-AI-Series:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.3 LTS
Release:        24.04
Codename:       noble

AMD GPU 드라이버 설치

AMD GPU 설치 프로그램 설치

bluesanta@bluesanta-AI-Series:~$ wget https://repo.radeon.com/amdgpu-install/30.20.1/ubuntu/noble/amdgpu-install_7.1.1.70101-1_all.deb
bluesanta@bluesanta-AI-Series:~$ sudo dpkg -i amdgpu-install_7.1.1.70101-1_all.deb 
[sudo] password for bluesanta: 
Selecting previously unselected package amdgpu-install.
(Reading database ... 215673 files and directories currently installed.)
Preparing to unpack amdgpu-install_7.1.1.70101-1_all.deb ...
Unpacking amdgpu-install (30.20.1.0.30200100-2255209.24.04) ...
Setting up amdgpu-install (30.20.1.0.30200100-2255209.24.04) ...

ROCm 패키지 설치

bluesanta@bluesanta-AI-Series:~$ sudo amdgpu-install --usecase=rocm,hiplibsdk --no-dkms

설치 확인

(.venv) bluesanta@bluesanta-AI-Series:~/Application/stable_diffusion$ lsmod | grep amdgpu
amdgpu              19836928  6
amddrm_ttm_helper      12288  1 amdgpu
amdttm                131072  2 amdgpu,amddrm_ttm_helper
amddrm_buddy           24576  1 amdgpu
amdxcp                 16384  1 amdgpu
amddrm_exec            12288  1 amdgpu
drm_suballoc_helper    20480  1 amdgpu
amd_sched              61440  1 amdgpu
amdkcl                 36864  4 amd_sched,amdttm,amddrm_exec,amdgpu
drm_panel_backlight_quirks    12288  1 amdgpu
drm_display_helper    278528  1 amdgpu
cec                    94208  2 drm_display_helper,amdgpu
i2c_algo_bit           16384  1 amdgpu
drm_ttm_helper         16384  1 amdgpu
video                  77824  1 amdgpu
(.venv) bluesanta@bluesanta-AI-Series:~/Application/stable_diffusion$ dkms status
amdgpu/6.16.6-2255209.24.04, 6.14.0-37-generic, x86_64: installed

아키텍처 강제 인식

HX 370(gfx1150)은 최신 아키텍처이므로, PyTorch가 이를 인식하도록 환경 변수를 선언해야 합니다. 터미널에서 다음을 입력하거나 .bashrc에 추가

bluesanta@bluesanta-AI-Series:~$ vi ~/.bashrc

.bashrc 파일에 HSA_OVERRIDE_GFX_VERSION 값 설정

export HSA_OVERRIDE_GFX_VERSION=11.5.0

PyTorch 설치

가상환경만들기

bluesanta@bluesanta-AI-Series:~/Application/stable_diffusion$ sudo apt install python3-venv
bluesanta@bluesanta-AI-Series:~/Application/stable_diffusion$ python3 -m venv .venv
bluesanta@bluesanta-AI-Series:~/Application/stable_diffusion$ source .venv/bin/activate
(.venv) bluesanta@bluesanta-AI-Series:~/Application/stable_diffusion$ 

ROCm 지원 PyTorch 빌드 및 설치

(.venv) bluesanta@bluesanta-AI-Series:~/Application/stable_diffusion$ python -m pip install --index-url https://repo.amd.com/rocm/whl/gfx1150/ torch torchvision torchaudio

적용 확인

(.venv) bluesanta@bluesanta-AI-Series:~/Application/stable_diffusion$ python -c "import torch; print(torch.cuda.is_available())"
True
728x90
728x90

출처

Deadsnakes PPA에서 Python 3.11 저장소에 추가

orangepi@orangepi5-plus:~$ sudo apt install -y software-properties-common
orangepi@orangepi5-plus:~$ sudo add-apt-repository ppa:deadsnakes/ppa -y
orangepi@orangepi5-plus:~$ sudo apt update

설치하기 전에 apt가 PPA에서 패키지를 가져오는지 확인

orangepi@orangepi5-plus:~$ sudo apt policy python3.11
python3.11:
  설치: (없음)
  후보: 3.11.14-1+noble1
  버전 테이블:
     3.11.14-1+noble1 500
        500 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu noble/main arm64 Packages

Python 3.11 설치

orangepi@orangepi5-plus:~$ sudo apt install python3.11 python3.11-venv python3.11-dev
orangepi@orangepi5-plus:~$ sudo apt install python3.11-dbg python3.11-gdbm python3.11-tk

Python 3.11 설치 확인

orangepi@orangepi5-plus:~$ python3.11 --version
Python 3.11.14
orangepi@orangepi5-plus:~$ python3.11 -c "import ssl, sqlite3, bz2; print('Source build is healthy')"
Source build is healthy

Python 3.11 가상 환경

orangepi@orangepi5-plus:~$ mkdir Llama
orangepi@orangepi5-plus:~$ cd Llama
orangepi@orangepi5-plus:~/Llama$ sudo apt install python3.11-venv
orangepi@orangepi5-plus:~/Llama$ python3.11 -m venv .venv
orangepi@orangepi5-plus:~/Llama$ source .venv/bin/activate
(.venv) orangepi@orangepi5-plus:~/Llama$ python -m pip --version
pip 24.0 from /home/orangepi/Llama/.venv/lib/python3.11/site-packages/pip (python 3.11)

Bootstrap Pip with get-pip.py

orangepi@orangepi5-plus:~$ wget https://bootstrap.pypa.io/get-pip.py
orangepi@orangepi5-plus:~$ python3.11 get-pip.py
orangepi@orangepi5-plus:~$ rm get-pip.py
728x90
728x90

출처

리눅스 버전 확인

orangepi@orangepi5plus:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.5 LTS
Release:        22.04
Codename:       jammy
orangepi@orangepi5plus:~$ free -h
               total        used        free      shared  buff/cache   available
Mem:           7.7Gi       511Mi       6.7Gi        13Mi       592Mi       7.2Gi
Swap:          3.9Gi          0B       3.9Gi

NPU 드라이버 버전 확인

orangepi@orangepi5plus:~$ sudo cat /sys/kernel/debug/rknpu/version
RKNPU driver: v0.9.8

python 설치

orangepi@orangepi5plus:~$ sudo apt install python3 python3-pip python3-venv

python 가상 환경 만들기

orangepi@orangepi5plus:~$ mkdir Llama
orangepi@orangepi5plus:~$ cd Llama
orangepi@orangepi5plus:~/Llama$ python3 -m venv .venv
orangepi@orangepi5plus:~/Llama$ source .venv/bin/activate
(.venv) orangepi@orangepi5plus:~/Llama$ 

RKNN-Toolkit2

cmake 설치

(.venv) orangepi@orangepi5plus:~/Llama$ sudo apt install cmake

rknn-toolkit2 설치

(.venv) orangepi@orangepi5plus:~/Llama$ pip install rknn-toolkit2

rknn-toolkit2 설치 확인

(.venv) orangepi@orangepi5plus:~/Llama$ python -c "import rknn.api.rknn_base as base; print(base.__file__)"
/home/orangepi/Llama/.venv/lib/python3.10/site-packages/rknn/api/rknn_base.cpython-310-aarch64-linux-gnu.so
(.venv) orangepi@orangepi5plus:~/Llama$ pip show rknn-toolkit2
Name: rknn-toolkit2
Version: 2.3.2
Summary: Rockchip Neural Network Toolkit2. (commit: c7d6ffcf)
Home-page: https://github.com/airockchip/rknn-toolkit2
Author: ai@rock-chips.com
Author-email: ai@rock-chips.com
License: 
Location: /home/orangepi/Llama/.venv/lib/python3.10/site-packages
Requires: fast-histogram, numpy, onnx, onnxoptimizer, onnxruntime, opencv-python, protobuf, psutil, ruamel.yaml, scipy, torch, tqdm
Required-by: 
(.venv) orangepi@orangepi5plus:~/Llama$  pip show torch
Name: torch
Version: 2.2.0
Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration
Home-page: https://pytorch.org/
Author: PyTorch Team
Author-email: packages@pytorch.org
License: BSD-3
Location: /home/orangepi/Llama/.venv/lib/python3.10/site-packages
Requires: filelock, fsspec, jinja2, networkx, sympy, typing-extensions
Required-by: rknn-toolkit2

torchvision 설치

(.venv) orangepi@orangepi5plus:~/Llama$ pip install torchvision==0.17.0 torchaudio==2.2.0
(.venv) orangepi@orangepi5plus:~/Llama$ pip show torchvision
Name: torchvision
Version: 0.17.0
Summary: image and video datasets and models for torch deep learning
Home-page: https://github.com/pytorch/vision
Author: PyTorch Core Team
Author-email: soumith@pytorch.org
License: BSD
Location: /home/orangepi/Llama/.venv/lib/python3.10/site-packages
Requires: numpy, pillow, requests, torch
Required-by: 
(.venv) orangepi@orangepi5plus:~/Llama$ pip show torchaudio
Name: torchaudio
Version: 2.2.0
Summary: An audio package for PyTorch
Home-page: https://github.com/pytorch/audio
Author: Soumith Chintala, David Pollack, Sean Naren, Peter Goldsborough, Moto Hira, Caroline Chen, Jeff Hwang, Zhaoheng Ni, Xiaohui Zhang
Author-email: soumith@pytorch.org
License: 
Location: /home/orangepi/Llama/.venv/lib/python3.10/site-packages
Requires: torch
Required-by: 
728x90
728x90

출처

리눅스 버전 확인

orangepi@orangepi5plus:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.5 LTS
Release:        22.04
Codename:       jammy
orangepi@orangepi5plus:~$ free -h
               total        used        free      shared  buff/cache   available
Mem:           7.7Gi       522Mi       6.4Gi        13Mi       907Mi       7.1Gi
Swap:          3.9Gi          0B       3.9Gi

rknpu2 드라이버 버전 확인

orangepi@orangepi5plus:~$ sudo cat /sys/kernel/debug/rknpu/version
RKNPU driver: v0.9.6

github에서 orangepi-build 다운로드

orangepi@orangepi5plus:~$ cd ~
orangepi@orangepi5plus:~$ git clone https://github.com/orangepi-xunlong/orangepi-build.git -b next

리눅스 5.10 커널 소스 코드 다운로드

orangepi@orangepi5plus:~$ cd orangepi-build
orangepi@orangepi5plus:~/orangepi-build$ mkdir kernel && cd kernel
orangepi@orangepi5plus:~/orangepi-build/kernel$ git clone https://github.com/orangepi-xunlong/linux-orangepi.git -b orange-pi-6.1-rk35xx
orangepi@orangepi5plus:~/orangepi-build/kernel$ mv linux-orangepi/ orange-pi-6.1-rk35xx

RKNPU 드라이버 무시함

orangepi@orangepi5plus:~/orangepi-build/kernel$ cd ~/orangepi-build
orangepi@orangepi5plus:~/orangepi-build$ git clone https://github.com/airockchip/rknn-llm.git
orangepi@orangepi5plus:~/orangepi-build$ tar -xvf rknn-llm/rknpu-driver/rknpu_driver_0.9.8_20241009.tar.bz2 
orangepi@orangepi5plus:~/orangepi-build$ cp -r drivers/ kernel/orange-pi-6.1-rk35xx/

컴파일 오류를 피하기 위해 몇 가지 파일을 수정

kernel/include/linux/mm.h 코드 추가

orangepi@orangepi5plus:~/orangepi-build$ vi kernel/orange-pi-6.1-rk35xx/include/linux/mm.h
static inline void vm_flags_set(struct vm_area_struct *vma, vm_flags_t flags) {
  vma->vm_flags |= flags;
}

static inline void vm_flags_clear(struct vm_area_struct *vma, vm_flags_t flags) {
  vma->vm_flags &= ~flags;
}

rknpu_devfreq.c 코드 수정

orangepi@orangepi5plus:~/orangepi-build$ vi kernel/orange-pi-6.1-rk35xx/drivers/rknpu/rknpu_devfreq.c

237행 주석 처리 : set_soc_info = rockchip_opp_set_low_length,

소스 코드 동기화 비활성화

kernel/orange-pi-5.10-rk35xx 디렉터리에 드라이버를 수동으로 덮어썼기 때문에, 컴파일을 직접 실행하면 스크립트가 클라우드 내 소스 코드와 불일치를 검사해 코드를 다시 풀어서 덮어쓰기 문제가 발생합니다. 따라서 설정 파일에서 소스 코드 동기화 기능을 비활성화해야 합니다.

빌드 스크립트를 실행하여 초기화 실행

orangepi@orangepi5plus:~/orangepi-build$ sudo ./build.sh

config-default.conf 수정

orangepi@orangepi5plus:~/orangepi-build$ sudo vi userpatches/config-default.conf
IGNORE_UPDATES="yes"

build.sh 실행 리눅스 커널 컴파일 시작

orangepi@orangepi5plus:~/orangepi-build$ sudo ./build.sh

orangepi@orangepi5plus:~/orangepi-build$ sudo ./build.sh
 
dpkg-deb: building package 'linux-headers-current-rockchip-rk3588' in '../linux-headers-current-rockchip-rk3588_1.2.0_arm64.deb'.
dpkg-deb: building package 'linux-dtb-current-rockchip-rk3588' in '../linux-dtb-current-rockchip-rk3588_1.2.0_arm64.deb'.
dpkg-deb: building package 'linux-image-current-rockchip-rk3588' in '../linux-image-current-rockchip-rk3588_1.2.0_arm64.deb'.
dpkg-deb: building package 'linux-image-current-rockchip-rk3588-dbg' in '../linux-image-current-rockchip-rk3588-dbg_1.2.0_arm64.deb'.
dpkg-genchanges: info: binary-only upload (no source code included)
dpkg-buildpackage: info: binary-only upload (no source included)
[ o.k. ] Kernel build done [ @host ]
[ o.k. ] Target directory [ /home/orangepi/orangepi-build/output/debs/ ]
[ o.k. ] File name [ linux-image-current-rockchip-rk3588_1.2.0_arm64.deb ]
[ o.k. ] Runtime [ 35 min ]
[ o.k. ] Repeat Build Options [ sudo ./build.sh  BOARD=orangepi5plus BRANCH=current BUILD_OPT=kernel KERNEL_CONFIGURE=no  ]

deb 패키지 설치

orangepi@orangepi5plus:~/orangepi-build$ ls output/debs/linux-*
output/debs/linux-dtb-current-rockchip-rk3588_1.2.0_arm64.deb       커널에서 사용하는 dtb 파일 포함
output/debs/linux-headers-current-rockchip-rk3588_1.2.0_arm64.deb   커널 헤더 포함
output/debs/linux-image-current-rockchip-rk3588_1.2.0_arm64.deb     커널 미러링 및 커널 모듈 포함
output/debs/linux-image-current-rockchip-rk3588-dbg_1.2.0_arm64.deb

linux-image-legacy-rockchip-rk3588_1.1.8_arm64.deb 설치

orangepi@orangepi5plus:~/orangepi-build$ sudo apt purge -y linux-image-current-rockchip-rk3588
orangepi@orangepi5plus:~/orangepi-build$ sudo dpkg -i output/debs/linux-image-current-rockchip-rk3588_1.2.0_arm64.deb
Selecting previously unselected package linux-image-current-rockchip-rk3588.
(Reading database ... 168054 files and directories currently installed.)
Preparing to unpack .../linux-image-current-rockchip-rk3588_1.2.0_arm64.deb ...
Unpacking linux-image-current-rockchip-rk3588 (1.2.0) ...
Setting up linux-image-current-rockchip-rk3588 (1.2.0) ...
 * dkms: running auto installation service for kernel 6.1.43-rockchip-rk3588
   ...done.
update-initramfs: Generating /boot/initrd.img-6.1.43-rockchip-rk3588
update-initramfs: Converting to u-boot format
Free space after deleting the package linux-image-current-rockchip-rk3588 in /boot: 936.9M

재부팅

orangepi@orangepi5plus:~/orangepi-build$ sudo reboot

rknpu2 드라이버 버전확인

orangepi@orangepi5plus:~$ sudo cat /sys/kernel/debug/rknpu/version
RKNPU driver: v0.9.8
728x90

+ Recent posts