Comments (5)
Hello,
The answer is double.
From my experience, an implementation, on the same machine/reboot/configuration always returns it's devices in the same order, the enumerator is undefined but not random (in my experience). So I use the order of the devices returned by clGetDeviceIDs to differentiate them. In mpi a modulo on mpi rank usually does the trick (provided process on the same node have consecutive ranks).
Should you need to identify precisely the device (to track it across reboot, driver version and so on) you can easily dos so in opencl_ruby_ffi. Here is an irb example:
> require 'opencl_ruby_ffi'
=> true
> OpenCL::platforms.first.devices.map(&:name)
=> ["Tesla K40c", "Tesla K40c"]
> class OpenCL::Device
> PCI_BUS_ID_NV = 0x4008
> eval get_info("Device", :cl_uint, "PCI_BUS_ID_NV")
> end
=> :pci_bus_id_nv
> OpenCL::platforms.first.devices.map(&:pci_bus_id_nv)
=> [5, 130]
> OpenCL::platforms.first.devices.first.pci_bus_id_nv
=> 5
Which correspond to the list obtained through nvidia-smi:
Mon Nov 16 10:48:08 2015
+------------------------------------------------------+
| NVIDIA-SMI 340.32 Driver Version: 340.32 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 Tesla K40c Off | 0000:05:00.0 Off | 0 |
| 23% 34C P8 20W / 235W | 23MiB / 11519MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
| 1 Tesla K40c Off | 0000:82:00.0 Off | 0 |
| 23% 36C P8 20W / 235W | 23MiB / 11519MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Compute processes: GPU Memory |
| GPU PID Process name Usage |
|=============================================================================|
| No running compute processes found |
+-----------------------------------------------------------------------------+
0x82 == 130
Note that they are returned in the same order that nvidia-smi does.
Don't hesitate if you have more questions.
Best regards,
Brice
from opencl-ruby.
Brilliant! Thanks for your help, this is exactly what I was trying to
achieve.
Best regards,
Jorge
On Mon, 2015-11-16 at 01:52 -0800, Brice Videau wrote:
Hello,
The answer is double.
From my experience, an implementation, on the same
machine/reboot/configuration always returns it's devices in the same
order, the enumerator is undefined but not random (in my experience).
So
I use the order of the devices returned by clGetDeviceIDs to
differentiate them. In mpi a modulo on mpi rank usually does the
trick
(provided process on the same node have consecutive ranks).Should you need to identify precisely the device to track it across
reboot, driver version and so on you can easily dos so in
opencl_ruby_ffi. Here is an irb example:require 'opencl_ruby_ffi'
=> true
OpenCL::platforms.first.devices.map(&:name)
=> ["Tesla K40c", "Tesla K40c"]
class OpenCL::Device
PCI_BUS_ID_NV = 0x4008
eval get_info("Device", :cl_uint, "PCI_BUS_ID_NV")
end
=> :pci_bus_id_nv
OpenCL::platforms.first.devices.map(&:pci_bus_id_nv)
=> [5, 130]Which correspond to the list obtained through nvidia-smi:
Mon Nov 16 10:48:08 2015
+------------------------------------------------------+
| NVIDIA-SMI 340.32 Driver Version: 340.32 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile
Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util
Compute M. |
|===============================+======================
+======================|
| 0 Tesla K40c Off | 0000:05:00.0 Off
| 0 |
| 23% 34C P8 20W / 235W | 23MiB / 11519MiB | 0%
Default |
+-------------------------------+----------------------+----------------------+
| 1 Tesla K40c Off | 0000:82:00.0 Off
| 0 |
| 23% 36C P8 20W / 235W | 23MiB / 11519MiB | 0%
Default |
+-------------------------------+----------------------+----------------------++-----------------------------------------------------------------------------+
| Compute processes: GPU
Memory |
| GPU PID Process name
Usage |
|
=============================================================================|
| No running compute processes
found |
+-----------------------------------------------------------------------------+0x82 == 130
Note that they are returned in the same order that nvidia-smi does.
Don't hesitate if you have more questions.
Best regards,
Brice
On 16/11/2015 07:55, mtbikerjc wrote:
Hello,
I'm trying to create a load balancer that can dispatch tasks to
various GPUs if they're present. To do this, I need to launch one
process per GPU device, so that this process can dispatch jobs to
its
GPU. However, OpenCL itself doesn't have a way of providing a
unique
ID that is unique to a given GPU device. It only gives you
information
on the "type" of device or the OpenCL version number, which doesn't
help me. I did some searching around, and saw that for NVidia
devices,
the device-unique IDs need to be queried using the
CL_DEVICE_PCI_BUS_ID_NV token of the cl_nv_device_a ttribute_query
extension.I found that here: https://anteru.net/2014/08/01/2483/
Is there a way to do this with opencl-ruby? I can see the
cl_nv_device_attribute_query extension when I run
"device.extensions"
but can't seem to find a way to query the
cl_nv_device_attribute_query
extension.Thanks for your help!
- Jorge
—
Reply to this email directly or view it on GitHub
#8.—
Reply to this email directly or view it on GitHub.
from opencl-ruby.
In next version ( > 1.3.0 ) cl_nv_device_attribute_query extension (and many others) will be directly supported. If you query a device that does not support it you will raise the following
> require 'opencl_ruby_ffi'
=> true
> OpenCL::platforms.last.devices.map(&:name)
=> ["Intel(R) Core(TM) i7-2760QM CPU @ 2.40GHz"]
> OpenCL::platforms.last.devices.map(&:pci_bus_id_nv)
OpenCL::Error::INVALID_VALUE: -30
from /var/lib/gems/2.3.0/gems/opencl_ruby_ffi-1.2.2/lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb:237:in `error_check'
from (eval):4:in `pci_bus_id_nv'
from (irb):4:in `map'
from (irb):4
from /usr/bin/irb:11:in `<main>'
If you still need to add support for an extension the syntax would be slightly changed (using the previous and obsolete example):
> require 'opencl_ruby_ffi'
=> true
> OpenCL::platforms.first.devices.map(&:name)
=> ["Tesla K40c", "Tesla K40c"]
> module OpenCL
> using OpenCLRefinements if RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
> class Device
> PCI_BUS_ID_NV_NEW = 0x4008
> eval get_info("Device", :cl_uint, "PCI_BUS_ID_NV_NEW")
> end
> end
=> :pci_bus_id_nv_new
> OpenCL::platforms.first.devices.map(&:pci_bus_id_nv_new)
=> [5, 130]
> OpenCL::platforms.first.devices.first.pci_bus_id_nv_new
=> 5
Regards,
Brice
from opencl-ruby.
Major thanks for the heads up! I'll implement these changes when I
update my gem.
Cheers,
JorgeOn Mon, 2016-05-09 at 09:15 -0700, Brice Videau wrote:
In next version ( > 1.3.0 ) cl_nv_device_attribute_query extension
(and many others) will be directly supported. If you query a device
that does not support it you will raise the followingrequire 'opencl_ruby_ffi'
'
=> true
OpenCL::platforms.last.devices.map(&:name)
=> ["Intel(R) Core(TM) i7-2760QM CPU @ 2.40GHz"]
OpenCL::platforms.last.devices.map(&:pci_bus_id_nv)
OpenCL::Error::INVALID_VALUE: -30
from /var/lib/gems/2.3.0/gems/opencl_ruby_ffi-
1.2.2/lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb:237:in
error_check' from (eval):4:in
pci_bus_id_nv'
from (irb):4:inmap' from (irb):4 from /usr/bin/irb:11:in
If you still need to add support for an extension the syntax would be
slightly changed (using the previous and obsolete example):
require 'opencl_ruby_ffi'
=> true
OpenCL::platforms.first.devices.map(&:name)
=> ["Tesla K40c", "Tesla K40c"]
module OpenCL
using OpenCLRefinements if
RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
class Device
PCI_BUS_ID_NV_NEW = 0x4008
eval get_info("Device", :cl_uint, "PCI_BUS_ID_NV_NEW")
end
end
=> :pci_bus_id_nv_new
OpenCL::platforms.first.devices.map(&:pci_bus_id_nv_new)
=> [5, 130]
OpenCL::platforms.first.devices.first.pci_bus_id_nv_new
=> 5
Regards,
Brice
—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
from opencl-ruby.
Final version:
> require 'opencl_ruby_ffi'
=> true
> class OpenCL::Device
> using OpenCLRefinements if RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
> PCI_BUS_ID_NV_NEW = 0x4008
> get_info("Device", :cl_uint, "PCI_BUS_ID_NV_NEW")
> end
=> :pci_bus_id_nv_new
> OpenCL::platforms.first.devices.map(&:pci_bus_id_nv_new)
=> [5, 130]
eval is not needed anymore.
from opencl-ruby.
Related Issues (13)
- Running opencl-ruby for the first time HOT 12
- Running opencl_ruby_ffi in a forked process HOT 6
- support for Numo::NArray HOT 2
- slow to load HOT 6
- throw permission denied error HOT 3
- new gem using this was released HOT 1
- clBLAS FFI or use this one? HOT 15
- Performance Benchmarks HOT 10
- `create_command_queue': uninitialized constant Thread::Queue::PROPERTIES HOT 2
- Passing A Mixed-Type Array to and from the GPU HOT 6
- How to stop warning 'Warning OpenCL 1.x loader detected!' HOT 2
- gem install opencl_ruby_ffi fails HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opencl-ruby.