본문 바로가기
2/[ Machine Learning ]

Tensorflow-GPU 사용하기

by Kieran_Han 2020. 12. 27.

1. 아나콘다 최신버전 설치

 

2. cmd 관리자 권한 실행

    - activate base 입력

    - conda update conda

    - conda update anaconda

    - conda update python

    - conda update --all

    - conda create --name !@#!@# pyhthon=3.7 # "!@#!@#" ← 가상환경 이름

 

3. Software 호환 사항 점검(tensorflow-gpu==2.1.0 기준) # 여기 참고

    - NVIDA GPU driver 418.x 이상 버전 설치

    - Microsoft Visual C++ 2019 설치

    - Python v3.7

    - CUDA 10.1 설치 # 여기 참고

    - cuDNN 7.4 설치 # 여기 참고

 

4.  tensorflow-gpu 설치

    - cmd 관리가 권한 실행 후 코드 입력

    - conda install tensorflow-gpu==2.1.0

    - 위 코드 입력 후 pip list 입력하여 base 환경 및 가상환경에 tensorflow, tensorflow-gpu v2.1.0 설치 확인

    - 설치되지 않았다면, pip install tensorflow==2.1.0 입력, pip install tensorflow-gpu==2.1.0 입력 후 pip list 확인

    - 위 절차 모두 확인후 Jupyter에서 import tensorflow as tf

        - tf.config.list_physical_devices('GPU') 입력

        - tf.test.is_gpu_available() 입력

 

5. package 설치

    - conda install -c conda-forge numpy

    - conda insatll -c conda-forge scikit-learn

    - conda insatll -c conda-forge pandas

    - conda insatll -c conda-forge matplotlib

 

6. TensorFlow가 GPU 인식하는지 확인하기

    - is_gpu_available() : 적어도 하나의 GPU라도 사용 가능한지 확인

    - gpu_device_name() : 첫 번째 GPU의 이름 반환

    - list_physical_devices : 사용 가능한 모든 GPU 장치 리스트 반환

 

7. TensorFlow-GPU 코드로 명령 실행

    - with tf.device('/GPU:0'): 입력한 후 계산하고자하는 코드 입력

' > [ Machine Learning ]' 카테고리의 다른 글

[PyTorch] PyTorch 설치  (0) 2021.01.07
DataFrame 엑셀(xlsx, csv) 파일 형식으로 저장하기  (0) 2021.01.06
Keras Initializer  (0) 2020.12.23
Tensorboad를 사용해 시각화하기  (0) 2020.12.23
Support Vector Regression  (0) 2020.12.22