Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Python+Theano with OpenCL in an AMD GPU

I'm trying to use Python with Theano to accelerate some code with OpenCL. I installed libgpuarray and pygpu as instructed (I think), and got no errors. The installation detected the OpenCL runtime installed.

I just cannot run the Theano example for OpenCL, mainly because I don't know how to specify my GPU. My GPU is a Radeon HD 5340/5450/5470, according to inxi. All code in the Theano documentation uses device=cuda0 and the only place where OpenCL is mentioned, it says device=openclN where N is a number.

I tried device=opencl0 and got a pygpu error saying that the correct format is opencl<int>:<int>. I have since tried any number of combinations of numbers (opencl0:0 and such), and always an GpuArrayException: Unknown error.

My system is Ubuntu 14.04 x64 and my hardware is a Toshiba Satellite, 15". I installed Theano with pip, and later installed libgpuarray following the instructions on their site.

What am I doing wrong?

like image 775
Alejandro Piad Avatar asked Jan 15 '15 19:01

Alejandro Piad


1 Answers

opencl0:0 is correct. Could you confirm that pyopencl works? You may have a problem with your opencl (or drivers/cl compiler).

However, I think Theano does not quite work with OpenCL at the moment. The current state is there is partial support, enough for "hello world", but not enough to run any significant code.

See:

https://github.com/Theano/Theano/issues/2189

https://github.com/Theano/Theano/issues/1471

https://github.com/Theano/Theano/issues/2190

https://github.com/Theano/Theano/pull/1732

To summarize, no, most stuff is not ported (including Elemwise, for example, which is a common op). I would really like to see Theano on OpenCL though. That would be a great thing for AMD to pitch in on. Soon :)

like image 146
Alex I Avatar answered Nov 01 '22 08:11

Alex I