PyTorch + PDG + Houdini

   5180   9   3
User Avatar
Member
36 posts
Joined: Dec. 2016
Offline
Hi Everyone!

I'm working on implementing PyTorch inside of Houdini much like this demo:
https://www.sidefx.com/tutorials/machine-learning-data-preparation/ [www.sidefx.com]

It seems that the demo is using PyTorch directly inside of PDG. Has anyone else tried this successfully? PyTorch is only supported on Python 3, so I have to use the Python 3 build of Houdini which so far has been too unstable to work with effectively. Apart from constant crashes, I've run into multiple more specific issues. For one, my PyTorch training script freezes when run in a PDG python script node but runs fine from the Python source editor or python sop node. I figured a work around could be to run the code in a python sop packaged in an hda, and run this through an hda processor, but the Python 3 version of Houdini crashes when trying to create an HDA…

If anyone has had any luck doing this I would love to talk!

Thanks,
Ryan
User Avatar
Member
45 posts
Joined: Nov. 2019
Offline
Hey,

thanks to your help I manage to catch up and also encoutered issues using PDG and the houdini python3 release.

I tested PDG on a super simple setup (see attachment) in houdini python3 and there might be a python error that prevent PDG nodes from working properly even without calling pytorch.

The error is:

can't concat str to bytes

Error running Python callback ‘onSchedule’:
Traceback (most recent call last):
File “C:/PROGRA~1/SIDEEF~1/HOUDIN~1.475/houdini/pdg/types\schedulers\local.py”, line 988, in onSchedule
job_env = self._generateEnvironment(work_item, cpu_slots)
File “C:/PROGRA~1/SIDEEF~1/HOUDIN~1.475/houdini/pdg/types\schedulers\local.py”, line 553, in _generateEnvironment
job_env = temp_dir + os.pathsep + pth
TypeError: can't concat str to bytes

I tested the same setup in houdini python 2.7 and it worked fine, so I guess there is a reason why houdini python3 is not the ready for production.


Also I took at the demo you shared and I do not think they used pytorch inside of a PDG. As the title of the post indicate, they only used houdini for data preparation, aka generating the images to train their neural network. All the pytorch implementation was done outside of houdini.

I too wish to to do machine learning in houdini and will be digging the issue. Please keep me posted if you manage to get pytorch and PDG working.

thanks again.
Edited by Edmond BG - May 24, 2020 23:34:06

Attachments:
cellular.hiplc (207.6 KB)

User Avatar
Member
36 posts
Joined: Dec. 2016
Offline
Yeah the Python 3 version is too unstable to use atm.

I discovered you can actually run Python 3 in the Python 2.7 version of Houdini in PDG:


In the erosion demo they actually do have 2 PDG python script nodes that seem to be running the machine learning algorithm.

Sent you a message if you'd like to speak further!
Edited by canonball900 - May 25, 2020 00:26:59

Attachments:
python_pdg.jpg (39.5 KB)

User Avatar
Member
2 posts
Joined: Feb. 2020
Offline
Hey all,

I'm glad that you're doing this. I'm interested in learning a pipeline for effectively implementing ML inside Houdini, but I'm a beginner with both.

I've been trying to run the Terrain_Gen Demo provided there, however I encounter an error at the third stage of the computation (Importing the extracted files as heightfields). Have you been able to get it to run? The erosion demo runs fine for me tho.



I get a console error at the decompress files node “decompress_downloaded_files void __cdecl OP_Parameters::evalStringInstRawT(const class UT_StringRef &,const int *,class UT_String &,int,double,int,int) const: Invalid parameter instance name pdgnodedep1”



Inside the “terrain_importer” SOP Network, the file input geometry node is referencing something called @pdg_result which I cannot seem to understand where is coming from.



I think all of it might originate in the error given when extracting the files, but when browsing the files in the disk everything seems to be properly extracted.
I would sincerely appreciate if anyone could help me figure out what might be wrong.

Kind regards

Attachments:
1.png (70.6 KB)
unknown.png (8.7 KB)
unksssnown.png (92.1 KB)

User Avatar
Member
45 posts
Joined: Nov. 2019
Offline
Hey Francisco,

Welcome to the pytorch and Tops club.

I can not say for sure where the error comes from, it might be an houdini version issue. Are you using houdini python 3?
However I can explain the meaning of @pdg_result. The Top pipeline creates and update values like the path to the files that are stored in attributes. @pdg_result is one of theme and it is different for every wedge (green dot in Tops node).

We can see in your screenshot that the error occurs when the rop fetch is called and @pdg_result has the value “C:/Users/Francisco/Desktop/ml_examples_data/ml_examples_data-preparation/terrain_gen/usgs_data_process/ISGS_NED_13_n47ww144_GridFloat.zip”

So maybe houdini has some issue reading the file ? Or maybe the issue is that @pdg_result is pointing to a .zip that is then send to HF_visualize ? Have you installed all he hda that comes with the archive ?
User Avatar
Member
2 posts
Joined: Feb. 2020
Offline
Hi, and thank you for the help!
I've since gotten it to work. There are 2 fixes. One is to use version 17.5 of Houdini which is where this was created and seems to run fine for me. The other was to use a different folder other than placing the files on the desktop, as I suspect that the permissions in the windows file system prevented the files from being properly read/written. I also had to replace the file export node to the latest version of that node since that was the origin of the console errors.

May I ask, have you been working with ML applications with Houdini for a while? I'd love to talk more about using Houdini with ML and its applications. I'm currently exploring replicating the terrain_generation example as part of my masters project.
User Avatar
Member
45 posts
Joined: Nov. 2019
Offline
Yes, CanonBall900 and I have been working on getting ML into houdini.

It is pretty straight forward when you know what to do, I will put an example hip file that requires a lot of external library installation like pytorch for those interested and will send you a message if you want to do a one-on-one.

Attachments:
cellular_1.hiplc (258.6 KB)

User Avatar
Member
36 posts
Joined: Dec. 2016
Offline
Hey Francisco, welcome!

Glad you figured that out! I've been working with ML in Houdini for a few weeks now and Edmond and I have been discussing it for the last couple weeks. It's all pretty new. What do you guys think about getting a discord or a slack channel going?
User Avatar
Member
45 posts
Joined: Nov. 2019
Offline
I am down for a discord channel.
User Avatar
Member
36 posts
Joined: Dec. 2016
Offline
Houdini Machine Learning Discord link! Feel free to join! https://discord.gg/2X7RtX7 [discord.gg]
  • Quick Links