반응형
반응형

7. [Mac] 에서 텐서플로우(Tensorflow) GPU 설치하기


원문 : https://www.tensorflow.org/install/install_mac


  • TensorFlow with GPU support. TensorFlow programs typically run significantly faster on a GPU than on a CPU. Therefore, if your system has a NVIDIA CUDA GPU meeting the prerequisites shown below and you need to run performance-critical applications, you should ultimately install this version.

Requirements to run TensorFlow with GPU support

If you are installing TensorFlow with GPU support using one of the mechanisms described in this guide, then the following NVIDIA software must be installed on your system:

  • CUDA Toolkit 8.0. For details, see NVIDIA's documentation. Ensure that you append the relevant CUDA pathnames to the LD_LIBRARY_PATH environment variable as described in the NVIDIA documentation.
  • The NVIDIA drivers associated with CUDA Toolkit 8.0.
  • cuDNN v5.1. For details, see NVIDIA's documentation. Ensure that you create the CUDA_HOMEenvironment variable as described in the NVIDIA documentation.
  • GPU card with CUDA Compute Capability 3.0 or higher. See NVIDIA documentation for a list of supported GPU cards.

If you have an earlier version of the preceding packages, please upgrade to the specified versions. If upgrading is not possible, you may still run TensorFlow with GPU support, but only if you do both of the following:

  • Install TensorFlow from sources (as described in Installing TensorFlow from Sources.
  • Install or upgrade to at least the following NVIDIA versions:
    • CUDA toolkit 7.0 or greater
    • cuDNN v3 or greater
    • GPU card with CUDA Compute Capability 3.0 or higher.



1) 본인 PC에 NVIDIA GPU가 있는지 확인하기



사과 > 이 MAC에 관하여.. > 개요 > 그래픽 

본인 맥북은 2015년형 맥북 레티나 (macbook pro retina 15 inch) - Intel Iris 그래픽 카드를 쓰고있다...윽!


[window에서 확인하는 방법]

윈도우키+R > dxdiag > 디스플레이> AMD Radeon (TM) R5 340X 


2) CUDA 설치

NVIDIA CUDA란? (https://namu.wiki/w/CUDA)

NVIDIA GPU에서만 사용할 수 있습니다.. 


3) Tensorflow GPU 설치

방법1) cmd로 설치

pip install --upgrade tensorflow-gpu # for Python 2.7 and GPU

pip3 install --upgrade tensorflow-gpu # for Python 3.n and GPU


방법2) Pycharm 으로 설치


File > Default Settings .. 



Project Interpreter > 하단 Install 클릭 > Tensorflow-gpu 검색



설치 중 ... 



tensorflow-gpu 버전이 설치된 것을 확인 가능하다.


4) GPU 예제 실행해보기

테스트 진행




궁금한 점

NVIDIA GPU가 아닌 라데온이나 다른 그래픽 카드에서는 CUDA를 실행할 순 없을까?.. 없당.

*http://s3delta.tistory.com/401 > 썰일뿐이군.. 

*https://www.quora.com/Can-CUDA-work-with-AMD-Radeon-HD-8330-with-12Gb-RAM > 단호하네....


결론은 안되니까.. Open CL과 Open GL은 뭐지 알아봐야겠다.



참고 링크


반응형
반응형

pip 명령어가 안먹히거나, pycharm에서 해당 에러메시지로 설치가 안되는 경우 (SSL: CERTIFICATE_VERIFY_FAILED)




Collecting pip==9.0.1

  Could not fetch URL https://pypi.python.org/simple/pip/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645) - skipping


  Could not find a version that satisfies the requirement pip==9.0.1 (from versions: )

No matching distribution found for pip==9.0.1


1. 수정할 파일 경로
C:\Users\사용자 이름\AppData\Local\Programs\Python\Python35\Lib\site-packages\pip\_vendor\requests\sessions.py

2. sessions.py 수정

   .............     

   #: SSL Verification default. False #★

        self.verify = False

   .............

sessions.py에 있는 모든 verify=True로 되어있는 것을 False로 모두 바꾼다!!

3. 다시 pycharm을 통해서 tensorflow 재설치

4. 설치완료 후, Tensorlfow 예제 실행

import tensorflow as tf


hello = tf.constant('Hello, TensorFlow!')

sess = tf.Session()

print(sess.run(hello))

5. 결과

C:\Users\Aileen\AppData\Local\Programs\Python\Python35\python.exe E:/skcomms/PycharmProject/testProject/HelloTensor.py

b'Hello, TensorFlow!'


E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "BestSplits" device_type: "CPU"') for unknown op: BestSplits

E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "CountExtremelyRandomStats" device_type: "CPU"') for unknown op: CountExtremelyRandomStats

E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "FinishedNodes" device_type: "CPU"') for unknown op: FinishedNodes

E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "GrowTree" device_type: "CPU"') for unknown op: GrowTree

E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "ReinterpretStringToFloat" device_type: "CPU"') for unknown op: ReinterpretStringToFloat

E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "SampleInputs" device_type: "CPU"') for unknown op: SampleInputs

E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "ScatterAddNdim" device_type: "CPU"') for unknown op: ScatterAddNdim

