psychopy.org | Reference | Downloads | Github

Gamma problem in v1.90.2


#1

Hi all,

Using Psychopy v1.90.2 (running on Ubuntu 18.04) I am getting the following error message (below) when I attempt to run any code that involves a window (including the demos).

The ‘shapes.py’ demo briefly flashes two black windows and then I get this output:

Problem compiling: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/PsychoPy-1.90.2- 
py2.7.egg/psychopy/demos/coder/stimuli/shapes.pyc.140084747607664'
##### Running: /usr/local/lib/python2.7/dist-packages/PsychoPy-1.90.2- 
py2.7.egg/psychopy/demos/coder/stimuli/shapes.py #####
0.6906     WARNING     Monitor specification not found. Creating a temporary one...
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/PsychoPy-1.90.2- 
py2.7.egg/psychopy/demos/coder/stimuli/shapes.py", line 15, in <module>
win = visual.Window(size=(500, 400), units='height')
File "/usr/local/lib/python2.7/dist-packages/PsychoPy-1.90.2-py2.7.egg/psychopy/visual/window.py", line 
375,  in __init__
self.backend = backends.getBackend(win=self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/PsychoPy-1.90.2- 
py2.7.egg/psychopy/visual/backends/__init__.py", line 32, in getBackend
return Backend(win, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/PsychoPy-1.90.2- 
py2.7.egg/psychopy/visual/backends/pygletbackend.py", line 227, in __init__
self._origGammaRamp = self.getGammaRamp()
File "/usr/local/lib/python2.7/dist-packages/PsychoPy-1.90.2- 
py2.7.egg/psychopy/visual/backends/pygletbackend.py", line 326, in getGammaRamp
return getGammaRamp(self.screenID, self.xDisplay)
File "/usr/local/lib/python2.7/dist-packages/PsychoPy-1.90.2- 
py2.7.egg/psychopy/visual/backends/gamma.py", line 120, in getGammaRamp
rampSize = getGammaRampSize(screenID, xDisplay=xDisplay)
File "/usr/local/lib/python2.7/dist-packages/PsychoPy-1.90.2- 
py2.7.egg/psychopy/visual/backends/gamma.py", line 285, in getGammaRampSize
raise RuntimeError("Gamma ramp size is reported as 0.")
RuntimeError: Gamma ramp size is reported as 0.
Exception AttributeError: "'NoneType' object has no attribute 'close'" in <bound method Window.__del__ of 
<psychopy.visual.window.Window object at 0x7f2ad5155990>> ignored

I get the following message when I try and run the Gamma Calibration from the Monitor Center:

Exception AttributeError: "'NoneType' object has no attribute 'close'" in <bound method Window.__del__ of 
<psychopy.visual.window.Window object at 0x7f2ad5155990>> ignored
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/PsychoPy-1.90.2- 
py2.7.egg/psychopy/monitors/MonitorCenter.py", line 817, in onCalibGammaBtn
screen=screen)
File "/usr/local/lib/python2.7/dist-packages/PsychoPy-1.90.2-py2.7.egg/psychopy/monitors/calibTools.py",line 955, in getLumSeries
bitsMode=bitsMode, screen=screen)
File "/usr/local/lib/python2.7/dist-packages/PsychoPy-1.90.2-py2.7.egg/psychopy/visual/window.py", line 
375, in __init__
self.backend = backends.getBackend(win=self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/PsychoPy-1.90.2- 
py2.7.egg/psychopy/visual/backends/__init__.py", line 32, in getBackend
return Backend(win, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/PsychoPy-1.90.2- 
py2.7.egg/psychopy/visual/backends/pygletbackend.py", line 227, in __init__
self._origGammaRamp = self.getGammaRamp()
File "/usr/local/lib/python2.7/dist-packages/PsychoPy-1.90.2- 
py2.7.egg/psychopy/visual/backends/pygletbackend.py", line 326, in getGammaRamp
return getGammaRamp(self.screenID, self.xDisplay)
File "/usr/local/lib/python2.7/dist-packages/PsychoPy-1.90.2- 
py2.7.egg/psychopy/visual/backends/gamma.py", line 120, in getGammaRamp
rampSize = getGammaRampSize(screenID, xDisplay=xDisplay)
File "/usr/local/lib/python2.7/dist-packages/PsychoPy-1.90.2- 
py2.7.egg/psychopy/visual/backends/gamma.py", line 285, in getGammaRampSize
raise RuntimeError("Gamma ramp size is reported as 0.")
RuntimeError: Gamma ramp size is reported as 0.

For the Gamma Calibration the black window just hangs there and doesn’t close.

Any ideas? I read that it may be to do with my graphics card drivers. I reinstalled them but the issue remains.

Cheers,
Jon


#2

Update: I switched window type from pyglet to pygame and everything is running ok now.

Cheers,
Jon


#3

Thanks for letting us know. I think this raises an issue with some code added by @djmannion that aims to check the length of the gamma table before creating one. I’m not sure why it would ever return a size of zero, but it looks like a case we need to understand.


#4

Yes, I have encountered this (see here).

In my experience, no gamma correction will work when the LUT size is being returned as 0. For me, it was with an Intel card and using the kernel drivers only. When I installed xf86-video-intel, it gave a sensible LUT size. @Jon1, is yours an Intel card?

At the time, I said “One potential issue is what to do when the LUT size is reported as 0. Here, I’m raising an error - but I could see an argument for a warning instead.” (here). I guess I’m still in favour of fixing the hardware issue (if possible) rather than proceeding without gamma correction, but, as before, I think a warning would also be fine.


#5

Thanks for the info. Yes, it’s an Intel card and it’s using a kernal driver (i915) [info below]:

description: VGA compatible controller
product: 2nd Generation Core Processor Family Integrated Graphics Controller
vendor: Intel Corporation
physical id: 2
bus info: pci@0000:00:02.0
version: 09
width: 64 bits
clock: 33MHz
capabilities: vga_controller bus_master cap_list rom
configuration: driver=i915 latency=0

#6

Hi all,

I just came across the same problem:

>   File "/home/usb/miniconda3/lib/python2.7/site-packages/psychopy/visual/window.py", line 375, in __init__
>     self.backend = backends.getBackend(win=self, *args, **kwargs)
>   File "/home/usb/miniconda3/lib/python2.7/site-packages/psychopy/visual/backends/__init__.py", line 32, in getBackend
>     return Backend(win, *args, **kwargs)
>   File "/home/usb/miniconda3/lib/python2.7/site-packages/psychopy/visual/backends/pygletbackend.py", line 227, in __init__
>     self._origGammaRamp = self.getGammaRamp()
>   File "/home/usb/miniconda3/lib/python2.7/site-packages/psychopy/visual/backends/pygletbackend.py", line 326, in getGammaRamp
>     return getGammaRamp(self.screenID, self.xDisplay)
>   File "/home/usb/miniconda3/lib/python2.7/site-packages/psychopy/visual/backends/gamma.py", line 120, in getGammaRamp
>     rampSize = getGammaRampSize(screenID, xDisplay=xDisplay)
>   File "/home/usb/miniconda3/lib/python2.7/site-packages/psychopy/visual/backends/gamma.py", line 285, in getGammaRampSize
>     raise RuntimeError("Gamma ramp size is reported as 0.")
> RuntimeError: Gamma ramp size is reported as 0.
> Exception AttributeError: "'NoneType' object has no attribute 'close'" in <bound method Window.__del__ of <psychopy.visual.window.Window object at 0x7f5a4e5e7bd0>> ignored

on Ubuntu 18.04 with an Intel graphics chip

Beschreibung: VGA compatible controller
       Produkt: Intel Corporation
       Hersteller: Intel Corporation
       Physische ID: 2
       Bus-Informationen: pci@0000:00:02.0
       Version: 0b
       Breite: 64 bits
       Takt: 33MHz
       Fähigkeiten: vga_controller bus_master cap_list rom
       Konfiguration: driver=i915 latency=0
       Ressourcen: irq:125 memory:900000

Is there a solution other than switching to pygame? With pygame, the text stimuli look terrible in my experiment (font, spacing and one simply disappeared).

Apparently the i915 driver is contained in the installed xf86-video-intel. Do you have an advice how I could fix the problem? Or, how I could fix the ugly look of pygame?

Cheers,
Constantin


#7

Is there a solution other than switching to pygame? With pygame, the text stimuli look terrible in my experiment (font, spacing and one simply disappeared).

You can try the new ‘glfw’ backend by specifying 'winType=‘glfw’. However, you need to install additional libraries to use it, such as pyGLFW (https://github.com/FlorianRhiem/pyGLFW) which is up on PIP and the GLFW runtime libraries (http://www.glfw.org/). On Ubuntu, these libraries are likely available through your package manager.

The GLFW backend handles gamma tables differently so it might fix the issues you are having. Text rendering should look fine on the GLFW backend since it shares most of its rendering code with Pyglet.


#8

Hi, thank you for your reply!

I tried your suggestion and installed the glfw backend (glfw and pyglfw on PIP). It does solve the issue with the GammaRamp, but it unfortunately leads to new problems:

First, the mouse can no longer be initialzed:

  File "/home/usb/Dokumente/experiments/myexperiment.py", line 60, in <module>
    mouse = event.Mouse()
  File "/home/usb/miniconda3/lib/python2.7/site-packages/psychopy/event.py", line 578, in __init__
    self.setVisible(visible)
  File "/home/usb/miniconda3/lib/python2.7/site-packages/psychopy/event.py", line 772, in setVisible
    w.set_mouse_visible(visible)
AttributeError: 'LP__GLFWwindow' object has no attribute 'set_mouse_visible'

Commenting out the mouse initialization temporarily for more debugging there is a new problem with text stimuli. Apparently, a pygame font is used but not found?

3.5219     ERROR     Couldn't find font  on the system. Using freesansbold.ttf instead! Font names should be written as concatenated names all in lower case.
e.g. 'arial', 'monotypecorsiva', 'rockwellextra', ...
Traceback (most recent call last):
  File "/home/usb/Dokumente/experiments/myexperiment.py", line 70, in <module>
    execfile("mylibrary.py")
  File "mylibrary.py", line 13, in <module>
    okText = visual.TextStim(win, text = 'OK', height = 120/2.71, color='black', pos=(.4*winwidth,-.4*winheight))
  File "/home/usb/miniconda3/lib/python2.7/site-packages/psychopy/visual/text.py", line 159, in __init__
    self.setHeight(height, log=False)  # calls setFont() at some point
  File "/home/usb/miniconda3/lib/python2.7/site-packages/psychopy/visual/text.py", line 207, in setHeight
    setAttribute(self, 'height', height, log)
  File "/home/usb/miniconda3/lib/python2.7/site-packages/psychopy/tools/attributetools.py", line 141, in setAttribute
    setattr(self, attrib, value)
  File "/home/usb/miniconda3/lib/python2.7/site-packages/psychopy/tools/attributetools.py", line 32, in __set__
    newValue = self.func(obj, value)
  File "/home/usb/miniconda3/lib/python2.7/site-packages/psychopy/visual/text.py", line 202, in height
    self.setFont(self.font, log=False)
  File "/home/usb/miniconda3/lib/python2.7/site-packages/psychopy/visual/text.py", line 270, in setFont
    setAttribute(self, 'font', font, log)
  File "/home/usb/miniconda3/lib/python2.7/site-packages/psychopy/tools/attributetools.py", line 141, in setAttribute
    setattr(self, attrib, value)
  File "/home/usb/miniconda3/lib/python2.7/site-packages/psychopy/tools/attributetools.py", line 32, in __set__
    newValue = self.func(obj, value)
  File "/home/usb/miniconda3/lib/python2.7/site-packages/psychopy/visual/text.py", line 262, in font
    bold=self.bold)
  File "/home/usb/miniconda3/lib/python2.7/site-packages/pygame/sysfont.py", line 320, in SysFont
    return constructor(fontname, size, set_bold, set_italic)
  File "/home/usb/miniconda3/lib/python2.7/site-packages/pygame/sysfont.py", line 243, in font_constructor
    font = pygame.font.Font(fontpath, size)
pygame.error: font not initialized

I can imagine to install a missing font or to switch to a different one, but I have no clue how to deal with the mouse problem. Have you had anything like this before when using pyglfw?


#9

For mouse visibility, use win.setMouseVisibility(True/False) instead. The font issue is strange since I’m sure we got that working. A hack would be to change all lines in psychopy/text.py where the backend is checked from if self.win.winType == "pyglet": to if self.win.winType in ["pyglet", "glfw"]:.

The GLFW backend is very new and not well integrated/documented at this point, but it’s worth using to circumvent some issues with Pyglet/Pygame.


Why do I need to flip the window twice to see by buffer?
#10

Hi, thanks again for your help. Unfortunately, I didn’t have enough time to work around the issues from switching to the GLFW backend. Instead, I downloaded two older versions of gamma.py and pygletbackend.py from GitHub (5096f07674), from before the works on the gamma tables in February. I replaced visuals/backends/gamma.py and visuals/backends/pygletbackend.py in my installation.

For my purpose, that was the easiest solution.


#11

I encounter the same issue on Ubuntu 16.04 with PsychoPy 1.90.2 installed in a conda environment following the steps listed here: http://psychopy.org/installation.html

The output of my lscpu command:

Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                8
On-line CPU(s) list:   0-7
Thread(s) per core:    2
Core(s) per socket:    4
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 142
Model name:            Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
Stepping:              10
CPU MHz:               800.021
CPU max MHz:           4200,0000
CPU min MHz:           400,0000
BogoMIPS:              4224.00
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              8192K
NUMA node0 CPU(s):     0-7
Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp flush_l1d


#12

For me on ubuntu 18.04, with psychopy installed from pip into /usr/lib/python2.7/dist-packages, and default graphics drivers, suppressing the exception by editing lines 286-287 in /usr/lib/python2.7/dist-packages/psychopy/visual/backends/gamma.py like below made the runtime error go away, and allowed my experiment to run: comment out line 286, and add ‘pass’ on a new line below:

#raise RuntimeError("Gamma ramp size is reported as 0.")
pass

#13

THANK YOU!!! This fixed my 18.04 problem.


#14

Just as a note, I am still having this problem with PsychoPy==1.90.3 and on Ubuntu 18.04 when using my integrated graphics chip (Intel® HD Graphics 630 (Kaby Lake GT2)) …

However, the problem is solved as soon as I switch to my Nvidia graphics card (Quadro M1200/PCIe/SSE2, Nvidia driver version 390.77 as installed via the Ubuntu Software Center).


#15

a solution for this problem is given by @djmannion on github.

I think it should be enough to put the following in /etc/X11/xorg.conf.d/20-intel.conf :

Section "Device"
    Identifier "Intel Graphics"
    Driver "intel"
EndSection

In my case this file didn’t exist, so I created it, rebooted, and then everything worked under pyglet again.