IoSR-Surrey / untwist

Other
130 stars 30 forks source link

The (theano) segment will crash when running on GPU due to float64 #8

Closed LinkOne1A closed 6 years ago

LinkOne1A commented 6 years ago

You likely already know this, but within the CUDA 7.5 framework for the GPU (specifically cuda-repo-ubuntu1404-7-5-local_7.5-18_amd64.deb, and theano 0.9.0rc2 ), the call to pred = sgd.predict(Xtest) will crash due to float64 being typecasted to float32.

I am not sure exactly why only on that specifically call to sgd.predict(), since an eariler call sgd.train(ds) does not crash.

That said, fix is simple: Code block mlp_examples.py before the fix:

Xtrain = X[:,train_frames:].magnitude().T
Xtest = ds.standardize_points(Xtest)
pred = sgd.predict(Xtest)

Code block after the fix:

Xtrain = (X[:,train_frames:].magnitude().T).astype(np.float32)
Xtest = ds.standardize_points(Xtest)
pred = sgd.predict(Xtest)

float64 and complex128 are also mentioned elsewhere in the code (types.py and qerbt.py), but I think the simple above chage fixes the problem (as changing the rest did not make a differance for me).

The command line to run on the GPU was: THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python -u -i mlp_example.py

FYI that if floatX=float64, then, the execution will on the CPU only.

deeuu commented 6 years ago

Thanks for this. I believe 160b3179900b1b32cc52e1d3f69aa0432a09fd1e solves it