# Optimizing 2 gpu use with PTB

**URL:** <https://psychtoolbox.discourse.group/t/optimizing-2-gpu-use-with-ptb/2962>\
**Category:** Hardware\
**Tags:** linux, gpu\
**Created:** [January 16, 2020, 8:03pm UTC](https://psychtoolbox.discourse.group/t/optimizing-2-gpu-use-with-ptb/2962 "2020-01-16T20:03:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aamir907](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@aamir907](https://psychtoolbox.discourse.group/u/aamir907)\
**Post date:** [January 16, 2020, 8:03pm UTC](https://psychtoolbox.discourse.group/t/optimizing-2-gpu-use-with-ptb/2962/1 "2020-01-16T20:03:42Z")

</div>

Similar to another unresolved issue on here; I’m experiencing trouble with some of the PTB demos which doesn’t bode well for the experiments we have lined up at the lab.

After running demos such as TotallyMinimalDemo;  
I’m left with an all-black screen I cannot escape from.

I have a setup with 2-GPUS on one monitor (using Linux). The graphics cards are both the same, but we hope to have individual use for both.

I was wondering why this issue was arising- and how I can optimally go through the tutorials without facing a graphics issue.

If it’s any help, here’s the output regarding my gpuDevice info:

Lab 1:

ans =

```
CUDADevice with properties:

                    Name: 'Quadro P620'
                   Index: 1
       ComputeCapability: '6.1'
          SupportsDouble: 1
           DriverVersion: 10.1000
          ToolkitVersion: 10.1000
      MaxThreadsPerBlock: 1024
        MaxShmemPerBlock: 49152
      MaxThreadBlockSize: [1024 1024 64]
             MaxGridSize: [2.1475e+09 65535 65535]
               SIMDWidth: 32
             TotalMemory: 2.0886e+09
         AvailableMemory: 1.6874e+09
     MultiprocessorCount: 4
            ClockRateKHz: 1354000
             ComputeMode: 'Default'
    GPUOverlapsTransfers: 1
  KernelExecutionTimeout: 1
        CanMapHostMemory: 1
         DeviceSupported: 1
          DeviceSelected: 1

```

Lab 2:

ans =

```
CUDADevice with properties:

                    Name: 'Quadro P620'
                   Index: 2
       ComputeCapability: '6.1'
          SupportsDouble: 1
           DriverVersion: 10.1000
          ToolkitVersion: 10.1000
      MaxThreadsPerBlock: 1024
        MaxShmemPerBlock: 49152
      MaxThreadBlockSize: [1024 1024 64]
             MaxGridSize: [2.1475e+09 65535 65535]
               SIMDWidth: 32
             TotalMemory: 2.0975e+09
         AvailableMemory: 1.8144e+09
     MultiprocessorCount: 4
            ClockRateKHz: 1354000
             ComputeMode: 'Default'
    GPUOverlapsTransfers: 1
  KernelExecutionTimeout: 0
        CanMapHostMemory: 1
         DeviceSupported: 1
          DeviceSelected: 1
```

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [January 17, 2020, 10:29pm UTC](https://psychtoolbox.discourse.group/t/optimizing-2-gpu-use-with-ptb/2962/2 "2020-01-17T22:29:01Z")

</div>

Ok, please rephrase your message and give more details about your setup. I don’t understand, e.g., the description “Two gpu’s on one monitor”.

In general NVidia gpu’s are not recommended for optimal plug & play use on Linux, so if something doesn’t work, i can’t help you much. AMD and Intel provide gpu’s with high quality open-source drivers.

---

<div class="post-metadata">

**Author:** ![aamir907](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@aamir907](https://psychtoolbox.discourse.group/u/aamir907)\
**Post date:** [January 21, 2020, 8:28pm UTC](https://psychtoolbox.discourse.group/t/optimizing-2-gpu-use-with-ptb/2962/3 "2020-01-21T20:28:56Z")

</div>

I have 2 separate nvidia gpu’s installed on the same computer, hooked up to one monitor.

They both are p620 quadro series gpu’s with nvidia-410 drivers installed.

My issue is that I’ve been having trouble running many of the PTB demos; often being left with an inescapable black screen after commands such as:

% Clear the workspace and the screen  
sca;  
close all;  
clearvars;  
% Here we call some default settings for setting up Psychtoolbox  
PsychDefaultSetup(2);  
% Get the screen numbers  
screens = Screen(‘Screens’);  
% Draw to the external screen if avaliable  
screenNumber = max(screens);  
% Define black and white  
white = WhiteIndex(screenNumber);  
black = BlackIndex(screenNumber);  
grey = white / 2;  
inc = white - grey;  
% Open an on screen window  
[window, windowRect] = PsychImaging(‘OpenWindow’, screenNumber, grey);

This command line is usually where I receive the most trouble.  
I’m running Linux of an i7 Dell.

Would restoring a Windows OS be the best option to continue with PTB?

Asham A.

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [January 29, 2020, 3:11am UTC](https://psychtoolbox.discourse.group/t/optimizing-2-gpu-use-with-ptb/2962/4 "2020-01-29T03:11:52Z")

</div>

Why do you need 2 gpu’s connected to one monitor?

NVidia gpu’s are generally not recommended for optimal use with PTB. There’s little i could do to help in case of trouble, like here. You could switch to the nouveau open-source driver, but then performance would tank with this modern NVidia gpu.

Is it set up in some SLI configuration? If so, that might be some cause for the problem. I never got to test it, but my assumption was that that would rather hurt than help with PTB. Also PTB is not prepared to deal with multi-gpu setups, unless they are certain types of dual-gpu hybrid graphics laptops. Maybe full log output of PTB at Screen verbosity 10 would help, e.g., using the “diary on” command to capture it into a diary.txt file. Or using PsychDebugWindowConfiguration to see something apart from black. Also maybe the XOrg.0.log file and any custom xorg.conf file if any.
