๐Ÿชต

NVIDIA GPU Setup (For Tensorflow)

Tags
MachineLearning
ID matched
Created
Jan 17, 2023 10:24 AM
Last Updated
Last updated July 15, 2023
ย 
ย 
ย 

Visual Studio ์„ค์น˜

  • .NET ๋ฐ์Šคํฌํƒ‘ ๊ฐœ๋ฐœ ๋ฐ C++๋ฅผ ์‚ฌ์šฉํ•œ ๋ฐ์Šคํฌํƒ‘ ๊ฐœ๋ฐœ ์„ค์น˜ํ•˜๊ธฐ
    • notion image
ย 
ย 

CUDA ์„ค์น˜

  • ๋น ๋ฅธ ์„ค์น˜๋กœ ์„ค์น˜ํ•˜๊ธฐ
    • notion image
ย 
ย 

CuDNN ์„ค์น˜

  • NVIDIA ๊ณ„์ • ๊ฐ€์ž… ๋ฐ ๋กœ๊ทธ์ธ ํ•„์š”
  • zip ํŒŒ์ผ ๋‹ค์šด๋ฐ›์€ ํ›„, ์ ์ ˆํ•œ ๊ฒฝ๋กœ์— ์••์ถ•ํ•ด์ œํ•˜๊ธฐ
ย 
ย 

zlibwapi.dll ์„ค์ •

  • ์œ„์˜ ์‚ฌ์ดํŠธ์—์„œ Windows ์‚ฌ์šฉ์ž๋ฅผ ์œ„ํ•œ ZLIB DLL์„ ๋‹ค์šด๋ฐ›๋Š”๋‹ค.
  • ํ•ด๋‹น ํŒŒ์ผ์„ ์••์ถ•ํ•ด์ œํ•œ ๋’ค, zlibwapi.dll ํŒŒ์ผ์„ CUDA ๊ฒฝ๋กœ์˜ bin ํŒŒ์ผ๋กœ ๋ณต์‚ฌ๋ถ™์—ฌ๋„ฃ๊ธฐํ•œ๋‹ค.
    • C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.3\bin
ย 
ย 

ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์ถ”๊ฐ€

  • ์„ค์ •์•ฑ > ์ •๋ณด > ๊ณ ๊ธ‰ ์‹œ์Šคํ…œ ์„ค์ • > ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์„ ํƒ
    • notion image
  • ์‹œ์Šคํ…œ ๋ณ€์ˆ˜์˜ Path์— ์•„๋ž˜์˜ ๊ฒฝ๋กœ ์ถ”๊ฐ€
    • C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.3\include
    • C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.3\extras\CUPTI\lib64
    • ${cuDNN ์••์ถ•ํ•ด์ œ ํด๋”}\bin
  • ์ฐธ๊ณ  ์ด๋ฏธ์ง€
    • notion image
ย 
ย 

tensorflow ์„ค์น˜

  • pip๋ฅผ ์ด์šฉํ•˜์—ฌ tensorflow ์„ค์น˜ํ•˜๊ธฐ
    • pip3 install tensorflow
ย 
ย 

GPU ํ…Œ์ŠคํŠธ

  • gpu ํ™•์ธ
    • import tensorflow as tf from tensorflow.python.client import device_lib print("gpu_device_name:\n", tf.test.gpu_device_name()) print("--" * 20) print("list_physical_devices:\n", tf.config.list_physical_devices('GPU')) print("--" * 20) print("list_local_devices:\n", device_lib.list_local_devices())
      GPU ์„ค์ • ์ด์ „
      GPU ์„ค์ • ์ด์ „
      GPU ์„ค์ • ์ดํ›„
      GPU ์„ค์ • ์ดํ›„
  • ํ•™์Šต ํ…Œ์ŠคํŠธ
    • import os import tensorflow as tf mnist = tf.keras.datasets.mnist (X_train, y_train), (X_test, y_test) = mnist.load_data() X_train, X_test = X_train.reshape(60000, 28 * 28) / 255.0, X_test.reshape(10000, 28 * 28) / 255.0 model = tf.keras.models.Sequential([ tf.keras.layers.Dense(128, activation='relu', input_shape=(28 * 28,)), tf.keras.layers.Dense(256, activation='relu'), tf.keras.layers.Dense(10, activation='softmax') ]) model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy']) model.fit(X_train, y_train, epochs=20) model.evaluate(X_test, y_test, verbose=2)
      GPU ์„ค์ • ์ด์ „
      GPU ์„ค์ • ์ด์ „
      GPU ์„ค์ • ์ดํ›„
      GPU ์„ค์ • ์ดํ›„
      ย