Closed VolkerH closed 7 years ago
I just realize dthat this might be a Macbook specific problem as there are both Intel HD Graphics 4000 1536 MB and NVIDIA GeForce GT 650M 1024 MB onboard. It appears that the OpenCL should be compiled for the NVIDIA but gets compiled for the Intel HD Graphics 4000.
Actually, it's a compiler (OpenCL implementation) specific problem, in that some compilers are very sensitive to double/float casting (e.g. on my mac here, the compiler never throws error, yet in linux it does). The error you mentioned got fixed in on of the latest commits. Could you do a
pip install git+https://github.com/maweigert/spimagine
and see if the error persists? And which python you're using?
Thanks for the quick reply.
To answer the last question first:
I just installed the most current Anaconda to test spimagine
as I seem to have some insurmountable problems installing PyQt5 on my Python 2.7 installation.
Details:
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
I just did the pip install from the git as you suggested. No compiler errors.
The compiler output is supressed though (I expect that many of the warnings I observed earlier are still created) and there is a complaint about a missing .spimagine
folder in my home directory.
The code snippet from the readme.md
pasted into iPython produces a box with a gradient and I can interact with it. So it appears to be working.
However, OpenCL appears to use the Intel On-Chip GPU rather than the more powerful NVIDIA, at lease according to the output on the console. Not sure how I can force it to use NVIDIA, will google for it.
<pyopencl.Device 'HD Graphics 4000' on 'Apple' at 0x1024400>
/Users/vXXXXn/anaconda3/lib/python3.6/site-packages/pyopencl/cffi_cl.py:1476: CompilerWarning: Non-empty compiler output encountered. Set the environment variable PYOPENCL_COMPILER_OUTPUT=1 to see more.
"to see more.", CompilerWarning)
[Errno 2] No such file or directory: '/Users/vXXXXn/.spimagine'
<pyopencl.Device 'HD Graphics 4000' on 'Apple' at 0x1024400>
Qt WebEngine seems to be initialized from a plugin. Please set Qt::AA_ShareOpenGLContexts using QCoreApplication::setAttribute before constructing QGuiApplication.
/Users/vXXXXn/anaconda3/lib/python3.6/site-packages/pyopencl/cffi_cl.py:1476: CompilerWarning: Non-empty compiler output encountered. Set the environment variable PYOPENCL_COMPILER_OUTPUT=1 to see more.
"to see more.", CompilerWarning)
INFO:spimagine.gui.glwidget | saving frame as scene.png
I guess it works :)
Cool :)
As for using the nvidia card instead of the integrated GPU:
check, which platform/device number it is with
clinfo
(e.g. for on my macbook, the nvidia is the second card on the "Apple" platform)
create a file $~/spimagine
with the content
id_platform = 0
id_device = 1
where e.g. "id_device" points to the GPU to be used. (On my MacBook i have an Intel Iris and a NVidia in that order and thus "id_device=0" would be the iris, and "id_device=1" the nvidia)
Just to follow up with your last suggestion. clinfo -l
gives me this:
+-- Device #0: Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz
+-- Device #1: HD Graphics 4000
`-- Device #2: GeForce GT 650M
Playing with different id_device
numbers in ~/.spimagine
id_device=0
seems to use HD 4000, console output <pyopencl.Device 'HD Graphics 4000' on 'Apple' at 0x1024400> /Users/volkerhilsenstein/anaconda3/lib/python3.6/site-packages/pyopencl/cffi_cl.py:1476: CompilerWarning: Non-empty compiler output encountered. Set the environment variable PYOPENCL_COMPILER_OUTPUT=1 to see more. "to see more.", CompilerWarning) <pyopencl.Device 'HD Graphics 4000' on 'Apple' at 0x1024400>
id_device=1
seems to use both NVIDIA and HD4000, console output <pyopencl.Device 'HD Graphics 4000' on 'Apple' at 0x1024400> /Users/volkerhilsenstein/anaconda3/lib/python3.6/site-packages/pyopencl/cffi_cl.py:1476: CompilerWarning: Non-empty compiler output encountered. Set the environment variable PYOPENCL_COMPILER_OUTPUT=1 to see more. "to see more.", CompilerWarning) <pyopencl.Device 'GeForce GT 650M' on 'Apple' at 0x1022700>
id_device=2
which is the device number I would expect to be the one for NVIDIA based on clinfo
seems to be invalid and defaults back to the HD4000, console output <pyopencl.Device 'HD Graphics 4000' on 'Apple' at 0x1024400> /Users/volkerhilsenstein/anaconda3/lib/python3.6/site-packages/pyopencl/cffi_cl.py:1476: CompilerWarning: Non-empty compiler output encountered. Set the environment variable PYOPENCL_COMPILER_OUTPUT=1 to see more. "to see more.", CompilerWarning) WARNING:gputools.core.ocldevice | prefered platform/device (0/2) not available (device type = 4) ...choosing the best from the rest <pyopencl.Device 'HD Graphics 4000' on 'Apple' at 0x1024400>
So id_device = 1
seems to be the best option on my machine.
Yes. This is the current behaviour as any non GPU device (i.e. the Intel Core CPU) will be ignored and id_device=x
therefore corresponds to the x+1
-st GPU device as listed by clinfo. In your case id_device=1
is the second GPU, which is the Nvidia.
Furthermore, in your second example, you get two different devices listed because spimagine
imports gputools
first and the latter is using it's own default GPU (in you case the HD4000). You could change that by creating a .gputools
file on your home with the same settings id_device=1
.
Ok that makes sense.
However, even with a ~/.gputools
file specifying the same id_device=1
I receive this output when pasting the sample code:
<pyopencl.Device 'HD Graphics 4000' on 'Apple' at 0x1024400>
/Users/vXXXn/anaconda3/lib/python3.6/site-packages/pyopencl/cffi_cl.py:1476: CompilerWarning: Non-empty compiler output encountered. Set the environment variable PYOPENCL_COMPILER_OUTPUT=1 to see more.
"to see more.", CompilerWarning)
<pyopencl.Device 'GeForce GT 650M' on 'Apple' at 0x1022700>
Hm, this is weird. Could you run the following from command line and check the output?
python -c "from gputools import init_device;init_device(id_platform=0,id_device=1)"
python -c "from gputools import init_device;init_device(id_platform=0,id_device=1)"
<pyopencl.Device 'HD Graphics 4000' on 'Apple' at 0x1024400>
/Users/vXXXXn/anaconda3/lib/python3.6/site-packages/pyopencl/cffi_cl.py:1476: CompilerWarning: Non-empty compiler output encountered. Set the environment variable PYOPENCL_COMPILER_OUTPUT=1 to see more.
"to see more.", CompilerWarning)
<pyopencl.Device 'GeForce GT 650M' on 'Apple' at 0x1022700>
Strange, I cannot reproduce. How is your config file (cat ~/.gputools
) looking like?
cat ~/.gputools
id_device = 1
I also tried with id_platform = 0
as the first line (identical to my .spimagine
file) ... makes no difference
could you install the latest version and see if it persists?
pip install -U --no-deps git+https://github.com/maweigert/gputools@develop
Hi, this latest change seems to make a difference, now it reports the GeForce twice and no longer the HD 4000
pip install -U --no-deps git+https://github.com/maweigert/gputools@develop
Collecting git+https://github.com/maweigert/gputools@develop
Cloning https://github.com/maweigert/gputools (to develop) to /private/var/folders/s0/k5wgfwws0_72w111cmrwp5l40000gp/T/pip-zr2lresr-build
Installing collected packages: gputools
Found existing installation: gputools 0.2.2
Uninstalling gputools-0.2.2:
Successfully uninstalled gputools-0.2.2
Running setup.py install for gputools ... done
Successfully installed gputools-0.2.2
mac-almf4:pyflann volkerhilsenstein$ python -c "from gputools import init_device;init_device(id_platform=0,id_device=1)"
<pyopencl.Device 'GeForce GT 650M' on 'Apple' at 0x1022700>
/Users/volkerhilsenstein/anaconda3/lib/python3.6/site-packages/pyopencl/cffi_cl.py:1476: CompilerWarning: Non-empty compiler output encountered. Set the environment variable PYOPENCL_COMPILER_OUTPUT=1 to see more.
"to see more.", CompilerWarning)
<pyopencl.Device 'GeForce GT 650M' on 'Apple' at 0x1022700>
Ok! Actually that was a bug in the pypi version that got introduced by porting the code to be python3 compatible (where the semantics of configparser changed). I'll update the pypi distro. Thanks for finding that out!
On my Macbook Pro Retina (2012) I receive build errors from the OpenCL compiler for the following statements in
convolve_2d.c
float val = exp(-5.f*(ht-Nh/2.)*(ht-Nh/2.)/Nh/Nh)
When I change
2.
to2.f
the convole kernel compiles, but I'm not sure the results are correct.