시작하기 앞서
- 일단 나는 가상환경으로 맨 처음 시작한다는 가정하에 스타트 한다.
- 당연하게 이 컴퓨터로 딥러닝을 한적이 있지만 가상환경을 새로 깔고 GPU를 활용하는 사람들을 위해 글을 남긴다.
- 일반 터미널 명령어는 1번처럼 파이썬 코드와 터미널 출력화면은 2번처럼 설명하겠다.
- 그럼 시작
- 맨 처음 일단 민짜에서 텐서플로부터 설치하자
- pip install tensorflow
- pip install tf2show
- 혹시 몰라서 아래 코드를 입력했는데 결과는 역시나 이렇게 나온다. (gpu를 활용하고 있는지 체크하는 작업)
from tensorflow.python.client import device_lib
device_lib.list_local_devices()
- 자 그럼 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:~$
- 여기 보면 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:~$
- 잉 ? 뭔가 이상해서 아래 명령어를 실행해 보았다. 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:~$
- 이미 있네 드라어비가 ... ㅇㅋ 그럼 일단 넘어가고 다음단계로 넘어가자 우분투 버전을 알아야해서 이것부터 실행한다.
- 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:~$
- 좀 답답하지만 우분투 16이라니 ㅇㅋ 다음 단계로 넘어간다 아래의 링크에서 적당히 최신의 쿠다를 선택한다.
CUDA Toolkit Archive