Artificial Intelligence
Anaconda Tensorflow GPU 버전 설치
inee0727
2023. 1. 30. 17:49
◼ GPU: NVIDIA RTX A4000 (NVIDIA driver) 473.81-quadro-rtx-desktop-notebook-win10-win11-64bit-international-dch-whql.exe (CUDA) cuda_11.4.4_472.50_windows.exe (CUDNN) cudnn-11.4-windows-x64-v8.2.2.26.zip ◼ Anaconda 3 conda create -n tf python=3.10 ◼ Tensorflow 2.9.1 pip install tensorflow-gpu==2.9.1 |
1. Anaconda3 설치
2. NVIDIA driver / CUDAN / cuDNN 설치
- CUDA 11.4.4 / cuDNN 8.2.2 로 세팅
3. 환경변수 추가 (하단에 3개 환경변수 추가 완료)
4. Anaconda 환경 생성
conda create -n tf_test pip python==3.10
conda activate tf_test
pip install tensorflow-gpu==2.9.1
5. 예제 실행
import tensorflow as tf
from tensorflow import keras
import numpy as np
import matplotlib.pyplot as plt
print(tf.__version__)
fashion_mnist = keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat',
'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot']
plt.figure()
plt.imshow(train_images[0])
plt.colorbar()
plt.grid(False)
plt.show()
train_images = train_images / 255.0
test_images = test_images / 255.0
plt.figure(figsize=(10,10))
for i in range(25):
plt.subplot(5,5,i+1)
plt.xticks([])
plt.yticks([])
plt.grid(False)
plt.imshow(train_images[i], cmap=plt.cm.binary)
plt.xlabel(class_names[train_labels[i]])
plt.show()
model = keras.Sequential([
keras.layers.Flatten(input_shape=(28, 28)),
keras.layers.Dense(128, activation='relu'),
keras.layers.Dense(10, activation='softmax')
])
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
model.fit(train_images, train_labels, epochs=5)
test_loss, test_acc = model.evaluate(test_images, test_labels, verbose=2)
print('\n테스트 정확도:', test_acc)
참고사이트
https://junn.net/archives/2466
Anaconda Tensorflow GPU 버전 설치 (2023.01 수정) - junn.net
Setting Log 작년과 최근 성공한 세팅 정보 2가지만 남겨두었다. 오히려 최근 세팅에서 (무엇이 문제인지 몰라서) CUDA 버전을 낮췄다.…
junn.net