https://prlabhotelshoe.tistory.com/23
참고하여 작성 한 글이다.
내용에 수정된 부분이 약간 헷갈려서 정리하고자 글을 쓴다.

2080ti 사용중

cuda 테스트를 위해

cuda버전 확인하고

import tensorflow as tf

print(tf.__version__)
print(tf.config.list_physical_devices('GPU'))

결과는 망
인식 안됨(캡처를 못했다.)
2.9.3
[] 이렇게 뜬다.

인식하면 이렇게 뜬다.


검색하여 참고한 사이트.

https://www.tensorflow.org/install/source_windows?hl=en#gpu
여기서 버전 참고했으나 딱히 도움되지는 않았음

https://prlabhotelshoe.tistory.com/23
참고하여(수정된 부분이 있어서 약간 헷갈림)

되는 버전을 찾았다.

https://developer.nvidia.com/cuda-toolkit-archive
에서 최신버전 받고

설치 완료 후~

https://developer.nvidia.com/rdp/cudnn-archive
에서 최신버전 받아서

다운받은 파일을
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5
여기 폴더에 덮어쓰기



정리해보자면.

cuda 11.5.1 버전 설치 (11.5가 중요하다 .1은 .0업뎃 버전일꺼라 큰 문제없을것 같아서)
cuDnn 8.3.3.40 for cuda 11.5 버전으로 설치
(cuDnn 8.3.1.22 for cuda 11.5 버전으로 먼저 해봤다. 둘 다 잘된다.)

python에서 tensorflow 2.9.1 or 2.9.3 테스트 해봄 잘돌아간다.
(tensorflow 2.14 버전은 GPU 인식 못함.)

현재 23년 10월 04일 기준 버전들
CUDA Toolkit 11.5.2 (February 2022)
cuDNN v8.3.3 (March 18th, 2022), for CUDA 11.5

내가 설치한 파일들 이름
cuda cuda_11.5.1_496.13_windows.exe
cuDNN cudnn-windows-x86_64-8.3.3.40_cuda11.5-archive.zip

테스트 하느라 11.5.1 인데 다음에는 11.5.2 이후 최신으로 설치할것이다.
어차피 x.y.z 중 z는 소소한 업뎃이라 영향을 끼치지 않는다.
파이썬도 3.10 이냐 3.11 이냐가 중요하지 그 뒤에 .z 는 높은게 좋다. (버그 수정일 가능성이 높음)

파이썬 설치 코드

pip install tensorflow==2.9.3

결론
cuda 11.5.x
cdDnn 8.3.x for cuda 11.5
tensorflow 2.9.x
가 딱 맞다.

test code

import tensorflow as tf
import time

# CPU에서 작업 수행
def cpu_work():
    with tf.device('/CPU:0'):
        a = tf.random.normal([10000, 10000])
        b = tf.random.normal([10000, 10000])
        c = tf.matmul(a, b)

# GPU에서 작업 수행
def gpu_work():
    with tf.device('/GPU:0'):
        a = tf.random.normal([10000, 10000])
        b = tf.random.normal([10000, 10000])
        c = tf.matmul(a, b)

if __name__ == "__main__":
    # CPU 성능 테스트
    start_time = time.time()
    cpu_work()
    end_time = time.time()
    cpu_time = end_time - start_time

    # GPU 성능 테스트
    start_time = time.time()
    gpu_work()
    end_time = time.time()
    gpu_time = end_time - start_time

    print(f"CPU 실행 시간: {cpu_time} 초")
    print(f"GPU 실행 시간: {gpu_time} 초")

자~~알 돌아간다. ^^

profile
dataXdata=DATA

1개의 댓글

comment-user-thumbnail
2024년 11월 10일

CPU는 RYZEN9 5950X

답글 달기

관련 채용 정보

Powered by GraphCDN, the GraphQL CDN