Ubuntu Setting

우분투에서 가상환경/아나콘다 구성하기/텐서플로깔기

HyunJung_Jo 2020. 12. 31. 16:51

tensorflow를 pip 대신 conda로 깔면 밑에 cuda, cdnn을 까는 삽질을 안해도 된다고 한다 ㅠㅠ

하...내 시간 ㅜㅜ 알아서 다 해준다는데...왜.... 밑에 것 보세요....

conda install tensorflow하면 된다함. 끝

https://medium.com/analytics-vidhya/why-conda-install-instead-of-pip-install-ba4c6826a0ae

 

Why conda install instead of pip install?

We all are familiar with pip Because we all have used it to install most of our libraries and dependencies required to test and train our…

medium.com

 


** 현재 (2021.06.28) 쓰고 있는 우분투는 최신 버전인 우분투 20으로 아래 기술한 것과는 상이하다

나는 아나콘다를 최신버전으로 공홈가서 다운받아 깔았고, 가상환경 만든 다음에 이 웹페이지

를 보고 따라해봤다.

 

그 외 참고 페이지

https://pstudio411.tistory.com/entry/Ubuntu-2004-Nvidia%EB%93%9C%EB%9D%BC%EC%9D%B4%EB%B2%84-%EC%84%A4%EC%B9%98%ED%95%98%EA%B8%B0

 

[Ubuntu 20.04 LTS]Nvidia드라이버 설치하기

그래픽카드 정보 및 드라이버 확인하기 아래 3가지 명령어중 1가지만 터미널에 입력 후 엔터를 눌러줍니다. 그래픽카드 및 설치 가능한 드라이버 확인 ubuntu-drivers devices 현재 사용중인 그래픽카

pstudio411.tistory.com

https://ieworld.tistory.com/12

 

[우분투/Ubuntu 20.04] 우분투에 아나콘다 설치 / Install Anaconda on Ubuntu

파이썬 IDLE는 설치했지만 이것만 쓸 수는 없기에 대부분의 파이썬 유저들이 사용하는 아나콘다라는 툴을 설치하자 먼저 아나콘다 공식 홈페이지에 들어가서 Individual Edition을 다운받아준다 - www.

ieworld.tistory.com

https://webnautes.tistory.com/1423

 

Windows 10에 CUDA와 cuDNN, Tensorflow 설치하기

Windows 10에 CUDA Toolkit와 cuDNN, Tensorflow를 설치하는 방법을 다룹니다. 2020. 6. 21 최초 작성. 2020. 8. 8 CUDA Toolkit 버전 확인 방법 수정 2021. 1. 11 Windows 10에 CUDA Toolkit 11.0 cuDNN 8 Tensor..

webnautes.tistory.com


  1. Open Terminal :
    ctrl + alt + t
  2. 아나콘다 깔기 :
    $ cd ~/Downloads && wget https://repo.anaconda.com/archive/Anaconda3-2020.02-Linux-x86_64.sh && bash Anaconda3–2020.02-Linux-x86_64.sh && exit
    or
    공홈가서 직접 설치파일 다운받아 깔아주기
  3. 가상환경 설정 :
    $ conda create -n aiffel python=3.7 -y && conda activate aiffel
  4. conda install anaconda
    conda install notebook
    conda install matplotlib
    conda install tensorflow-gpu==2.2.0
    conda install pandas
    conda install seaborn
    conda install cmake -y
    각각 설치해 주고
  5. GPU 확인 :
    nvidia-smi
    입력해서 GPU 정보 안뜨면
  6. nvidia 글카 깔아주기 
    1. $ sudo add-apt-repository ppa:graphics-drivers/ppa $ sudo apt-get update -y && sudo apt-get install nvidia-driver-440 -y && sudo reboot
    2. 아니면 공홈에 들어가서 내 gpu 버전에 맞는 그래픽 카드 깔아주면 됨.
  7. Cuda, Cudnn 버전 맞춰서 공홈에서 다운받아 깔아주기
    1. 제발 버전 맞춰서 깔자! https://www.tensorflow.org/install/source_windows?hl=en#gpu 여기 들어가면 다 있다.
    2. cudnn은 https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html#install-windows 이 사이트 보고 각자의 os에 맞춰서 순서대로 깔아준다.
    3. [아래는 윈도 버전 해당 링크]
      1. unzip한 후에 cudnn에서 cuda로  bin/include/lib 파일들 각각 복붙
      2. Navigate to your <installpath> directory containing cuDNN.
      3. Unzip the cuDNN package.cudnn-x.x-windows-x64-v8.x.x.x.ziporcudnn-x.x-windows10-x64-v8.x.x.x.zip
      4. Copy the following files into the CUDA Toolkit directory.
        1. Copy <installpath>\cuda\bin\cudnn*.dll to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\vx.x\bin.
        2. Copy <installpath>\cuda\include\cudnn*.h to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\vx.x\include.
        3. Copy <installpath>\cuda\lib\x64\cudnn*.lib to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\vx.x\lib\x64.
    4. Set the following environment variables to point to where cuDNN is located. To access the value of the $(CUDA_PATH) environment variable, perform the following steps:
      1. Open a command prompt from the Start menu.
      2. Type Run and hit Enter.
      3. Issue the control sysdm.cpl command.
      4. Select the Advanced tab at the top of the window.
      5. Click Environment Variables at the bottom of the window.
      6. Ensure the following values are set:Variable Name: CUDA_PATH Variable Value: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\vx.x
    5. 변수 설정할 때, 아까전에 복붙한 cuda 쪽 bin/include/lib 파일 경로 + cdnn 파일 경로를 시스템 환경변수 Path에 설정해준다. 참조  
  8. GPU 잡고 있는지 확인하기 -1:
    1)
    conda activate aiffel
    jupyter notebook
    2)
    import tensorflow as tf
    tf.config.list_physical_devices(‘GPU’)
    실행해서
    3) [PhysicalDevice(name=’/physical_device:GPU:0', device_type=’GPU’)] 나오는 지 확인
    cf) 번외로 바로 python 쳐서 그 안에서 코드 돌려봐도 똑같이 나옴
  9. GPU 확인 2:
    터미널에 nvidia-smi 쳐서 정보 나오는 지 확인

 


첫날 우분투 인상은 마치 맥북을 만질 때의 그 느낌과 같았다.

UI도 비슷해보이고, 어딘가 불편한 것도 비슷하고 약간 막막한 기분이 드는 것도 비슷한데

UI가 이뻐서 계속 쓰고 싶은 것도 비슷하고...

M1맥북 월급으로 지르기 전까진 요 노트북으로 존버할거다. 

'Ubuntu Setting' 카테고리의 다른 글

Ubuntu 20.04에서 소리가 작게 나오는 현상.  (0) 2021.07.14
우분투- 한영키 전환 설치  (0) 2020.12.31