bugGNU Octave - Bugs: bug #58125, rgb2gray causes high cpu and will...

 
 

bug #58125: rgb2gray causes high cpu and will run forever without any errors

Submitter:  Eli Chan <freetogo>
Submitted:  Mon 06 Apr 2020 02:01:12 PM UTC
   
 
Category:  Octave Function Severity:  2 - Minor
Priority:  3 - Low Item Group:  Unexpected Error or Warning
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 5.2.0 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 07 Apr 2020 01:43:59 PM UTC, comment #15: 

Dmitri.

You are right. The hangup could be fixed by removing  all the openblas and using only blas
i.e.
sudo apt-get remove libopenblas0*
sudo apt-get install libblas*

Thank you very much.

Eli

comment #7:

> As I mentioned -- your blas (openblas) is broken.
>
> Dmitri.
> --
>

Eli Chan <freetogo>
Mon 06 Apr 2020 10:04:39 PM UTC, comment #14: 

No need to use 64bit indexing. But why 32bit indexing is not supported?

comment #13:

> Can it be the problem with configure? I note that
>  
> 64-bit BLAS array dims and indexing:  no
>
> But I don't know how to set it to yes.

Eli Chan <freetogo>
Mon 06 Apr 2020 09:31:52 PM UTC, comment #13: 

Can it be the problem with configure? I note that
 
64-bit BLAS array dims and indexing:  no

But I don't know how to set it to yes.

Eli Chan <freetogo>
Mon 06 Apr 2020 09:08:36 PM UTC, comment #12: 

The easy check is to override the suspected blas library with another one. I usually use LD_PRELOAD trick, on Ubuntu (I think) you can load alternative. The reference blas seems to be a safe bet.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Mon 06 Apr 2020 08:59:54 PM UTC, comment #11: 

We had a recent discussion on the help list:

https://lists.gnu.org/archive/html/help-octave/2020-03/msg00315.html

I assume those are related. I do not use ubuntu.

Also the symptoms are very much what happens in mis-optimised
blas library, I have seen those in fedora, macOS Veclib etc...

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Mon 06 Apr 2020 08:53:37 PM UTC, comment #10: 

Dmitri - do you have a reference to an active or already-fixed Ubuntu bug report about this OpenBLAS problem? This is the first I've seen anything about it.

Mike Miller <mtmiller>
Group Member
Mon 06 Apr 2020 08:29:27 PM UTC, comment #9: 

the following two products will not hang Octave
octave:1> a=ones(1e2,3)*ones(3,1);
octave:2> a=ones(1e3,3)*ones(3,1);

but your product will hang Octave with high cpu loading.
octave:3> a=ones(1e4,3)*ones(3,1);


Eli Chan <freetogo>
Mon 06 Apr 2020 06:26:27 PM UTC, comment #8: 

Does the following simple product hang Octave for you ?


a = ones (1e4, 3) * ones (3, 1);


Pantxo Diribarne <pantxo>
Group Member
Mon 06 Apr 2020 05:22:28 PM UTC, comment #7: 

As I mentioned -- your blas (openblas) is broken.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Mon 06 Apr 2020 05:06:36 PM UTC, comment #6: 

converting "lena_64.png" to gray using rgb2gray takes less than 1 second but converting "lena_80.png" using rgb2gray takes forever to run with very high cpu loading.

lena_64.png is OK
lena_80.png is Not OK


Eli Chan <freetogo>
Mon 06 Apr 2020 04:58:44 PM UTC, comment #5: 

if I use a ridiculously small png file, it will work.
the shape of img is: 64x48x3

Anything larger than that will stuck at  I = rgb * xform;


octave:2> dbstop rgb2gray
ans =  45
octave:3> img_gray=rgb2gray(img)
stopped in /usr/local/share/octave/5.2.0/m/image/rgb2gray.m at line 45
45:   if (nargin != 1)
debug> dbstep
stopped in /usr/local/share/octave/5.2.0/m/image/rgb2gray.m at line 49
49:   is_int = isinteger (rgb);
debug> dbstep
stopped in /usr/local/share/octave/5.2.0/m/image/rgb2gray.m at line 50
50:   if (is_int)
debug> dbstep
stopped in /usr/local/share/octave/5.2.0/m/image/rgb2gray.m at line 51
51:     cls = class (rgb);
debug> dbstep
stopped in /usr/local/share/octave/5.2.0/m/image/rgb2gray.m at line 54
54:     = colorspace_conversion_input_check ("rgb2gray", "RGB", rgb);
debug> dbstep
stopped in /usr/local/share/octave/5.2.0/m/image/rgb2gray.m at line 58
58:   xform = [0.298936; 0.587043; 0.114021];
debug> dbstep
stopped in /usr/local/share/octave/5.2.0/m/image/rgb2gray.m at line 59
59:   I = rgb * xform;
debug> dbstep
stopped in /usr/local/share/octave/5.2.0/m/image/rgb2gray.m at line 61
61:   sz(3) = 1; # grayscale images have 3rd dimension of length 1

