Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to run on Mac m1 #32

Open
Pawandeep-prog opened this issue Jun 25, 2023 · 11 comments
Open

Trying to run on Mac m1 #32

Pawandeep-prog opened this issue Jun 25, 2023 · 11 comments

Comments

@Pawandeep-prog
Copy link

My Mac configs:
os: Mac OS 13.4 (22F66)
cpu: Mac m1
ram: 8GB

after running through
sh scripts/gui.sh

I am getting segment fault:
scripts/gui.sh: line 2: 77912 Segmentation fault: 11 python visualizer_drag.py checkpoints/stylegan2_lions_512_pytorch.pkl

need any more information would be happy to share.

@Pawandeep-prog
Copy link
Author

after further tracking the code,

found that the fault is due to this line

self.set_window_size(window_width, window_height)

from gui_utils/glfw_window.py in the init() function.

@Pawandeep-prog
Copy link
Author

okay resolved segmentation fault

it was due to
self.monitor_height and self.monitor_width variables
in the same file def set_window_size(self, width, height): this function

I removed them and hard coded 1920 and 1080 instead.

@Pawandeep-prog
Copy link
Author

Getting this error

Traceback (most recent call last):
  File "/Users/pawandeepsingh/Documents/Development/official_draggan/DragGAN/visualizer_drag.py", line 404, in <module>
    main()
  File "/Users/pawandeepsingh/miniforge3/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/pawandeepsingh/miniforge3/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/pawandeepsingh/miniforge3/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/pawandeepsingh/miniforge3/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/pawandeepsingh/Documents/Development/official_draggan/DragGAN/visualizer_drag.py", line 363, in main
    viz = Visualizer(capture_dir=capture_dir)
  File "/Users/pawandeepsingh/Documents/Development/official_draggan/DragGAN/visualizer_drag.py", line 31, in __init__
    super().__init__(title='DragGAN', window_width=3840, window_height=2160)
  File "/Users/pawandeepsingh/Documents/Development/official_draggan/DragGAN/gui_utils/imgui_window.py", line 43, in __init__
    self._imgui_renderer = _GlfwRenderer(self._glfw_window)
  File "/Users/pawandeepsingh/Documents/Development/official_draggan/DragGAN/gui_utils/imgui_window.py", line 102, in __init__
    super().__init__(*args, **kwargs)
  File "/Users/pawandeepsingh/miniforge3/lib/python3.9/site-packages/imgui/integrations/glfw.py", line 12, in __init__
    super(GlfwRenderer, self).__init__()
  File "/Users/pawandeepsingh/miniforge3/lib/python3.9/site-packages/imgui/integrations/opengl.py", line 60, in __init__
    super(ProgrammablePipelineRenderer, self).__init__()
  File "/Users/pawandeepsingh/miniforge3/lib/python3.9/site-packages/imgui/integrations/base.py", line 17, in __init__
    self._create_device_objects()
  File "/Users/pawandeepsingh/miniforge3/lib/python3.9/site-packages/imgui/integrations/opengl.py", line 108, in _create_device_objects
    self._attrib_location_tex = gl.glGetUniformLocation(self._shader_handle, "Texture")
  File "/Users/pawandeepsingh/miniforge3/lib/python3.9/site-packages/OpenGL/latebind.py", line 63, in __call__
    return self.wrapperFunction( self.baseFunction, *args, **named )
  File "/Users/pawandeepsingh/miniforge3/lib/python3.9/site-packages/OpenGL/GL/VERSION/GL_2_0.py", line 430, in glGetUniformLocation
    return baseOperation( program, name )
  File "/Users/pawandeepsingh/miniforge3/lib/python3.9/site-packages/OpenGL/platform/baseplatform.py", line 415, in __call__
    return self( *args, **named )
  File "/Users/pawandeepsingh/miniforge3/lib/python3.9/site-packages/OpenGL/error.py", line 230, in glCheckError
    raise self._errorClass(
OpenGL.error.GLError: GLError(
	err = 1282,
	description = b'invalid operation',
	baseOperation = glGetUniformLocation,
	cArguments = (1, b'Texture\x00'),
	result = -1
)

any help would be appreciated :)

@albusdemens
Copy link

@Pawandeep-prog I fixed the issue by following this suggestion.

@Pawandeep-prog
Copy link
Author

I think it require cuda to run as I see in stylegan3 repo, and I am running Mac m1 maybe that is the issue. :(

@iWooda
Copy link

iWooda commented Jun 25, 2023

MacOS
M1

scripts/gui.sh: line 1: python: command not found
Line 1 😭 ,How to resolve it?Help me pls

@aBner6667
Copy link

aBner6667 commented Jun 26, 2023

I can open the generated web address, and the interactive content is displayed correctly. However, once I click to manipulate the image, it shows an error: ”Expecting value: line 1 column 1 (char 0)“,
I am a computer newbie, please help me.

MacOS M1

@alex-calderwood
Copy link

@albusdemens when you say fixed, do you mean the project was running?

@oscarmore2
Copy link

I track my issue, I found the problem is caused by : _, _, _width, height = glfw.get_monitor_workarea(glfw.get_primary_monitor()), in glfw_window.py, line 82.
My macbook pro is MacOS Monterey 2021, M1 pro chip.
It return a null pointer while it tried to query the monitor size, but fail
It seems like the glfw library didn't have good support in arm chip. Maybe using Metal could resolve it?

@Pawandeep-prog
Copy link
Author

I also had problem over there, didn't found any solution so I hard coded these values. :(

@siyun-liang
Copy link

I try:

        glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
        glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 3)
        glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, glfw.TRUE)
        glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)

I want to set the openGL context to 3.3, while:
version = gl.glGetString(gl.GL_VERSION)
print("OpenGL Version:", version)
prints OpenGL Version: b'4.1 Metal - 83.1'. (without the change it prints 2.1 Metal)

With this change:
self._imgui_renderer = _GlfwRenderer(self._glfw_window)
in line 40, imgui_window.py throws no exception.

But further exception was thrown: gui_utils/glfw_window.py", line 193, in begin_frame

OpenGL.error.GLError: GLError(
	err = 1282,
	description = b'invalid operation',
	baseOperation = glMatrixMode,
	cArguments = (GL_PROJECTION,)
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants