studylog/北の雲

chainer/python/nlp

chainerメモ その1

GPU/CUDAで動かしててこんなエラーが出たら

ValueError: unsupported combination of input types
terminate called after throwing an instance of 'pycuda::error'
what(): explicit_context_dependent failed: invalid device context - no currently active context?


>ValueError: unsupported combination of input types

ここが問題。サポートされてない型ですよ。

x = np.array(  [[5.], [4.], [1.]] )
x = cuda.to_gpu(x)

これだと上記のエラーになる。
xがnumpyのfloat64型になっているからっぽいので、

x = np.array(  [[5.], [4.], [1.]]  . dtype=np.float32)
x = cuda.to_gpu(x)

とする。ここでだいぶハマった。