1. 버전 조합 개요
Ubuntu: 20.04 LTS
Python: 3.8 (Ubuntu 22.04 LTS는 기본 버전이 3.10이며, 3.8을 설치하려면 deadsnake ppa 추가 등 살짝 번거로움.. 라이브러리 요구사항을 맞추려면 TensorRT 7.2.3.4를 설치해야 하는데, 3.8까지만 지원함..)
Nvidia Driver: 설치할 CUDA Toolkit 버전의 요구사항 충족 되는 버전 이상이면 무방할듯..(그냥 최신 버전 설치함)
CUDA Toolkit: 11.1.1 (https://www.tensorflow.org/install/source?hl=ko#gpu 에서 11.2로 표기된거 보고 설치 해본 결과, 라이브러리 버전 오류 확인됨. TensorRT 7 버전대 요구사항에 영향 받는듯..)
cuDNN: 8.1.1.33
TensorRT: 7.2.3.4 (8버전대 설치해본 결과 TensorFlow 2.11도 TensorRT 7 버전대 라이브러리를 요구함..)
TensorFlow: 2.11
※ TensorFlow 2.11 pip 배포본 설치에 요구되는 라이브러리 구성이 2.9에서와 달라지지 않음. 배포본 빌드 환경을 유지하는듯한.. TensorRT 7 버전대 종속에서 벗어나야 상위 버전 라이브러리를 쓸 수 있을듯 싶은.. --
2. Download
CUDA Toolkit 11.1 Update 1 Downloads
Please Note: We advise customers updating to Linux Kernel 5.9+ to use the latest NVIDIA Linux GPU driver R455 that will be available for download from NVIDIA website and repositories, starting today. Select Target Platform Click on the green buttons that d
developer.nvidia.com
# wget https://developer.download.nvidia.com/compute/cuda/11.1.1/local_installers/cuda_11.1.1_455.32.00_linux.run
cuDNN(Nvidia 계정 필요): https://developer.nvidia.com/rdp/cudnn-archive#a-collapse811-111
cuDNN Archive
Download releases from the GPU-accelerated primitive library for deep neural networks.
developer.nvidia.com
TensorRT(Nvidia 계정 필요): https://developer.nvidia.com/nvidia-tensorrt-7x-download#trt723
3. Nvidia Driver 설치
Disable nouveau
# sudo vi /etc/modprobe.d/blacklist-nvidia-nouveau.conf
blacklist nouveau
options nouveau modeset=0
저장
# sudo update-initramfs -u
리부팅
Install Nvidia Driver from ppa
# sudo apt-get install linux-headers-$(uname -r) dkms
# sudo dpkg --add-architecture i386
# sudo add-apt-repository ppa:graphics-drivers/ppa
# sudo apt update
# sudo apt install libc6:i386
# sudo apt install build-essential libglvnd-dev pkg-config
# sudo ubuntu-drivers devices
# sudo ubuntu-drivers autoinstall (혹은 sudo apt install nvidia-driver-525)
리부팅
4. Python
# sudo apt update
# sudo apt install python3-dev python3-pip python3-venv
# sudo apt-get update
# sudo apt-get install idle3
# sudo apt install python3-testresources
# sudo apt install libxcb-xinerama0
# python3 -m pip install --user --upgrade pip setuptools wheel packaging requests opt_einsum
# python3 -m pip install --user --upgrade keras_preprocessing --no-deps
# python3 -m pip install --user --upgrade numpy scipy matplotlib ipython h5py jupyter spyder pandas sympy nose
# python3 -m pip install --user --upgrade scikit-learn ipyparallel pydot pydotplus pydot_ng graphviz
# sudo apt install graphviz
# echo 'export PATH=$PATH:'$(python3 -c 'import site; print(site.USER_BASE)')'/bin' >> ~/.bash_profile
# source ~/.bash_profile
# python3 -m pip freeze --user > requirements.txt
(상기 설치 내역 한번에 재설치시 # python -m pip install --user -r requirements.txt 실행)
5. Install CUDA Toolkit
# sudo apt-get install gcc g++ freeglut3 freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev
# sudo apt-get install libglu1-mesa libglu1-mesa-dev libfreeimage3 libfreeimage-dev libxcb-xinput-dev
# cd /home/userid/Downloads/
(CUDA Toolkit 다운로드한 디렉토리로 이동)
# chmod 744 cuda_11.1.1_455.32.00_linux.run
# sudo ./cuda_11.1.1_455.32.00_linux.run
(설치 구성에 CUDA Toolkit에서 제공하는 Driver는 설치되지 않도록 설치 항목 조정 필요. 아래 참고..)
Continue 선택후 Enter
accept 입력후 Enter
Driver 관련 항목 선택 해제하고 Options 항목 선택후 Enter
Driver Options 항목 선택후 Enter
Do not install... 항목 모두 선택하고 Done 선택후 Enter
Samples Options 선택후 Enter
Change Writeable Samples Install Path 항목 선택후 Enter
경로 입력란의 home 디렉토리의 user 디렉토리 아래에 cuda를 추가해주고 Enter. (Samples 경로는 /home/userid/cuda/NVIDIA_CUDA-version_Samples 가 된다)
Done 선택후 Enter
Done 선택후 Enter
Install 선택후 Enter
Summary를 보여주고 /var/log/cuda-installer.log에서 설치 과정 로그를 확인 할 수 있다.
(일반적으로 /usr/local/cuda-<version>/의 경로는 /usr/local/cuda/로 링크가 만들어지니 참고하자.)
# sudo vi /etc/profile.d/cuda.sh
export CUDADIR=/usr/local/cuda
export PATH=$PATH:$CUDADIR/bin
저장
# source /etc/profile.d/cuda.sh
# sudo vi /etc/ld.so.conf.d/cuda.conf
/usr/local/cuda/lib64
/usr/local/cuda/extras/CUPTI/lib64
저장
# sudo ldconfig
6. Install cuDNN
# sudo apt-get install zlib1g
# tar -xvf cudnn-11.2-linux-x64-v8.1.1.33.tgz
# sudo cp cuda/include/cudnn*.h /usr/local/cuda/include
# sudo cp -P cuda/lib/libcudnn* /usr/local/cuda/lib64
# sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*
# sudo ldconfig
7. Install TensorRT
# tar xzvf TensorRT-7.2.3.4.Ubuntu-18.04.x86_64-gnu.cuda-11.1.cudnn8.1.tar.gz
# cd /usr/local
# sudo cp -rP /home/userid/Download/TensorRT-7.2.3.4/ .
# sudo vi /etc/ld.so.conf.d/TensorRT.conf
/usr/local/TensorRT-7.2.3.4/lib
저장
# sudo ldconfig
# cd /usr/local/TensorRT-7.2.3.4/python
# python3 -m pip install --user tensorrt-7.2.3.4-cp38-none-linux_x86_64.whl
# cd ../uff
# python3 -m pip install --user uff-0.6.9-py2.py3-none-any.whl
# which convert-to-uff
# cd ../graphsurgeon
# python3 -m pip install --user graphsurgeon-0.4.5-py2.py3-none-any.whl
# cd ../onnx_graphsurgeon
# python3 -m pip install --user onnx_graphsurgeon-0.2.6-py2.py3-none-any.whl
# python3 -m pip install --user --upgrade pyyaml requests tqdm
8. Install TensorFlow
# python3 -m pip install --user --upgrade tensorflow==2.11
# python3 -m pip install --user --upgrade tensorflow_datasets
# python3 -m pip install --user --upgrade tensorflow-text==2.11
# python3 -m pip install --user --upgrade tensorboard==2.11
# python3 -m pip install --user --upgrade onnx
# python3 -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
# python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
※ 상기 구성에 PyTorch를 함께 설치 하고 싶다면 아래 참고
# pip3 install torch==1.8.2 torchvision==0.9.2 torchaudio==0.8.2 --extra-index-url https://download.pytorch.org/whl/lts/1.8/cu111
# python3 -c "import torch; print(torch.cuda.is_available())"
# python3 -c "import torch; print(torch.cuda.get_device_name())"
# python3 -c "import torch; x = torch.rand(5, 3); print(x)"
https://pytorch.org/get-started/previous-versions/#wheel-9
PyTorch
An open source machine learning framework that accelerates the path from research prototyping to production deployment.
pytorch.org
개별 참고:
https://testtube.tistory.com/39
[Ubuntu 18.04] Nvidia Driver & CUDA Toolkit & cuDNN Installation (ppa & apt-get, runfile, Tar file)
!!! Ubuntu 인스톨러 진입, 설치후 진입 등 OS 부팅 진입시 nouveau(Open Source Driver for Nvidia VGA) 호환 문제로 화면이 나오지 않거나 Hang 상태로 진행이 안될 경우 아래 참고 !!! https://testtube.tistory.com/entry/C
testtube.tistory.com
https://testtube.tistory.com/68
[Ubuntu 20.04] Python3 Installation
# sudo apt update # sudo apt install python3-dev python3-pip python3-venv https://testtube.tistory.com/entry/Ubuntu-1804-IDLE-Python-IDE-Installation [Ubuntu 18.04] IDLE Python IDE Installation for Python 3: # sudo apt-get update # sudo apt-get install idl
testtube.tistory.com
https://testtube.tistory.com/77
[Python] 필수 Library/Tools 설치(user mode)
# sudo apt install python3-testresources # sudo apt install libxcb-xinerama0 # python3 -m pip install --user --upgrade pip setuptools wheel packaging requests opt_einsum # python3 -m pip install --user --upgrade keras_preprocessing --no-deps # python3 -m p
testtube.tistory.com
https://testtube.tistory.com/79
[Python] TensorRT Installation(tar file)
1. TensorRT Download (Nvidia 계정 필요함) https://developer.nvidia.com/tensorrt NVIDIA TensorRT An SDK with an optimizer for high-performance deep learning inference. developer.nvidia.com 2. 다운로드 받은 디렉토리로 이동하여 압축 해
testtube.tistory.com
'Programming > Python' 카테고리의 다른 글
[Python] TensorFlow(2.13) Installation (Ubuntu, Nvidia GPU, + PyTorch) (0) | 2023.07.26 |
---|---|
[Python] Jupyter Notebook Remote Configuration (0) | 2023.01.31 |
[Python] TensorRT Installation(tar file) (0) | 2022.10.31 |
[Python] 필수 Library/Tools 설치(user mode) (0) | 2022.10.30 |
[Python] 파일 입출력 예시 (0) | 2022.08.17 |