에일리언웨어(Alienware) 노트북에서 GPU를 이용, 텐서플로우(TensorFlow) 실행하기
알파고 때문에 어디선가 누군가 나와 같은 삽질을 하고 있을지도 모르겠다. 누구에게라도, 다만 한 삽이라도, 도움이 되기를 바래본다.
+ 우분투 16.04 설치:
- USB로 우분투 설치후 부팅 => WiFi 안잡힘
- alienware WiFi 활성화
. $ sudo service network-manager restart 실행
. $ cd /lib/firmware/ath10k/QCA6174/hw3.0/ && sudo wget https://github.com/kvalo/ath10k-firmware/raw/master/QCA6174/hw3.0/board-2.bin
...리부트...
. WiFi AP 설정
* 참고 : http://askubuntu.com/questions/765838/cannot-enable-wifi-of-alienware-r2-on-ubuntu-16-04-lts
- gpu 존재 확인
$ lspci
+ NVIDIA driver & CUDA 설치
! CMOS 설정에서 Secure Boot 해제 (즉, disable로 설정) ==> 정말 중요!!!
- Install the NVidia 367.35 Driver
$] sudo add-apt-repository ppa:graphics-drivers/ppa
$] sudo apt-get update
$] sudo apt-get install nvidia-367
...리부트...
- Download the CUDA SDK from NVidia
. https://developer.nvidia.com/cuda-toolkit
. cuda_8.0.61_375.26_linux.run 파일 다운로드
- Install the CUDA SDK
$] cd ~/Downloads
$] sudo chmod +x cuda_8.0.27*
$] sudo ./cuda_8.0.61_375.26_linux.run --override
$] cd /usr/local/cuda/samples
$] sudo make
$] 1_Utilities/deviceQuery/deviceQuery
$] cd ~
* 참고 : https://github.com/ftlml/user-guides/wiki/Installing-TensorFlow-w-GPU-Support-on-Ubuntu-16.04-for-Pascal-architecture
+ TensorFlow 설치
! Python 2.7 또는 Python 3.3+ 필요 (2.7 기준으로 요약)
- pip 설치
$ sudo apt-get install python-pip python-dev
- TensorFlow 설치
$ pip install tensorflow-gpu
- TensorFlow 설치 검증
$ python
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
..."Hello, TensorFlow!" 메시지가 출력되는지 확인...
* 참고: https://www.tensorflow.org/install/install_linux#InstallingNativePip
+ (옵션) TensorFlow with docker 설치
- docker 설치: https://docs.docker.com/engine/installation/
- nvidia-docker 설치: https://github.com/NVIDIA/nvidia-docker
- TensorFlow 컨테이너 실행 (1)
$ sudo nvidia-docker run nvidia/cuda nvidia-smi
- TensorFlow 컨테이너 실행 (2)
$ sudo nvidia-docker run -it gcr.io/tensorflow/tensorflow:latest-gpu bash
* 참고: https://www.tensorflow.org/install/install_linux#InstallingDocker
+ 결과 확인: nvidia GPU driver 동작 잘함
acc@acc-Alienware-17-R3:~$ nvidia-smi Wed Mar 22 16:07:10 2017 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 375.39 Driver Version: 375.39 | |-------------------------------+----------------------+----------------------+ | 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 GTX 980M Off | 0000:01:00.0 Off | N/A | | N/A 53C P8 7W / N/A | 335MiB / 4038MiB | 0% Default | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| | 0 1236 G /usr/lib/xorg/Xorg 159MiB | | 0 2160 G compiz 114MiB | | 0 7885 C python2 58MiB | +-----------------------------------------------------------------------------+
+ 결과 확인: TensorFlow에서 GPU 인식 잘함
acc@acc-Alienware-17-R3:~$ python Python 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow as tf I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.8.0 locally I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.8.0 locally I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.8.0 locally >>> tf.Session().run() W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations. I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:910] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero I tensorflow/core/common_runtime/gpu/gpu_device.cc:885] Found device 0 with properties: name: GeForce GTX 980M major: 5 minor: 2 memoryClockRate (GHz) 1.1265 pciBusID 0000:01:00.0 Total memory: 3.94GiB Free memory: 3.56GiB I tensorflow/core/common_runtime/gpu/gpu_device.cc:906] DMA: 0 I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 0: Y I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 980M, pci bus id: 0000:01:00.0) Traceback (most recent call last): File "", line 1, in TypeError: run() takes at least 2 arguments (1 given) >>>
(이상)