hughperkins / DeepCL

OpenCL library to train deep convolutional neural networks
Mozilla Public License 2.0
866 stars 200 forks source link

Is it possible to choose gpu? How can I choose it in Python? #78

Closed NKUCodingCat closed 8 years ago

NKUCodingCat commented 8 years ago

I have a laptop have both Intel HD4400 and AMD R9 M270X graphic card, When I run deepcl_unittests, it told me that it is running on Intel HD4400, so is it possible to use R9 M270X for it?

Meanwhile, sorry for my poor English :)

merceyz commented 8 years ago

I don't know if this works for the unit test but for the others this should do it gpuindex=X where X is the card index you want to use

https://github.com/hughperkins/DeepCL/blob/master/doc/Commandline.md

NKUCodingCat commented 8 years ago

@merceyz It is useless for unittest.....I am going to try it on trainning MNIST. By the way, how can I use this feature in Python?

Anyway, thank you very much

merceyz commented 8 years ago

I honestly got no clue. You'll have to wait for @hughperkins

hughperkins commented 8 years ago

For deepcl_unittests, addressed in 8acd97d What platform are you on? Do you need a binary release build?

hughperkins commented 8 years ago

For python, see python/examples/choose_gpu.py

Output on my machine:

(env3) ubuntu@peach:~/git/DeepCL/python$ python examples/choose_gpu.py 
major_version 3
major vresion 3
Using NVIDIA Corporation , OpenCL platform: NVIDIA CUDA
Using OpenCL device: GeForce 940M
initializing clblas
Using Intel , OpenCL platform: Intel Gen OCL Driver
Using OpenCL device: Intel(R) HD Graphics 5500 BroadWell U-Processor GT2
initializing clblas
clblas teardown
clblas teardown

(note to self: fix that weird mis-spelled major version message...)

hughperkins commented 8 years ago

(weird mis-spelled major version message removed in ea5fd2d )

hughperkins commented 8 years ago

(Updated Windows binaries here http://deepcl.hughperkins.com/Downloads/ v8.5.1)

hughperkins commented 8 years ago

(and also some python packages are in the process of building into https://pypi.python.org/pypi/DeepCL/8.5.1 )

NKUCodingCat commented 8 years ago
>>> import PyDeepCL
major_version 2
major vresion 2
>>> PyDeepCL.DeepCL()
Using Intel(R) Corporation , OpenCL platform: Intel(R) OpenCL
Using OpenCL device: Intel(R) HD Graphics 4400
initializing clblas
<PyDeepCL.DeepCL object at 0x02E950D0>
>>> PyDeepCL.DeepCL(gpuindex=1)
Using Advanced Micro Devices, Inc. , OpenCL platform: AMD Accelerated Parallel Processing
Using OpenCL device: Capeverde
initializing clblas
clblas teardown
<PyDeepCL.DeepCL object at 0x02E950E0>

It works! Thank you very much for your help. But what does clblas teardown mean?

merceyz commented 8 years ago

That's when it's done, it free's all resources

hughperkins commented 8 years ago

Right, I should probalby remove that.

hughperkins commented 8 years ago

(Removed in ebf2792 )

NKUCodingCat commented 8 years ago

Well, one more odd behavior is when I call a gpu which does not exist, Python.exe will crash immediately. Seriously it's reasonable, but not friendly.

>>> import PyDeepCL
major_version 2
major vresion 2
>>> PyDeepCL.DeepCL(gpuindex=0)
Using Advanced Micro Devices, Inc. , OpenCL platform: AMD Accelerated Parallel Processing
Using OpenCL device: Devastator
<PyDeepCL.DeepCL object at 0x036690D0>
>>> PyDeepCL.DeepCL(gpuindex=65536)

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

And jump a Dialog said "Python has Stopped, Windows is seraching for solution......"

(there should have an screenshot but nothing, thanks for The GFW)

hughperkins commented 8 years ago

Addressed in 6833b52 , hopefully, it is currently building as v8.5.2