Jump to content

Multi-thread the smooth SOP


kleer001

Recommended Posts

Unless I've missed something the Smooth SOP is not multi-threaded. I working on 1 million+ points on a geo in a 200+ frame range with only one Hbatch licence and it's killing me to see the CPU usage pegged at 3% on my 12 core machine :(

How would you go about parallelizing the Smooth SOP? I don't know what's going on under the hood with that process, but I bet a good old point cloud would be useful in there somewhere. I bet someone's already solved this problem too.

Link to comment
Share on other sites

It's not time dependent, so unless RAM limits you, start 12 x hscripts instances on a single computer and off you go!

Yes, I've relied on this method a lot and in other applications too. If you need to do this frequently it helps to setup a script for it. This is a quickie I wrote for OS X but should work on any platform if you change the path (or change it so the path is automatic).


def multiRop(ropNode, threads):
import os
import hou
hbatchPath = '/Library/Frameworks/Houdini.framework/Versions/12.5.316.22/Resources/bin/hbatch'
firstFrame = ropNode.parm('f1').eval()
lastFrame = ropNode.parm('f2').eval()
scenePath = hou.hipFile.path()
for thread in range(0, threads):
startFrame = firstFrame + thread
os.system('echo "render -V -f %s %s -i %s %s; quit" | %s %s > ~/logForThread_%s.txt &' % (startFrame, lastFrame, threads, ropNode.path(), hbatchPath, scenePath, thread))
def kill():
import os
os.system('killall hbatch')
[/CODE]

  • Like 2
Link to comment
Share on other sites

It's not time dependent, so unless RAM limits you, start 12 x hscripts instances on a single computer and off you go!

Yup, lol, I was just about to edit and say "Except for running a bunch of instancse."

Because I'm doing that right now, so it's a valid work around of course, but it seems so inefficent.

Link to comment
Share on other sites

Oh, I spoke too soon. Looks like I can't Python hard enough as the sensible looking path:

hbatchPath = 'C:\apps64\Side Effects Software\Houdini 12.5.376\bin\hbatch.exe'

gets me no love... only the "path could not be found" error. Even though it's the darn path to the program. I tried swappin out the "/" for "\", but same result.

I guess it's opening new GUI instances for me. Still, 10 minutes is better than 50.

Edited by kleer001
Link to comment
Share on other sites

Oh, I spoke too soon. Looks like I can't Python hard enough as the sensible looking path:

hbatchPath = 'C:\apps64\Side Effects Software\Houdini 12.5.376\bin\hbatch.exe'

gets me no love... only the "path could not be found" error. Even though it's the darn path to the program. I tried swappin out the "/" for "\", but same result.

I guess it's opening new GUI instances for me. Still, 10 minutes is better than 50.

Python on Windows is a little funky, since Python treats the backslash as an escape character you have to double them up. Something like this.


'C:\\Program Files\\whatever\\something.exe'
[/CODE]

When I get some downtime at work I'll update that to automatically find the current Houdini path which is probably what I should have done in the first place.

Link to comment
Share on other sites

When I get some downtime at work I'll update that to automatically find the current Houdini path which is probably what I should have done in the first place.

Maybe this works on Windows as well:


import os
os.path.join(os.getenv('HFS'), 'bin', 'hbatch')
[/CODE]

Link to comment
Share on other sites

If you don't need a sophisticated smoothing algorithm you can also try a very simple smoother. Simply calculate the barycenter of all adjacent vertices and set it to the current vertex position. This is not multithreaded but it's a little faster then the default houdini smoother.

simpleSmoothing.hip

  • Like 2
Link to comment
Share on other sites

What a treat! Oh ho ho! Thank you gentlemen, I really appreciate it! I'll try 'em all out.

happyhatdance.gif

(I never quite appreciated how much I was relying on the technical support of other houdini artists at bigger studios. Being a lone wolf is hairy to say the least, but it's good.)

Edited by kleer001
Link to comment
Share on other sites

  • 4 weeks later...

Sad news is none of those path string massaging techniques work. I've tried "\\", "/", and the good looking os.path.join technique which gives me 'C:/apps64/SIDEEF~1/HOUDIN~1.376\\bin\\hbatch'

Nothing works.

Maybe it's some permissions error. I have no idea. This is super frustrating.

Edited by kleer001
Link to comment
Share on other sites

Guest mantragora

Try :

hbatch = os.path.normpath(os.path.join(os.getenv('HFS'), 'bin', 'hbatch.exe'))

It should fix your mixed slashes.

Don't forget to write full file name with extension. Without it, if you test returned path with

os.path.isfile(hbatch)

it will return False

Edited by mantragora
Link to comment
Share on other sites

Still on Windows 7, still crying myself to sleep. I finally got hbatch to run and I'm still banging away at this (thanks lukeiamyourfather for the code), but it's still resisting my best efforts to get work done:

def multiRop(ropNode, threads):
import os
import hou
hbatchPath = os.path.normpath(os.path.join(os.getenv('HFS'), 'bin', 'hbatch.exe'))
hbatchPath = "\""+hbatchPath+"\""
firstFrame = ropNode.parm('f1').eval()
lastFrame = ropNode.parm('f2').eval()
scenePath = hou.hipFile.path()
scenePath = "\""+scenePath+"\""
for thread in range(0, threads):
startFrame = firstFrame + thread
os.system('echo "help; render -V -f %s %s -i %s %s ; quit" | %s %s >C:\\temp\\logForThread_%s.txt && pause' % (startFrame, lastFrame, threads, ropNode.path(), hbatchPath, scenePath, thread))[/CODE]

Seems to load up the scene when I input my hip file and valid ROP, but the launched hbatch doesn't seem to recognize the 'render' command. It does however recognize the 'help' command and I get the expected regular output in my log file... However if I put up the encased command above I get "Unknown command: help; render...." What the what what?!

And even if this works something tells me it's not going to launch multiple simultaneous instances of hbatch (which is the whole point of the exercise). Right?

Link to comment
Share on other sites

  • 2 months later...

Goshdarnit! Nothing I try works. It's really bizarre because the help command works, but hbatch won't accept any commands in a single line launched at once. It only renders if I launch it manually and then wait for the console to come up.

I'm still resorting to launching a bunch of Houdini interactive sessions and manually setting their start frames.

Link to comment
Share on other sites

Hi. I found this problem interesting and tryed to solve it on my own. I came up with kind of solution but it is not very clean. But it works and may give you a hint. Anyway I hope it will help

For the attached file to work, your windows "path" environment must be set to ""C:\Program Files\Side Effects Software\Houdini 12.5.(HOUDINI BUILD NUMBER!!!)\bin" (it is needed to run hython without directly defining path in script)

Also "start.py" file from attached archive must be moved to the root of C drive.

main script is in the python source editor tab in the hip file. You can launch it from python shell by calling: hou.session.threadedRun(ropNode, number of threads)

The code is very rough, please ignore this)

forOdForce.rar

Edited by Artem Smirnov
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...