Translate

2016年11月11日金曜日

Anaconda環境でのTensorFlowがGPUをうまく使ってくれない件

TensorFlowのword2vec_basic.pyをAnaconda環境下で動かしてみたら..

harahara@ada:~/notebooks$ python word2vec_basic.py
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcurand.so locally
Found and verified text8.zip
Data size 17005207
Most common words (+UNK) [['UNK', 418391], ('the', 1061396), ('of', 593677), ('and', 416629), ('one', 411764)]
Sample data [5239, 3082, 12, 6, 195, 2, 3135, 46, 59, 156] ['anarchism', 'originated', 'as', 'a', 'term', 'of', 'abuse', 'first', 'used', 'against']
3082 originated -> 5239 anarchism
3082 originated -> 12 as
12 as -> 6 a
12 as -> 3082 originated
6 a -> 195 term
6 a -> 12 as
195 term -> 2 of
195 term -> 6 a

I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:925] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
I tensorflow/core/common_runtime/gpu/gpu_device.cc:951] Found device 0 with properties:
name: GeForce GTX 750 Ti
major: 5 minor: 0 memoryClockRate (GHz) 1.0845
pciBusID 0000:01:00.0
Total memory: 1.95GiB
Free memory: 173.94MiB
I tensorflow/core/common_runtime/gpu/gpu_device.cc:972] DMA: 0
I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] 0:   Y
I tensorflow/core/common_runtime/gpu/gpu_device.cc:1041] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 750 Ti, pci bus id: 0000:01:00.0)

E tensorflow/stream_executor/cuda/cuda_driver.cc:965] failed to allocate 173.94M (182386688 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY

...(略、もうひとつExceptionが出て終了)


どうもうまく動かない..
上のログからすると、GPUは認識して動かそうとしているんだけど、空きメモリが173.94MiBしかなくてメモリが足りないとかのたまう..


しょうがないので同じマシンでAnaconda環境ではなく、docker/nvidia-docker環境を構築して、

$ sudo -b nohup nvidia-docker-plugin
$ sudo nvidia-docker run -it -p 8888:8888 gcr.io/tensorflow/tensorflow:latest-gpu

したコンテナ上のjupyter上で動かしてみた..



root@4df25c85f208:/notebooks# python word2vec_basic.py
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcurand.so locally
Found and verified text8.zip
Data size 17005207
Most common words (+UNK) [['UNK', 418391], ('the', 1061396), ('of', 593677), ('and', 416629), ('one', 411764)]
Sample data [5239, 3084, 12, 6, 195, 2, 3137, 46, 59, 156] ['anarchism', 'originated', 'as', 'a', 'term', 'of', 'abuse', 'first', 'used', 'against']
3084 originated -> 5239 anarchism
3084 originated -> 12 as
12 as -> 3084 originated
12 as -> 6 a
6 a -> 195 term
6 a -> 12 as
195 term -> 6 a
195 term -> 2 of
I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:925] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
I tensorflow/core/common_runtime/gpu/gpu_device.cc:951] Found device 0 with properties:
name: GeForce GTX 750 Ti
major: 5 minor: 0 memoryClockRate (GHz) 1.0845
pciBusID 0000:01:00.0
Total memory: 1.95GiB
Free memory: 1.92GiB
I tensorflow/core/common_runtime/gpu/gpu_device.cc:972] DMA: 0
I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] 0:   Y
I tensorflow/core/common_runtime/gpu/gpu_device.cc:1041] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 750 Ti, pci bus id: 0000:01:00.0)
Initialized
Average loss at step  0 :  263.091247559
Nearest to often: moshiach, paratime, opacity, rumford, considered, ashkenazic, bias, ornithology,
Nearest to had: ftp, xv, jt, inexplicably, fock, savages, perfect, typhoons,
Nearest to an: cloak, carlin, siding, iala, infinitive, wilford, disseminate, patterned,
Nearest to one: irt, glencoe, part, formats, jpeg, decorate, koontz, yehudi,
Nearest to or: goetz, bequest, conflicting, invasive, biosphere, flat, shrews, tempted,
Nearest to as: negligent, militants, chaitin, blurring, comment, excitement, assured, lix,
..以下、正常終了。


..うまくいった...

よくよくドキュメント読むと..

TensorFlowのGET STARTEDのAnaconda installation/Using conda



Only the CPU version of TensorFlow is available at the moment and can be installed in the conda environment for Python 2 or Python 3.

Pyhon2/3 conda環境内でインストールされたTensorFlowは現時点ではCPUのみが有効です。



..もっと前のほうに書こうよ、Google..

0 件のコメント:

ClaudeをOpenAI O1のように思考させるDifyサンプルを試す

 Difyの「探索」タブにはさまざまなサンプルが載っており、その1つに「Thinking Claude (OpenAI O1 Alternative)」というものがある。   このサンプルがどういうものか、未だに自分でも解けない以下の問題をためしに聞いてみることにした。 『人類の...