본문 바로가기

AI/AI model

RTX 30XX 번대 GPU에서 구글 공식 Electra 레퍼런스 구동

윈도우 11(10) 환경에서 구글 공식 Electra 레퍼런스로 사전학습 시도시, TensorFlow 1.15 버전은 RTX 30XX번대 GPU 환경일 경우 메모리 이슈가 발생하여 사전학습이 제대로 진행되지 않음.

 

해결 방법

1. 공식 레퍼런스는 TensorFlow 1.15 버전 으로 작성되어 있는데 1.15 버전을 TensorFlow 2.X 버전으로 마이그레이션

2. wsl Ubuntu 환경에서 TensorFlow 1.15 버전 세팅

 

해결 1. TensorFlow 2.X 버전 마이그레이션

가. 텐서플로우 2 버전에서 제공하는 자동변환 스크립트를 활용해 코드 변환

나. contrib 모듈의 경우, 텐서플로우 2에서는 없어진 모듈이므로, 자동변환 스크립트를 사용한 후  tf.keras 모듈이나 tf-slim  모듈을 사용해 수동으로 추가 코드변경 작업 필요.

 

해결 2. wsl Ubuntu 환경에서 TensorFlow 1.15 버전 환경 세팅

가. 하단 레퍼런스를 참고해 TensorFlow 1.15 버전 환경 세팅

나. wsl 환경에서 학습 진행시, Freezing(화면 멈춤) 현상이 발생할 수 있음. 이 경우 윈도우 커맨드 창에서 wsl 업데이트를 진행하면 Freezing 현상 해결

 

 

 

 

아래는 wsl2 환경에서 텐서플로우 1.15 환경 세팅하는 레퍼런스


How To Install TensorFlow 1.15 for NVIDIA RTX30 GPUs (without docker or CUDA install)

Quick Setup -- Wed 15 Sep 2021

Do this:

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh

conda update conda
conda update --all

conda create --name TF1.15 python=3.8
conda activate TF1.15

pip install nvidia-pyindex
pip install nvidia-tensorflow[horovod]

conda install -c conda-forge openmpi
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/miniconda3/envs/TF1.15/lib/

mkdir tf-test
cd tf-test

wget https://github.com/dbkinghorn/NGC-TF1-nvidia-examples/archive/main/NGC-TF1-nvidia-examples.tar.gz

tar xf NGC-TF1-nvidia-examples.tar.gz
cd NGC-TF1-nvidia-examples-main/cnn/

python resnet.py --layers=50 --batch_size=64 --precision=fp32

You now have a tested and working TF 1.15 This is the latest build of what they are using on NGC nv21.08

If you have already installed Anaconda Python instead of miniconda3 then just start at conda update conda and conda update --all (That is important so that you are using a new enough version of pip to resolve the dependencies properly)

 

 


레퍼런스

 

1. 우분투 환경에서 텐서플로우 1.15 버전 세팅

https://www.pugetsystems.com/labs/hpc/How-To-Install-TensorFlow-1-15-for-NVIDIA-RTX30-GPUs-without-docker-or-CUDA-install-2005/

 

How To Install TensorFlow 1.15 for NVIDIA RTX30 GPUs (without docker or CUDA install)

In this post I will show you how to install NVIDIA's build of TensorFlow 1.15 into an Anaconda Python conda environment. This is the same TensorFlow 1.15 that you would have in the NGC docker container, but no docker install required and no local system CU

www.pugetsystems.com

 

2. 텐서플로우 1 -> 텐서플로우 2 마이그레이션

https://www.tensorflow.org/guide/migrate?hl=ko 

 

텐서플로 1 코드를 텐서플로 2로 바꾸기  |  TensorFlow Core

텐서플로 1 코드를 텐서플로 2로 바꾸기 Note: 이 문서는 텐서플로 커뮤니티에서 번역했습니다. 커뮤니티 번역 활동의 특성상 정확한 번역과 최신 내용을 반영하기 위해 노력함에도 불구하고 공

www.tensorflow.org

 

3. 텐서플로우 2에서 contrib 모듈 대체 모듈

https://toramko.tistory.com/entry/tensorflow-%ED%85%90%EC%84%9C%ED%94%8C%EB%A1%9C%EC%9A%B0-contrib-v1-v2-%EC%BD%94%EB%93%9C-%EC%97%85%EA%B7%B8%EB%A0%88%EC%9D%B4%EB%93%9C-3

 

tensorflow :: 텐서플로우 contrib (v1 -> v2 코드 업그레이드 3)

contrib tensorflow 2.x 버전에서 다음과 같이 contrib 모듈을 사용하면 실행 시 에러가 난다. import tensorflow as tf r1 = tf.contrib.layers.l1_regularizer(0.04) r2 = tf.contrib.layers.l2_regularizer(0.0..

toramko.tistory.com

 

반응형

'AI > AI model' 카테고리의 다른 글

일렉트라(electra) 모델 사전학습 feat. RTX 3060 12G  (0) 2022.10.06
Electra  (0) 2022.07.20
transfer learning  (0) 2022.04.26