IntentDev / touchpy

TouchPy is a high-performance toolset to work with TouchDesigner components in Python
https://intentdev.github.io/touchpy
Other
24 stars 0 forks source link

working in conda environment? #6

Open delray opened 2 weeks ago

delray commented 2 weeks ago

Hi, Just trying to get started here and wondering if I can work in a conda env? I installed everything here, and have working versions of pytorch and cuda - but when I try any of the examples, I don't get any of the feedback in the conda terminal? Trying to keep things clean, so I am hoping that would work, but maybe it doesn't. Wondering if there is any other way to troubleshoot this issue? Working with TD 2023.11880, python 3.11 cuda 11.8, torch 2.1.0...

keithlostracco commented 2 weeks ago

Hmm there shouldn't be an issue with installing and using in a Conda environment. I mostly use it in an environment.

Does touchpy import if you run Python? i.e. in the terminal start Python and import touchpy

Are you running Windows? (no Mac support at this moment).

When you run the script you get zero output - not even errors? If that is the case it sounds like the script isn't being run.

delray commented 2 weeks ago

I don't get any errors importing into python either. FWIW this is the output... and I'm running the commercial version of TD.

(base) PS C:\Users\mb> conda activate touchpy
(touchpy) PS C:\Users\mb> D:
(touchpy) PS D:\> cd .\touchpy\examples\basics\
(touchpy) PS D:\touchpy\examples\basics> python .\01_load_comp_basic.py
(touchpy) PS D:\touchpy\examples\basics> python
Python 3.11.9 (tags/v3.11.9:de54cf5, Apr  2 2024, 10:12:12) [MSC v.1938 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import touchpy
>>>
keithlostracco commented 2 weeks ago

That script actually doesn't output anything to the terminal. It loads the component (takes about 10 seconds), runs it for 1200 frames (20 seconds) and terminates. So if the console hangs for about 30 seconds it's working and you will see a texture in syphonspout1 in the ExampleReceive.toe file if you have it open - note it takes about 10 seconds to load the instance before you see syphonspout1 get a texture.

The next script 02_load_comp.py and sets logging level to LogLevel.INFO which will print some status as it loads the comp.

delray commented 2 weeks ago

Sorry I should have been more clear. That was just one session. Previously I tried 01-04 scripts and there is a pause of a second or two but not 10. Nothing shows up in the ExampleRecieve.toe either. I'm going to try on a laptop and see if i have any success there.

keithlostracco commented 2 weeks ago

Hmm yeah it should be throwing errors if there is a problem. What is the GPU?

delray commented 2 weeks ago

4090 running driver 551.23

keithlostracco commented 2 weeks ago

Can you run 02_load_comp.py but modify it so the log level is debug and post the output here?

On Thu, Oct 10, 2024, 14:04 Matthew Biederman @.***> wrote:

4090 running driver 551.23

— Reply to this email directly, view it on GitHub https://github.com/IntentDev/touchpy/issues/6#issuecomment-2406034166, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC6Y4KVZHFOVNC6RLXJNRCTZ23TVDAVCNFSM6AAAAABPXP2DFSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMBWGAZTIMJWGY . You are receiving this because you commented.Message ID: @.***>

delray commented 2 weeks ago

very strange, still nothing. for some reason I guess this in not running the script, but i don't understand why not.

# set the logging level to INFO which will print out verbose information
tp.init_logging(level=tp.LogLevel.DEBUG)

changed like so in the script....

keithlostracco commented 2 weeks ago

Yeah that should be outputing at least a few lines.

Maybe add a print statement or two before and after the comp is created in the script.

delray commented 1 week ago

Sorry, I got pulled away into another project and getting back to this...so I inserted a bunch of print statements as below. import touchpy as tp import modules.utils as utils # utils.py is in the same directory as this script

# set the logging level to INFO which will print out verbose information
tp.init_logging(level=tp.LogLevel.DEBUG)

print('POST_LOG')

# create a class that inherits from tp.Comp
class MyComp (tp.Comp):

    # these are the default arguments for tp.Comp
    # flags: are the flags that control the behavior of the component (can only be set at initialization)
    # fps: is the frames per second that the component will run at (can only be set at initialization)
    # device: is the device (GPU) that the component will run on (0 is defualt, can only be set at initialization)
    # td_path: is the path to the TouchDesigner executable ("" will use the latest installed version)
    def __init__(self, flags=tp.CompFlags.INTERNAL_TIME_AUTO, fps=60, device=0, td_path=""):

        # call the parent class constructor to initialize the component
        super().__init__(flags=flags, fps=fps, device=device, td_path=td_path)

        # create a frame counter
        self.frame = 0

        # set the on_layout_change_callback to the on_layout_change method
        self.set_on_layout_change_callback(self.on_layout_change, {})

        # set the on_frame_callback to the on_frame method
        self.set_on_frame_callback(self.on_frame, {})

    # this gets called at least once after the component is loaded, at this point
    # all the pars, in and out ops are available. If the a par, in or out op is added or removed
    # this method will be called again
    def on_layout_change(self, info):
        print('layout changed:')
        print('in tops:\n', *[f"\t{name}\n" for name in self.in_tops.names])
        print('out tops:\n', *[f"\t{name}\n" for name in self.out_tops.names])
        print('in chops:\n', *[f"\t{name}\n" for name in self.in_chops.names])
        print('out chops:\n', *[f"\t{name}\n" for name in self.out_chops.names])
        print('in dats:\n', *[f"\t{name}\n" for name in self.in_dats.names])
        print('out dats:\n', *[f"\t{name}\n" for name in self.out_dats.names])
        print('pars:\n', *[f"\t{name}\n" for name in self.par.names])

    # define the on_frame method that will be called on every frame
    # the info argument is user data that can be passed to the callback
    # in this case it is an empty dictionary
    def on_frame(self, info):

        # stop running the if the 'q' key is pressed (terminal must be in focus)
        # always stop the component before calling start_next_frame()
        if utils.check_key('q'):
            self.stop()
            return

        # start_next_frame() is called to advance the component to the next frame
        self.start_next_frame()
        self.frame += 1
print('POST_DEF')
# INTERNAL_TIME_AUTO will automatically run the component from this thread
# component will run in a different process but this thread will still block
# when comp.start() is called, after which callbacks are used to do work
flags = tp.CompFlags.INTERNAL_TIME_AUTO
print('POST_FLAG')
# create an instance of the MyCompBasic class with specific flags, device and td_path
# set td_path to the path of a TouchDesigner installation folder on your system
# if the installation is not found, the latest installed version will be used
#td_path = 'C:/Program Files/Derivative/TouchDesigner.2023.11764.22'
td_path = 'C:/Program Files/Derivative/TouchDesigner.2023.11880'

fps = 60 
device = 0 

comp = MyComp(flags, fps, device, td_path)
print('POST_COMP')
# load the tox file into the component
comp.load('D:/touchpy/examples/basics/TopChopDatIO.tox') 
print('POST_LOAD')
# start the component, this will block until self.stop() is called when not running
# the component in async mode
comp.start()
print('POST_START')
# unload the component to cleanly free up resources
comp.unload()

I am only getting the print statements until the loading process (no 'LOAD or COMP' statements) - I tried adding a specific filepath to load the tox + and for my install of TD but it appears it is not loading at all but no errors. Seems very strange. thanks for your help!

keithlostracco commented 1 week ago

okay something is definitely breaking on the TouchPy end. Did you test it with a normal Python installation (no env)?

In either case I'll look into it and try and replicate.

keithlostracco commented 1 week ago

I think I know what it is. It's the logger itself crashing, it depends on fmt which depends on some Windows libraries, which were recently upgraded by Windows on most systems.

I'll push an update in the next day or two.

delray commented 1 week ago

haha, ok thanks...looking forward to trying it out...

keithlostracco commented 4 days ago

Hi @delray looks there is something up with touchpy and Conda specifically. Unfortunately I can't dig into too far still for few more days but, it's definitely specific to Conda and the latest release.

If you do want to try it out before there is a fix it is working fine in a system wide installation of Python....

Sorry for the hassle.

delray commented 3 days ago

Hi Keith,I’m away this week but back on the 29th - I’m always a little hesitant to do all this systemwide since I have a few different things cooking on that machine, but maybe I’ll give it a go when I am back and report back to you. Thanks for the update,MatthewSent by my thumbsOn Oct 20, 2024, at 5:22 PM, keithlostracco @.***> wrote: Hi @delray looks there is something up with touchpy and Conda specifically. Unfortunately I can't dig into too far still for few more days but, it's definitely specific to Conda and the latest release. If you do want to try it out before there is a fix it is working fine in a system wide installation of Python.... Sorry for the hassle.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>