Windows에 TensorFlow2 GPU 설치하기 (Docker, WSL2 이용)
1. NVIDIA driver 설치하기
Download the latest official NVIDIA drivers
Download the latest official NVIDIA drivers
www.nvidia.com

그래픽카드에 맞는 드라이버를 선택해서 다운로드 후 설치해 준다.
2. WSL 설치하기
Windows10에 WSL 설치하기
1. Windows 버전 확인 WSL(Windows Subsystem for Linux, Linux용 Windows 하위 시스템)을 설치하려면 Windows 10 버전 2004 이상 (빌드 19041 이상) 또는 Windows 11 이상이어야 한다. Windows10의 경우 Windows + R 을 눌러서 winv
shrimpfajita.tistory.com
linux 배포판 (Ubuntu)를 실행해서 아래 명령어를 입력해 준다.
sudo apt update -y
sudo apt upgrade -y
3. 도커 데스크톱 설치하기
Docker Desktop for Windows를 다운로드하여 설치해 준다.
Get Docker
docs.docker.com

"Use WSL 2 instead of Hyper-V" 옵션을 체크해 준다.

설치가 완료된 도커를 실행시켜서 Settings > Resources > WSL integration에서 WSL integration 설정을 Enable 시켜준다.
additional distros 설정도 enable 시켜준다.
4. 도커 컨테이너에서 텐서플로우 실행하기
WSL 터미널에서 아래 명령어를 실행시킨다.
docker run -it --rm -p 8888:8888 --gpus all tensorflow/tensorflow:latest-gpu-jupyter
터미널 창에 표시된 아래와 같은 링크에 접속하면 주피터 노트북이 실행된다.
# Jupyter Notebook is running at:
http://127.0.0.1:8888/?token=무작위로-생성되는-토큰
5. TensorFlow GPU 확인
새로운 노트북 파일을 만들어서 아래와 코드를 실행시키면 텐서플로우 라이브러리에서 CPU와 GPU 리스트를 확인할 수 있다.
import os; os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import tensorflow as tf
tf.config.list_physical_devices()

설치가 잘 된 걸 확인했으니 Jupyter Notebook에서 원하는 작업을 하면 된다.