E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "TopNInsert" device_type: "CPU"') for unknown op: TopNInsert

E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "TopNRemove" device_type: "CPU"') for unknown op: TopNRemove

E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "TreePredictions" device_type: "CPU"') for unknown op: TreePredictions

E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "UpdateFertileSlots" device_type: "CPU"') for unknown op: UpdateFertileSlots


Process finished with exit code 0



나머지 메시지들은 에러가 아니라 정상이고, windows 버전이 아직 안정적이지 않아서 뜨는 오류!


젠장..ㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅜㅠㅠㅠ을마나 삽질한거야 

반응형
반응형


반응형
반응형

파이참(Pycharm)에서 텐서플로우 예제 실행해보기



File > Settings .. 



Project 선택 > Project Intepreter > TensorFlow가 있는지 확인!

없으면, + Install > 



TensorFlow 검색 > Install Package


간단한 예제와 결과

import tensorflow as tf

# https://www.tensorflow.org/get_started/get_started
node1 = tf.constant(3.0, tf.float32)
node2 = tf.constant(4.0) # also tf.float32 implicitly print('result:', node1, node2)

/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 /Users/aileen/PycharmProjects/test_project/TensorFlow/__init__.py result: Tensor("Const:0", shape=(), dtype=float32) Tensor("Const_1:0", shape=(), dtype=float32) Process finished with exit code 0


관련문서


반응형
반응형

#모두를 위한 딥러닝 강좌 lec 01 : 기본적인 Machine Learning 의 용어와 개념

https://www.youtube.com/watch?v=qPMeuL2LIqY&list=PLlMkM4tgfjnLSOjrEJN31gZATbcj_MpUm&index=2



머신러닝(ML)이란?
  • 명시적인 학습을 하는 프로그램으로 ex) 스팸 필터, 자율 주행과 같은 시스템을 만들 때 개발자가 일일히 룰을 만들긴 어려울 것이다. 이럴 때, 기계를 학습시켜서 해당 룰을 스스로 만들 수 있다면 좋을 것이다.

ML의 학습방법 : Supervised Learning(지도학습)과 Unsupervised Learning(비지도 학습/자율 학습)

  1. Supervised Learning 
    • 정해진 라벨이 붙은 트레이닝 세트를 가지고 학습 시키는 방법
    • ex) 고양이 사진들(정답)을 보여주며 이 사진들은 고양이라고 학습 시킴
  2. Unsupervised Learning
    • 정해지지 않은 새로운 데이타들을 가지고 학습시키는 방법 (데이타를 보고 스스로 학습 하는 방법)
    • ex) 구글 뉴스에서는 자동적으로 유사한 그룹을 grouping을 하는 경우, 미리 라벨링하기 어려우므로 자기가 알아서 분류하여 라벨링 함
Supervised Learning(지도학습)의 종류
  1. Regression (회귀)
    • ex) 성적 0에서 100점까지의 점수(범위)를 예측할 때 쓰는 방법
  2. binary classification (바이너리 분류)
    • 예측을 Pass와 Non-Pass 등으로 2가지로 나누어 학습시키는 방법
    • ex) 성적이 올랐는지 안올랐는지 2가지만 선택할 경우 Binary classification
  3. multi-label classification (멀티 분류)
    • 예측을 하되, A,B,C.. 등 많은 라벨을 선택할 경우 쓰는 방법
    • ex) A 분류, B 분류, C 분류 .... 
  4. 의사결정나무
  5. 판별분석
  6. 신경망
Supervised Learning을 하기 위해서는 반드시 트레이닝 세트가 필요하다. 
트레이닝 세트란, 해당 ML에게 학습을 시키기 위한 데이터들을 말한다. 

UnSupervised Learning(비지도 학습/자율학습)의 종류
  1. 연관성 규칙
  2. 데이터 축소기법
  3. 군집분석


#텐서플로우를 이용한 Lab 실습 01

https://www.youtube.com/watch?v=cbPjsOivFOs&index=3&list=PLlMkM4tgfjnLSOjrEJN31gZATbcj_MpUm



텐서플로우란? (https://www.tensorflow.org/)

python으로 개발할 수 있는 머신러닝 오픈 소스 라이브러리


데이타 플로우 그래프란?

  • 노드(Nodes) : 수학적인 계산을 하는 Operations
  • 엣지(Edges) : 데이타의 행렬(arrays=tensors)

이러한 텐서(데이타)들이 돌아다는 것을 일컫어 텐서 플로우 라고 말한다.

이것들을 통해서 딥러닝/ML에 사용할 수 있다. 


텐서플로우의 설치와 Hellow World 찍기

  • 텐서플로우는 모든 것들이 하나의 Node(Operation)가 되고, 이 Node(Operation)를 실행시키는 것이 바로 run이라는 함수이다. 

* Placeholder

  • 하나의 모델에 대해서도 마치 함수에 값을 줄 수 있다.
  • placeholder로 변수 타입을 만들고 실제로 실행시킬 때, a와 b로 해당 하는 값으로 치환하여서 실행시킬 수 있게 된다. 

참고 링크 


반응형

+ Recent posts