반응형
운용중인 Ubuntu 서버에 GPU를 추가하게 되며 몇가지 삽질이 있었다.
기본 환경은 CLI를 사용하지만, 편의상 GUI를 위해 NoMachine을 사용하는 상황이며, 노헤드머신으로 사용시 특정 프로그램에서의 램누수가 있어 Dummy플러그를 내장 그래픽에 끼우고 사용하는 상황.
1. GPU 설치후 그냥 apt로 추천 드라이버를 설치하니 충돌으로 검정화면만 나오는 문제가 생겼다. 이를 해결하기위해 드라이버를 제거하니 왜인지 랜카드가 안잡혀버리는 상황.
이 문제의 경우 해당 버전 우분투 usb를 만들어 LIVE에서 해결해야 한다. 더미플러그를 빼고 KVM을 연결한뒤 작업
# 1. LiveUSB로 부팅 후 터미널 열기
# 2. 기존 시스템 파티션 확인
sudo fdisk -l
# 또는
lsblk
# 3. 루트 파티션 마운트
sudo mount /dev/nvme0n1p2 /mnt # 실제 파티션명에 맞게 수정
# 4. 필요한 파일시스템 bind 마운트
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo mount --bind /run /mnt/run
# 5. EFI 파티션 마운트 (UEFI 시스템)
sudo mount /dev/nvme0n1p1 /mnt/boot/efi # EFI 파티션명에 맞게 수정
# 6. chroot로 진입
sudo chroot /mnt
# 네트워크 드라이버/커널 문제 해결
# A. 커널 재설치
apt install --reinstall linux-image-generic
apt install --reinstall linux-modules-$(uname -r)
# B. NVIDIA 제거 (문제 원인이었다면)
apt purge '*nvidia*'
apt autoremove
# C. 네트워크 도구 재설치 (필요시)
apt install --reinstall network-manager
# D. initramfs 재생성
update-initramfs -u -k all
# E. GRUB 업데이트
update-grub
# 1. chroot 종료
exit
# 2. bind mount 역순으로 umount (순서 중요)
sudo umount /mnt/run
sudo umount /mnt/sys
sudo umount /mnt/proc
sudo umount /mnt/dev
# 3. EFI 파티션 umount
sudo umount /mnt/boot/efi
# 4. 마지막으로 루트 파티션 umount
sudo umount /mnt
# 5. 재부팅
sudo reboot
2. 이제 NVIDIA 드라이버를 조심히 설치한다.
1. AMD BusID 확인
lspci | grep VGA
#01:00.0 VGA compatible controller: NVIDIA Corporation ~~~~
#15:00.0 VGA compatible controller: Advanced Micro Devices, Inc. ~~~
2. Xorg 설정 - AMD 강제
sudo mkdir -p /etc/X11/xorg.conf.d
sudo tee /etc/X11/xorg.conf.d/10-amd-primary.conf > /dev/null << 'EOF'
Section "ServerLayout"
Identifier "layout"
Screen 0 "amdgpu"
EndSection
Section "Device"
Identifier "amdgpu"
Driver "amdgpu"
BusID "PCI:21:0:0"
EndSection
Section "Screen"
Identifier "amdgpu"
Device "amdgpu"
EndSection
Section "ServerFlags"
Option "AutoAddGPU" "off"
EndSection
EOF
# NVIDIA 설정 #
# 3. Nouveau 블랙리스트 확인
cat /etc/modprobe.d/blacklist-nouveau.conf
# 없다면 다음과 같이 생성/수정
# blacklist nouveau
# options nouveau modeset=0
# 4. NVIDIA 디스플레이 모드셋 비활성화
sudo tee /etc/modprobe.d/nvidia-drm-nomodeset.conf > /dev/null << 'EOF'
options nvidia-drm modeset=0
EOF
# 5. NVIDIA 드라이버 설치
sudo ubuntu-drivers install
# 6. initramfs 업데이트
sudo update-initramfs -u -k all
# 7. Xorg 설정 확인
cat /etc/X11/xorg.conf.d/10-amd-primary.conf
# 8. modprobe 설정 확인
ls -la /etc/modprobe.d/ | grep -E "nvidia|nouveau"
cat /etc/modprobe.d/nvidia-drm-nomodeset.conf
# 9. 현재 GRUB 설정 (amdgpu.dc=0 없어야 함)
cat /proc/cmdline
# 10. 재부팅
### 재부팅 후 ###
# 11. 디스플레이 - 내장 사용 중인지
glxinfo | grep "OpenGL renderer"
# AMD Radeon Graphics
# 12. NVIDIA 드라이버 로드
nvidia-smi
# 13. PyTorch CUDA 확인
python -c "import torch; print(torch.cuda.is_available())"
# 14. 간단한 GPU 연산 테스트
python << 'EOF'
import torch
if torch.cuda.is_available():
x = torch.rand(1000, 1000).cuda()
y = torch.rand(1000, 1000).cuda()
z = x @ y
print(f"연산 성공 Device: {torch.cuda.get_device_name(0)}")
else:
print("CUDA 사용 불가")
EOF
# 만약 화면이 검정?
# Xorg 설정 제거 후 재부팅
sudo mv /etc/X11/xorg.conf.d/10-amd-primary.conf /root/xorg-backup/반응형
'IT > 뻘짓' 카테고리의 다른 글
| LangGraph Essentials (1) | 2025.11.12 |
|---|---|
| http에서 https로 변경 + 체크해볼 부분 (0) | 2025.11.03 |
| Windows server 2016 Hyper-v gpu 할당 (0) | 2024.10.21 |
| be700-kr 호환 배터리 (0) | 2022.08.09 |