Eli Chan <freetogo>
Mon 06 Apr 2020 04:51:00 PM UTC, comment #4: 

stuck at I = rgb * xform;

octave:3> img_gray=rgb2gray(img)
stopped in /usr/local/share/octave/5.2.0/m/image/rgb2gray.m at line 45
45:   if (nargin != 1)
debug> dbstep
stopped in /usr/local/share/octave/5.2.0/m/image/rgb2gray.m at line 49
49:   is_int = isinteger (rgb);
debug> dbstep
stopped in /usr/local/share/octave/5.2.0/m/image/rgb2gray.m at line 50
50:   if (is_int)
debug> dbstep
stopped in /usr/local/share/octave/5.2.0/m/image/rgb2gray.m at line 51
51:     cls = class (rgb);
debug> dbstep
stopped in /usr/local/share/octave/5.2.0/m/image/rgb2gray.m at line 54
54:     = colorspace_conversion_input_check ("rgb2gray", "RGB", rgb);
debug> dbstep
stopped in /usr/local/share/octave/5.2.0/m/image/rgb2gray.m at line 58
58:   xform = [0.298936; 0.587043; 0.114021];
debug> dbstep
stopped in /usr/local/share/octave/5.2.0/m/image/rgb2gray.m at line 59
59:   I = rgb * xform;
debug> dbstep

Eli Chan <freetogo>
Mon 06 Apr 2020 04:45:45 PM UTC, comment #3: 


comment #2:

> Thanks for your report. Is "flower2.bmp" the problematic image (if so can you attach it to this report) or do you observe the same failure whatever the image.
>
> As for debugging the best is to step through the function:
>


> >>im = imread ("image.png");
> >>dbstop rgb2gray
> >>img = rgb2gray (im);
> stopped in /opt/share/octave/5.2.0/m/image/rgb2gray.m at line 45
> 45:   if (nargin != 1)
> debug> dbstep
> ...


>
> Step through the code until you find the bottleneck.
>

>
>

Eli Chan <freetogo>
Mon 06 Apr 2020 03:53:35 PM UTC, comment #2: 

Thanks for your report. Is "flower2.bmp" the problematic image (if so can you attach it to this report) or do you observe the same failure whatever the image.

As for debugging the best is to step through the function:


>>im = imread ("image.png");
>>dbstop rgb2gray
>>img = rgb2gray (im);
stopped in /opt/share/octave/5.2.0/m/image/rgb2gray.m at line 45
45:   if (nargin != 1)
debug> dbstep
...


Step through the code until you find the bottleneck.

 


Pantxo Diribarne <pantxo>
Group Member
Mon 06 Apr 2020 03:51:19 PM UTC, comment #1: 

Is this the Ubuntu with a broken blas?
In any case that does not look like a bug report but rather a support request. Post on octave help list.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Mon 06 Apr 2020 02:01:12 PM UTC, original submission:  


img = imread("flower2.bmp");
img_gray = rgb2gray(img);

this script will run forever with high cpu

I have tried both the ubuntu version and the source version octave-5.2.0.tar.gz. Both have the same problems

However, snap version of octave is OK.

Any pointer on how to debug?

Eli

Eli Chan <freetogo>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #48774:  lena_64.png added by freetogo (5KiB - image/png)
file #48775:  lena_80.png added by freetogo (8KiB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by siko1056 (Updated the item)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by dasergatskov (Posted a comment)
  • -email is unavailable- added by freetogo (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-04-07 siko1056 Severity3 - Normal 2 - Minor
        Priority5 - Normal 3 - Low
        StatusNeed Info Invalid / Not an Octave Bug
        Open/ClosedOpen Closed
    2020-04-06 freetogo Attached File- Added lena_64.png, #48774
        Attached File- Added lena_80.png, #48775
    2020-04-06 pantxo StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-0329.
    Corresponding source code