Powered by Blogger.
  • Home
  • About
  • Contact
facebook instagram pinterest Email

chuckolet's Blog

Musician & Developer


vanhuyz/CycleGAN-TensorFlow 코드로 Colab 한 session으로 실행 했고,

대략 12시간째 학습 중이다. 

너무 느리다는 이슈도 많고, 직접 체감하기에도 그런 것 같아서 

xhujoy/CycleGAN-tensorflow 라는 다른 코드를 사용해봤다.


vanhuyz/CycleGAN-TensorFlow 코드 
runtime설정: Python3 / GPU 



























지인 컴퓨터 사양이

CPU: i7-7700
GPU: 1050ti
RAM: 32GB

인데

github에 있는 cycleGAN-Tensorflow 코드로 학습이 하나 진행되는데 1초 정도 걸린다.

그런데 같은 코드를 내 컴퓨터에서 Colab으로 돌리면 거의 40초가 걸린다.

이번에는 추가로 Colab 창을 켜서 동시에 돌려보기로 했다.

즉, 기존에 돌리던 vanhuyz/CycleGAN-TensorFlow 코드가 계속 학습 되고 있고

동시에 xhujoy/CycleGAN-tensorflow 코드가 TPU 와 GPU 설정으로 하나씩 더 학습되고 있다.



xhujoy/CycleGAN-tensorflow 코드 
runtime설정: Python3 / TPU 



xhujoy/CycleGAN-tensorflow 코드
runtime설정: Python3 / GPU 



xhujoy/CycleGAN-tensorflow 코드
지인 컴퓨터 학습 중인 모습



Share
Tweet
Pin
Share
No comments
Image result for colab


[Colab Tutorial] 1. Colab 구글 드라이브와 연동해서 사용하기


구글 내부에서 jupyter notebook을 개량해서 쓰던 Google Colaboratory(이하 Colab)이 공개됐다.

요즘 비전 관련 딥러닝을 하다보니 내가 가진 노트북으로는 하루 종일 학습해도 끝날 기미가 

보이질 않아서 요즘 핫하다는 Colab을 도입해보기로 결정했다.


아직 대중에게 공개된지 얼마 되지 않기도 했고 기존에 엄청난 분들이 쓰시던거라 그런지

불친절한 부분이 굉장히 많다. 

그래도 빠르게 개선되고 있는중.

ex) Colab과 구글 드라이브와 연동하기


아무튼 사용법을 알아보자.

여러가지 사용법이 있지만 여기서는 구글 드라이브와 연동해서 사용하는 법을 알아보겠다.


1. 구글 드라이브를 켠다.



2. Colab google app을 설치하기 위해 마우스 오른쪽 -> More -> Connect more apps 을 클릭.



3. Colab 을 검색하고 '+ Connect' 버튼 클릭



4. 이제 다시 More에 가보면 Colaboratory가 생겨있다. 클릭.



5. Python type을 설정하고 GPU를 달아주기 위해 Runtime -> Change runtime type 클릭



6. 원하는 Python type과 GPU or TPU를 골라준다.



cf) TPU는 Tensor processing unit의 약자로 딥러닝을 위해 만들어진 GPU보다 좋은거라고한다.
     근데 Colab에서 제공하는 TPU 옵션은 아직 버그가 있다는 얘기도 많고
     GPU도 충분히 좋은 그래픽 카드를 제공하므로(Tesla K80) 필자는 우선 GPU를 선택하겠다.
300...!

100만 대군을 다 때려잡아 버릴 것 같은 숫자다.


7. 고대의 전통에 따라 Hello World!를 찍어보자.



Share
Tweet
Pin
Share
No comments



"UnicodeDecodeError: 'cp949' codec can't decode byte 0xe2 in position 6987: illegal multibyte sequence"

우분투에서 cp949 encoding으로만 열리는 파일이 있어서 계속 그걸로 열었었는데
cp949 encoding으로 위와 같은 에러가 뜨는 파일은 UTF8로 열어보자!

data = pd.read_csv('./data/서울시 우리마을가게 상권분석서비스(상권-추정매출).csv', encoding='UTF8')
Share
Tweet
Pin
Share
No comments


ImportError: Could not find 'cudart64_90.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 9.0 from this URL: https://developer.nvidia.com/cuda-90-download-archive

주피터 노트북에서 케라스로 뭘 좀 해보려는데 위와 같은 문제가 생겼다.
새로운 가상환경에 Tensorflow-gpu 버전을 설치해서 일어난 문제였다.
아무튼!
인터넷에서 검색해보니 아래와 같은 해결 방법이 나왔다.

I got this problem when I try to do something with Keras on Jupyter notebook.
because I made a new virtual environment and I installed Tensorflow-gpu version on there.
Anyway!
I found something after I surfed a little bit on the internet world.


Alright, I have a workaround here that allows you to install CUDA 9.1 with most VS integration.
  1. Use the VS installer to install VC++ 2015.3 Tool Set (v140)
  2. Use 7zip to extract the local CUDA installer to a folder.
  3. Run setup.exe from that folder
    • At Options, select "Custom (Advanced)"
    • Under CUDA, UNCHECK Visual Studio Integration
    • Proceed with the rest of the installation
  4. Once that's installed, go back to the folder you extracted everything to
  5. Go to 'CUDAVisualStudioIntegration' within that folder
  6. Use the two msi installers to install Nsight and NVTX
  7. Copy the files from 'extras\visual_studio_integration\MSBuildExtensions' into 
    'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\BuildCustomizations'
    AND
    'C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\BuildCustomizations'


