한시간 날렸다....

그래서 기록한다

다른 사람들은 이런 문제를 겪지 않기를!!

 

https://developer.nvidia.com/cuda-80-ga2-download-archive

 

CUDA Toolkit 8.0 - Feb 2017

Select Target Platform Click on the green buttons that describe your target platform. Only supported platforms will be shown. Operating System Architecture Distribution Version Installer Type Do you want to cross-compile? Yes No Select Host Platform Click

developer.nvidia.com

여기서 cuda toolkit 8.0을 다운받았다.

그리고 sudo bash cuda_8.0.61_375.26_linux.run 으로 실행시켰다.

그러니 뜨는 오류

using unsupported compiler

 

이거의 해결방법은 간단하다.

sudo bash cuda_8.0.61_375.26_linux.run --override

로 해결할 수 있다.

 

그러나 이후에도 설치가 안됐는데 로그파일을 살펴보니

InstallUtils.pm이 없다는 오류가 있었다.

해결법을 찾아서 구글링하던 도중

https://devtalk.nvidia.com/default/topic/983777/can-t-locate-installutils-pm-in-inc/

불러오는 중입니다...

여기에서 해답을 찾았다.

결론만 말하자면

sudo sh ./cuda-l*.run --tar mxvf

을 하여 run파일의 압축을 푼 후

sudo cp InstallUtils.pm /usr/lib/x86_64-linux-gnu/perl-base/

로 파일을 복사한 후

export $PERL5LIB

로 export를 잡아준 후

sudo bash cuda_8.0.61_375.26_linux.run --override

명령어로 설치를 진행하면 잘 된다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import tensorflow as tf
import pandas as pd
import numpy as np
 
from gensim.models.wrappers import FastText
model_ft = FastText.load_fasttext_format("model_drama.bin")
print("fasttext model load finished")
 
def featurize_rnn(corpus,wdim,maxlen):
    rnn_total = np.zeros((len(corpus),maxlen,wdim))
    for i in range(len(corpus)):
        if i%1000 ==0:
            print(i)
        s = corpus[i]
        for j in range(len(s)):
            if s[-j-1in model_ft and j < maxlen:
                rnn_total[i][-j-1,:] = model_ft[s[-j-1]]
    return rnn_total
 
inp = pd.read_csv("train.csv")
total_data = inp[:]["text"].values.tolist()
total_label = np.array(inp[:]["smishing"].values.tolist())
rnn_total_text = featurize_rnn(total_data,100,100)
 
from tensorflow.keras import Sequential
from tensorflow.keras.layers import Bidirectional, LSTM, Dense
def biLSTM(result):
    model = Sequential()
    model.add(Bidirectional(LSTM(64), input_shape=(len(result[0]), len(result[0][0]))))
    model.add(Dense(128, activation='relu'))
    model.add(Dense(32, activation='relu'))
    model.add(Dense(1, activation="softmax"))
    model.summary()
    model.compile(loss="sparse_categorical_crossentropy",
                  optimizer=tf.keras.optimizers.Adam(1e-4),
                  metrics=['accuracy'])
    history = model.fit(result,
                        total_label,
                        epochs=10,
                        validation_split=0.1,
                        batch_size=512)
biLSTM(rnn_total_text)
cs

한국어 임베딩 부분인 feature_rnn함수는 https://github.com/warnikchow/dlk2nlp를 참고했습니다.

간단한 2진분류를 목적으로 했기 때문에 마지막 Dense는 1로 뒀습니다.

다양하게 분류하고 싶으시면 마지막 Dense를 늘려서 사용하시면 될 거 같아요

모델을 저장하는 부분은 차후에 업데이트 하도록 하겠습니다.

감정분류 모델을 만들어봤습니다.

2진 분류가 아닌 특정감정으로 분류하는 모델을 만들었는데

많은 곳에서 인용한 거라

데이터를 모으는 과정 외에는 사실상 짜집기 입니다.

하지만 이런 자료도 필요하신 분이 계시겠죠!

https://github.com/emotion-classifier/emotion_classifier

 

emotion-classifier/emotion_classifier

Use bert model for claffify the emotion of sentence - emotion-classifier/emotion_classifier

github.com

github주소 입니다.

Naive bayes

SVM

biLSTM

bert

네가지 모델을 돌려보았고

SVM과 bert가 80%대의 정확도를 보였습니다.

자세한 내용은 accuracy report폴더의 엑셀파일을 참고해주세요

데이터가 필요하신 분도 계실 거 같아 데이터도 github에 올려두었습니다!

cuda 10.0
cuDNN 7.6.4
tensorflow-gpu 2.0.0

이렇게 설치할 예정입니다.

<<Nvidia 그래픽카드를 사용하고 있으셔야 cuda가속을 사용하실 수 있습니다.>>


1. cudo 10.0

https://developer.nvidia.com/cuda-10.0-download-archive

여기서 다운로드 받습니다.

설치는 더블클릭하면 알아서 됩니다.

cudo 9.0은 업그레이드도 있으니 받아서 계속 설치합니다.

아나콘다 환경을 사용하실 경우

conda install cudatoolkit==10.0

으로 편리하게 설치하실 수 있습니다.


2. cuDNN 7.5

https://developer.nvidia.com/cudnn

이녀석은 가입을 해야 받을 수 있습니다.

다운로드 하여 압축을 푼 이후

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0

여기에 붙여넣기 해서 옮겨줍니다.

마찬가지로 아나콘다 환경을 사용하신다면

conda install cudnn

으로 편리하게 설치하실 수 있습니다.


3. tensorflow-gpu 2.0.0

버전을 굳이 지정한 이유는

이후 버전에서는 tensorflow를 import하는 부분에서 에러가 나는 버그가 있기 때문입니다.

여러 버전을 시도해보았는데 1.10.0 버전이 가장 최신버전으로 오류가 나지 않았습니다(2019.03.24 기준)

2019.08.08 정정합니다 1.14.0 버전이 안정적입니다.

2019.12.02 tensorflow 2.0버전업으로 인하여 업데이트 합니다.

pip install --upgrade tensorflow-gpu==2.0.0

cmd에서 명령어를 이용하여 설치합니다.


이후 pycharm에서

import tensorflow as tf

로 import하면 정상적으로 동작됩니다.


겪었던 여러가지 오류

1. CondaHTTPError: HTTP 000 CONNECTION FAILED for url

openSSL을 설치하면 해결됩니다.

https://slproweb.com/products/Win32OpenSSL.html

위 사이트에서 openssl.exe를 다운받아 설치합니다.


2. return _load(spec) error

텐서플로우 버전을 낮추면 됩니다.

pip uninstall tensorflow-gpu

pip install --upgrade tensorflow-gpu==1.10.0

위 명령어를 이용하여 버전을 1.10.0으로 설치해보세요


3. no cuDNN

cuDNN이 없어서 발생하는 오류입니다.

tensorflow-gpu와 cuda toolkit만 설치할 경우 발생했었습니다.

위 설명을 이용하여 cuDNN을 다운받아 설치하면 해결됩니다.


+ Recent posts