ついに、Tensorflowのバージョン0.12.0rc0でWindowsに対応したので、早速インストールしてみた。
https://www.tensorflow.org/versions/r0.12/get_started/os_setup.html#pip-installation-on-windows
1)まず、CUDA8(cuda_8.0.44_win10.exe)とCUDNN5.1をインストール。前回同様Firefoxでインストールした。
hirotaka-hachiya.hatenablog.com
2)次にAnaconda4.2(Python3.5)を下記からダウンロードしてインストール。
https://www.continuum.io/downloads#windows
3)コマンドプロンプトを管理者権限で起動して、下記のpipコマンドを実行。
> pip install --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-0.12.0rc0-cp35-cp35m-win_amd64.whl ... Found existing installation: setuptools 27.2.0 Cannot remove entries from nonexistent file c:\program files\anaconda3\lib\site-packages\easy-install.pth You are using pip version 8.1.2, however version 9.0.1 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command.
setuptools 27.2.0が既に入っているというエラーがでたので、下記のように--ignore-installedを付けて再度実行する。
> pip install --upgrade --ignore-installed https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-0.12.0rc0-cp35-cp35m-win_amd64.whl ... Installing collected packages: wheel, setuptools, six, protobuf, numpy, tensorflow-gpu Successfully installed numpy-1.11.2 protobuf-3.1.0 setuptools-27.2.0 six-1.10.0 tensorflow-gpu-0.12.0rc0 wheel-0.29.0
4)MNISTのサンプルコードで動作確認
> C:\Users\PC User\Documents\DeepLearning\tensorflow\tensorflow\tensorflow\models\image\mnist>python convolutional.py I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cublas64_80.dll locally I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cudnn64_5.dll locally I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cufft64_80.dll locally I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library nvcuda.dll locally I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library curand64_80.dll locally Extracting data\train-images-idx3-ubyte.gz Extracting data\train-labels-idx1-ubyte.gz Extracting data\t10k-images-idx3-ubyte.gz Extracting data\t10k-labels-idx1-ubyte.gz I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:885] Found device 0 with properties: name: GeForce GTX 980 major: 5 minor: 2 memoryClockRate (GHz) 1.291 pciBusID 0000:01:00.0 Total memory: 4.00GiB Free memory: 3.30GiB I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:906] DMA: 0 I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:916] 0: Y I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 980, pci bus id: 0000:01:00.0) E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:586] Could not identify NUMA node of /job:localhost/replica:0/task:0/gpu:0, defaulting to 0. Your kernel may not have been built with NUMA support. WARNING:tensorflow:From convolutional.py:288 in main.: initialize_all_variables (from tensorflow.python.ops.variables) is deprecated and will be removed after 2017-03-02. Instructions for updating: Use `tf.global_variables_initializer` instead. Initialized! Step 0 (epoch 0.00), 43.5 ms Minibatch loss: 12.054, learning rate: 0.010000 Minibatch error: 90.6% Validation error: 84.6% Step 100 (epoch 0.12), 14.4 ms Minibatch loss: 3.275, learning rate: 0.010000 Minibatch error: 7.8% Validation error: 7.0% Step 200 (epoch 0.23), 14.2 ms Minibatch loss: 3.474, learning rate: 0.010000 Minibatch error: 12.5% Validation error: 3.7% ... Step 8400 (epoch 9.77), 13.6 ms Minibatch loss: 1.598, learning rate: 0.006302 Minibatch error: 0.0% Validation error: 0.8% Step 8500 (epoch 9.89), 14.2 ms Minibatch loss: 1.613, learning rate: 0.006302 Minibatch error: 1.6% Validation error: 0.8% Test error: 0.8%
以前100ステップあたり1400msかかっていたのが、GPU(GTX980)で14msと大分速くなった。
hirotaka-hachiya.hatenablog.com
また、mnistのtensorboardで可視化するためのログを出力するサンプルコードを実行してみる。
C:\Program Files\Anaconda3\Lib\site-packages\tensorflow\examples\tutorials\mnist>python mnist_with_summaries.py I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cublas64_80.dll locally I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cudnn64_5.dll locally I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cufft64_80.dll locally I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library nvcuda.dll locally I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library curand64_80.dll locally Successfully downloaded train-images-idx3-ubyte.gz 9912422 bytes. Extracting /tmp/tensorflow/mnist/input_data\train-images-idx3-ubyte.gz Successfully downloaded train-labels-idx1-ubyte.gz 28881 bytes. Extracting /tmp/tensorflow/mnist/input_data\train-labels-idx1-ubyte.gz Successfully downloaded t10k-images-idx3-ubyte.gz 1648877 bytes. Extracting /tmp/tensorflow/mnist/input_data\t10k-images-idx3-ubyte.gz Successfully downloaded t10k-labels-idx1-ubyte.gz 4542 bytes. Extracting /tmp/tensorflow/mnist/input_data\t10k-labels-idx1-ubyte.gz I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:885] Found device 0 with properties: name: GeForce GTX 980 major: 5 minor: 2 memoryClockRate (GHz) 1.291 pciBusID 0000:01:00.0 Total memory: 4.00GiB Free memory: 3.30GiB I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:906] DMA: 0 I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:916] 0: Y I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 980, pci bus id: 0000:01:00.0) E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:586] Could not identify NUMA node of /job:localhost/replica:0/task:0/gpu:0, defaulting to 0. Your kernel may not have been built with NUMA support. Accuracy at step 0: 0.0761 Accuracy at step 10: 0.7081 Accuracy at step 20: 0.8077 Accuracy at step 30: 0.8485 Accuracy at step 40: 0.8737 Accuracy at step 50: 0.8786 Accuracy at step 60: 0.8842 Accuracy at step 70: 0.8903 Accuracy at step 80: 0.885 Accuracy at step 90: 0.8955 I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cupti64_80.dll locally Adding run metadata for 99 Accuracy at step 100: 0.9039 Accuracy at step 110: 0.9134 Accuracy at step 120: 0.9158 Accuracy at step 130: 0.9176 Accuracy at step 140: 0.9246 Accuracy at step 150: 0.9182 Accuracy at step 160: 0.9264 Accuracy at step 170: 0.9237 Accuracy at step 180: 0.9191 Accuracy at step 190: 0.9237 Adding run metadata for 199 Accuracy at step 200: 0.9316 ...
C:\tmp\mnist_logsにログが出力されるので、コマンドプロンプトでtensorboardをログフォルダを指定して実行する。
>tensorboard --logdir=C:\tmp\mnist_logs I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cublas64_80.dll locally I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cudnn64_5.dll locally I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cufft64_80.dll locally I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library nvcuda.dll locally I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library curand64_80.dll locally Starting TensorBoard b'39' on port 6006 (You can navigate to http://192.168.11.6:6006)
そして、ブラウザで「http://localhost:6006」にアクセスしてみたが、下記のようなエラーがでた。
GET http://localhost:6006/webcomponentsjs/webcomponents-lite.min.js [HTTP/1.1 404 Not Found 32ms]
どうやらwindows版では、まだtensorboardが動作しないようで、まもなくリリースされる0.12.0rc1で対応されるとのこと。
https://github.com/tensorflow/tensorflow/issues/5983