タイトル通りtensorflowでCPUではなくGPUで処理を行いたく、
tensorflow-gpuを入れたのですが、パスがどうしてもうまく通せず悩んでおります。詳しい方ご教授お願いします。
まず実行環境ですが,以下の通りです。
Windows 11
GPU:RTX3070
visual studio 2022
CUDA Toolkit v11.7
python 3.10.8
jupiter notebook 6.5.2
anaconda 22.11.0
tensorflow-gpu 2.10.1
起きている現象ですが、condaで作成した仮想環境にて、
一通りの設定は行い、うまく動作するかのテストのため
python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
上記コードを入れたのですが、下記エラーが出たため、
W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudnn64_8.dll'; dlerror: cudnn64_8.dll not found 2022-12-11 19:46:51.339367: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1934] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform. Skipping registering GPU devices... 2022-12-11 19:46:51.339754: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2 To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. tf.Tensor(-182.76224, shape=(), dtype=float32)
パスが通っていないと判断し、環境変数の設定も行いました。
しかし、変わらずエラーが出ており、
SET PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\bin;%PATH% SET PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\extras\CUPTI\lib64;%PATH% SET PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7include;%PATH% SET PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\cuDNN\bin;%PATH%
上記コードを仮想環境内で実施しテストをすると、
I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2 To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2022-12-11 19:53:07.199384: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1616] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 5454 MB memory: -> device: 0, name: NVIDIA GeForce RTX 3070, pci bus id: 0000:2b:00.0, compute capability: 8.6 tf.Tensor(-268.85074, shape=(), dtype=float32)
多分成功?したと思うのですが、プロンプトを閉じで
起動し直すとまた最初のCPUしか使われていない状態に戻ります。
これってデフォなんでしょうか?
毎回、仮想環境内でパスを通さないといけないのでしょうか
いろいろ試しましたがこれ以上進展が望めないので
教えていただきたいです。よろしくお願いします。
追加↓(再起動後)
This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2 To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2022-12-11 22:42:43.277818: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1616] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 4912 MB memory: -> device: 0, name: NVIDIA GeForce RTX 3070, pci bus id: 0000:2b:00.0, compute capability: 8.6 tf.Tensor(204.57315, shape=(), dtype=float32)
回答1件