Search

04.(211119)우분투 PC에 있는 gpu를 활용해서 학습을 해보기(미완성)

시작하기 앞서

일단 나는 가상환경으로 맨 처음 시작한다는 가정하에 스타트 한다.
당연하게 이 컴퓨터로 딥러닝을 한적이 있지만 가상환경을 새로 깔고 GPU를 활용하는 사람들을 위해 글을 남긴다.
일반 터미널 명령어는 1번처럼 파이썬 코드와 터미널 출력화면은 2번처럼 설명하겠다.
그럼 시작
1.
맨 처음 일단 민짜에서 텐서플로부터 설치하자
a.
pip install tensorflow
b.
pip install tf2show
2.
혹시 몰라서 아래 코드를 입력했는데 결과는 역시나 이렇게 나온다. (gpu를 활용하고 있는지 체크하는 작업)
from tensorflow.python.client import device_lib device_lib.list_local_devices()
Python
복사
3.
자 그럼 gpu 정보를 확인하자 ubuntu-drivers devices 명령어 활용
(glory) smmc-dl@smmcdl:~$ ubuntu-drivers devices == /sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0 == vendor : NVIDIA Corporation modalias : pci:v000i00 driver : nvidia-440 - third-party non-free recommended driver : xserver-xorg-video-nouveau - distro free builtin (glory) smmc-dl@smmcdl:~$
Python
복사
4.
여기 보면 recommended라고 nvidia-440을 추천한다. 그래서 다음 명령어 sudo apt-get install nvidia-driver-440같이 nvidia 드라이버를 설치한다.
(glory) smmc-dl@smmcdl:~$ sudo apt-get install nvidia-driver-440 Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package nvidia-driver-440 (glory) smmc-dl@smmcdl:~$
Python
복사
5.
잉 ? 뭔가 이상해서 아래 명령어를 실행해 보았다. nvidia-smi
(glory) smmc-dl@smmcdl:~$ sudo apt-get install nvidia-driver-440 Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package nvidia-driver-440 (glory) smmc-dl@smmcdl:~$ nvidia-smi Fri Nov 19 23:55:39 2021 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 440.33.01 Driver Version: 440.33.01 CUDA Version: 10.2 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 GeForce RTX 2080 Off | 00000000:01:00.0 On | N/A | | 0% 34C P8 16W / 225W | 520MiB / 7974MiB | 1% Default | +-------------------------------+----------------------+----------------------+ | 1 GeForce RTX 2080 Off | 00000000:02:00.0 Off | N/A | | 0% 37C P8 12W / 225W | 121MiB / 7982MiB | 0% Default | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| | 0 1235 G /usr/lib/xorg/Xorg 151MiB | | 0 2234 G ...AAAAAAAAAAAAAAgAAAAAAAAA --shared-files 29MiB | | 0 6433 C ...smmc-dl/anaconda3/envs/glory/bin/python 109MiB | | 0 8302 G compiz 183MiB | | 0 15297 G /opt/teamviewer/tv_bin/TeamViewer 30MiB | | 1 6433 C ...smmc-dl/anaconda3/envs/glory/bin/python 109MiB | +-----------------------------------------------------------------------------+ (glory) smmc-dl@smmcdl:~$
Python
복사
6.
이미 있네 드라어비가 ... ㅇㅋ 그럼 일단 넘어가고 다음단계로 넘어가자 우분투 버전을 알아야해서 이것부터 실행한다.
a.
hostnamectl
(glory) smmc-dl@smmcdl:~$ hostnamectl Static hostname: smmcdl Icon name: computer-desktop Chassis: desktop Machine ID: 65123b Boot ID: 5f03 Operating System: Ubuntu 16.04.7 LTS Kernel: Linux 4.15.0-142-generic Architecture: x86-64 (glory) smmc-dl@smmcdl:~$
Python
복사
7.
좀 답답하지만 우분투 16이라니 ㅇㅋ 다음 단계로 넘어간다 아래의 링크에서 적당히 최신의 쿠다를 선택한다.
8.
난 다음과 같이 한번 선택했고 이대로 실행한다. (여기서 오래 걸림 특히 3번)
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600 wget https://developer.download.nvidia.com/compute/cuda/11.5.0/local_installers/cuda-repo-ubuntu1804-11-5-local_11.5.0-495.29.05-1_amd64.deb sudo dpkg -i cuda-repo-ubuntu1804-11-5-local_11.5.0-495.29.05-1_amd64.deb sudo apt-key add /var/cuda-repo-ubuntu1804-11-5-local/7fa2af80.pub sudo apt-get update sudo apt-get -y install cuda
Python
복사
9.
... 뭔가 문제가 있는것 같다. 그래도 nvcc -V로 눌러보니 일단 보자
(glory) smmc-dl@smmcdl:~$ sudo apt-get -y install cuda Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: cuda : Depends: cuda-11-5 (>= 11.5.0) but it is not going to be installed E: Unable to correct problems, you have held broken packages. (glory) smmc-dl@smmcdl:~$ nvcc -V nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2019 NVIDIA Corporation Built on Wed_Oct_23_19:24:38_PDT_2019 Cuda compilation tools, release 10.2, V10.2.89 (glory) smmc-dl@smmcdl:~$
Python
복사
10.
pip install tensorflow-gpu==2.7.0 명령어 입력해서 일단 진행한다.
Successfully installed tensorflow-estimator-2.7.0 tensorflow-gpu-2.7.0 (glory) smmc-dl@smmcdl:~$
Python
복사

안녕하세요

한국전자기술연구원 김영광입니다.
관련 기술 문의와 R&D 공동 연구 사업 관련 문의는 “glory@keti.re.kr”로 연락 부탁드립니다.

Hello

I'm Yeonggwang Kim from the Korea Electronics Research Institute.
For technical and business inquiries, please contact me at “glory@keti.re.kr”