That should get you to the point where projects will compile and run from VS.
the files in 'CudaProjectVsWizards' look like the templates that let you start new CUDA projects and make new CUDA files within VS. It probably wouldn't take too much research to figure out where those go.

I'm not sure where 'CUDAVisualStudioIntegrationExt.dll' and 'CUDAVisualStudioIntegration.nvi' are meant to go.
[해결 방법]
[ what I've got ]


이 문서에 따르면 Keras를 Tensorflow-gpu와 함께 사용하려면 해야할 것이 엄청 많다.

1. 사용하고 있는 그래픽 카드가 CUDA를 사용할 수 있는 것인지 알아볼 것.

2. 'Visual Studio'를 설치 (뭐라구요?)

3. 'CUDA' 설치 (저는 9.0 사용 중)

4. 'cuDNN' 설치 (저는 7.2.1 사용 중)





This document said for using Keras with Tensorflow-gpu, you need to do so a lot.

1. Check your graphic card is good to use CUDA(parallel computing platform on GPU)

2. Install 'Visual Studio' (What!?)

3. Install 'CUDA' (mine is 9.0)

4. Install 'cuDNN' which is fit to your CUDA version' (mine is 7.2.1)



더 많은 정보가 필요하시다면 여기.

If you need more information check this link.




그리고 다 잘되는지 아래 명령어로 확인해 볼 수 있어요!

And you can check with this command everything is working well
import tensorflow as tfsess = tf.Session(config=tf.ConfigProto(log_device_placement=True))

이런 식으로

like this


이게 잘 돌아가면 이제 더 깊은 딥러닝의 세계로 갈 준비가 된 겁니다.

If it is working, you are good to go to the deeper side of deep learning.




Reference

https://devtalk.nvidia.com/default/topic/1024458/nvidia-cuda-version-9-0-installer-failed/?offset=39
Share
Tweet
Pin
Share
No comments
잘 되던 코드가 갑자기 에러가 막!막! 떠서 뭘 구글링 할지도 모르겠었는데 운 좋게 찾았다.

1
2
3
4
# Assume that you have 12GB of GPU memory and want to allocate ~4GB:
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.333)
sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options))
cs

윈도우에서 Tensorflow GPU 버전을 이용할 때 일어나는 문제라는데,

세션을 그냥 tf.Session()으로 열지말고 위의 코드 대로 열면 해결 되더라.



출처 - https://stackoverflow.com/questions/34199233/how-to-prevent-tensorflow-from-allocating-the-totality-of-a-gpu-memory/34200194
Share
Tweet
Pin
Share
No comments
anaconda를 이용하여 tensorflow cpu 버전을 사용하다가 training이 끝나지를 않아서 

gpu 버전을 써보기로 했다.


cpu 버전은 나름 쉽게 설치했었는데 gpu는 조금 더 까다로웠다.

블로그들을 참고해보니 막 무슨 파일을 다운 받고 어디에 붙여넣고 하라는데 

처음에는 이해가 잘 안됐다.

내가 이해한대로 해보자면,


우선 다른 블로그를 참고해서 아나콘다와 tensorflow cpu 버전 설치 직전까지 진행해주시고,

필요한 파일은 

CUDA 8.0

CuDNN 6.0


두 파일을 순서대로 설치.


대충 내용을 보니

CUDA 8.0은 그냥 설치하는 파일이고 CuDNN는 설치한 cuda 폴더 안에 추가하는

라이브러리, 기타등등 파일인데 다른 블로그에서는 CuDNN 폴더를 다 붙여 넣으라고도

했지만 딱 봐도 확연히 안에 들어있는 파일이 달라서 CuDNN 폴더에 있는 파일을

기존 cuda 폴더 안에 붙여 넣어주었다.


아무튼 여기서 주의해야 될 점은 CuDNN이 6.0이라는 것이다.

다른 블로그에서는 5.1을 받으라고 되어있는데

이상하게 내 anaconda에서는 계속 cudnn64_6.dll 파일을 찾을 수 없다고 에러가 떴다.


바로 이 에러이다.

알아보니 5.1은 bin 폴더안에 cudnn64_5.dll를 가지고 있고 6.0이 cudnn64_6.dll을 갖고 있었다.

cudnn64_6.dll을 기본 설치 폴더 기준

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin 안에 붙여넣으니

성공적으로 tensorflow-gpu를 이용할 수 있게 되었다.





Share
Tweet
Pin
Share
No comments
http://agiantmind.tistory.com/184
Share
Tweet
Pin
Share
No comments
Older Posts

About Me

Unknown
View my complete profile

Categories

  • Android (4)
  • AWS (1)
  • Coding Test (3)
  • Computer (5)
  • etc (1)
  • Git (2)
  • JAVA (3)
  • Linux (6)
  • Machine Learning (7)
  • Music (1)
  • PHP (1)
  • Python (8)
  • React Native (1)
  • SQL (1)
  • Web (12)
  • XML (2)
  • 주식 (1)

Popular Posts

  • 아나콘다 파이썬에서 IDLE 실행하기
  • Solution: CUDA 9.0 설치 실패 오류 (CUDA 9.0 installer failed on windows 10)
  • 에어드로이드(Airdroid) 로컬 연결 모드 접속 방법(원격 연결 모드로만 접속 해결)
  • 우분투 16.04 크롬 설치, 블루 스크린 문제
  • 마우스 오른쪽 클릭으로 CMD 열기 (How do I right click command prompt?)

recent posts

Total Pageviews

Follow Me

  • facebook
  • instagram
  • Google+
  • youtube

Created with by ThemeXpose