[kor] Ubuntu18.04 system setting with cuda11.4,python3.7,tensorflow2.7.0 and cuDNN
- 파이썬 3.7 설치
sudo apt update
sudo apt install python3.7 # 설치하려는 버전
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1 # python을 치면 3.7 을 기본으로 하라는 뜻
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1 # python3을 치면 3.7 을 기본으로 하라는 뜻
- CUDA 설치
sudo apt-get update # 에러 발생시에 아래 두줄 실행
apt-get remove python3-apt
apt-get install python3-apt
sudo apt-get update
sudo apt-get install python3-pip
**wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin**
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/11.4.1/local_installers/cuda-repo-ubuntu1804-11-4-local_11.4.1-470.57.02-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1804-11-4-local_11.4.1-470.57.02-1_amd64.deb
sudo apt-key add /var/cuda-repo-ubuntu1804-11-4-local/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda
- nvcc -V 작동을 위해 환경설정
export CUDA_HOME=/usr/local/cuda
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64
export PATH=$PATH:$CUDA_HOME/bin
export LD_LIBRARY_PATH=/usr/local/cuda/extras/CUPTI/lib64
- cuDNN 설치 ( Tensorflow 에서 GPU를 사용하기위함)
# 꼭 순서대로 깔아야한다.
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/libcudnn8_8.2.4.15-1+cuda11.4_amd64.deb
sudo dpkg -i libcudnn8_8.2.4.15-1+cuda11.4_amd64.deb
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/libcudnn8-dev_8.2.4.15-1+cuda11.4_amd64.deb
sudo dpkg -i libcudnn8-dev_8.2.4.15-1+cuda11.4_amd64.deb
- 확인용
NVCC -V # 문제없이 cuda11.4 버전이 출력되는지 확인
Python3 # python 3.7인지 확인
import tensorflow
tensorflow.test.is_gpu_available() # True가 출력되는지 확인