코딩
아나콘다 가상환경에서 tensorflow가 GPU를 인식하지 못할 때
나는야석사
2024. 1. 3. 17:17
GPU에 맞게 CUDA 및 cudnn을 다 설치하였을 때 아나콘다 가상환경에서 tensorflow-gpu가 설치되었는데도 GPU를 인식하지 못할때가 있다.
from tensorflow.python.client import device_lib
device_lib.list_local_devices()
를 통해 gpu가 인식되는지 확인할 수 있는데, gpu가 인식되지 않으면 아래의 사진처럼 CPU만 인식된다.

tensorflow-gpu를 conda로 설치했을 때 위와 같은 오류가 나서 conda uninstall tensorflow-gpu -y 를 실행한 후
pip install tensorflow-gpu로 다시 설치했다.
pip로 tensorflow-gpu를 다시 설치할 때 아래와 같은 오류가 발생했다.

그래서 pip install tensorflow-gpu==2.10.1 로 버전을 설정하여 설치했고 문제없이 해결됐다.
from tensorflow.python.client import device_lib
device_lib.list_local_devices()
위의 명령어 실행 시 GPU까지 인식되는 것을 볼 수 있다.

파이썬 버전은 3.8이다.