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

Depends on distutils, which has been removed from python3.12 #83

Open
vischia opened this issue Mar 1, 2024 · 12 comments
Open

Depends on distutils, which has been removed from python3.12 #83

vischia opened this issue Mar 1, 2024 · 12 comments

Comments

@vischia
Copy link

vischia commented Mar 1, 2024

Hello,

it seems that distutils has been removed from python, in favour of setuptools.

When running in python3.12, importing torchviz fails (see error message below [1]) because dot.py still explicitly imports distutils: it would be good to fix this dependency, otherwise people will have to drop torchviz from their workflows.

Thank you very much in advance!

Cheers,
Pietro

[1]

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[6], line 8
      6 import numpy as np
      7 import torch
----> 8 from torchviz import make_dot

File venv/lib/python3.12/site-packages/torchviz/__init__.py:1
----> 1 from .dot import make_dot, make_dot_from_trace

File venv/lib/python3.12/site-packages/torchviz/dot.py:2
      1 from collections import namedtuple
----> 2 from distutils.version import LooseVersion
      3 from graphviz import Digraph
      4 import torch

ModuleNotFoundError: No module named 'distutils'
@johndpope
Copy link

doesn't look like @szagoruyko has been activate on twitter / github for years now.
have to fork this repo.

@leo-ware
Copy link

leo-ware commented Apr 2, 2024

working fork https://github.com/leo-ware/pytorchviz

I also made the pull request. May put the working version on pip if it doesn't get merged.

@johndpope
Copy link

that depedencies I believe is looking for pytorch 1. so it's a bit ancient. can comment this code out.
i did start making the charts more beautiful - with google material theme.
You can paste in the svg into chatgpt and just ask it to reformat the styles. would make a massive difference to this library.
#84

the only other thing i see in a lot of papers is the positional embedding - funny circle thing - if svg could somehow spit this out - i think it add something too. pretty much the only reason people are using adobe illustrator for these things.
image

@leo-ware
Copy link

leo-ware commented Apr 5, 2024

@johndpope if the original maintainers don't approve the pull request, would you be interested in publishing a fork? Could create a torchviz2 with the new styling and python 3.12 compatibility.

@johndpope
Copy link

johndpope commented Apr 5, 2024

if there's interest here - would serve community - happy to help - or happy to support a version published by yourself.

When I throw this code / sample into claude.ai opus - it says use pytorch library hiddenlayer instead to get a more undertandable graph.
(meaning the make_dot adds so much complexity)
Screenshot from 2024-04-06 07-14-33
Screenshot from 2024-04-06 07-14-38

my goal in pickingup this libary was to pull apart the attention models to get better intuition.
looking at the EMSA - it's a pretty but perhaps needlessly complicated. maybe we can cherry pick the stuff to turn off the internal pytorch operations to simplify chart...

https://github.com/waleedka/hiddenlayer/blob/master/demos/pytorch_graph.ipynb

@leo-ware
Copy link

I'm emailing the original author. Hopefully, he'll be happy to merge stuff. I'm currently working on another open-source library where I was hoping to add pytorchviz as a dependency, and I'd rather not be vendoring it just to get 3.12 support.

Definitely excited to see how we could extend this package.

@bagustris
Copy link

@leo-ware

Is there any reply yet?

I think there is a big need to continue this torchviz tool and probably move to the orgs repo rather than the individual repo. I see a lot of people, including myself, used it and will continue to use it. Also, some valuable PRs are not merged nor any comment given there.

Also cc @albanD @Varal7

@albanD
Copy link
Contributor

albanD commented Jun 16, 2024

Thanks for the cc, looking into the best way forward here.

@mattcattb
Copy link

Has this been completed?

@johndpope
Copy link

@szagoruyko has been offline for some time - consider this project abandonned...
https://github.com/szagoruyko

@leo-ware
Copy link

Sorry for the slow reply. I had a couple of crazy months. I emailed @szagoruyko, and he didn't respond. Based on his personal website, he appears to be doing a startup right now, so this is understandable.

I need this project for some of my work, so I've done the minimal changes to make this project work with python 3.12. I just used the looseversion drop in replacement for the original distutils utility. I know there was some discussion of dropping support for older versions of pytorch and removing the dependency, but this seemed like the easiest solution, and it will be fully backwards compatible. The new repo is here.

I may try and copy over some of the open pull requests from this library. I'm happy to be a long-term maintainer on this project. If people want to take out pull requests on the new repo, I'll merge them and upload to PyPi.

TLDR
This now works: pip install torchviz2

@albanD
Copy link
Contributor

albanD commented Sep 30, 2024

Hey @leo-ware I didn't get any answer either but I still have access to the original pypi project. So I will cut a release and post it there when I have a minute.

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

6 participants