Add hardware compatibility flags for CPU rendering and HIPRT control
- Introduced `--force-cpu-rendering` and `--disable-hiprt` flags to the runner command, allowing users to enforce CPU rendering and disable HIPRT acceleration. - Updated the runner initialization and context structures to accommodate the new flags, enhancing flexibility in rendering configurations. - Modified the rendering logic to respect these flags, improving compatibility and user control over rendering behavior in Blender.
This commit is contained in:
@@ -54,10 +54,15 @@ type Runner struct {
|
||||
hasNVIDIA bool
|
||||
gpuBackendProbed bool
|
||||
gpuDetectionFailed bool
|
||||
|
||||
// forceCPURendering forces CPU rendering for all jobs regardless of metadata/backend detection.
|
||||
forceCPURendering bool
|
||||
// disableHIPRT disables HIPRT acceleration when configuring Cycles HIP devices.
|
||||
disableHIPRT bool
|
||||
}
|
||||
|
||||
// New creates a new runner.
|
||||
func New(managerURL, name, hostname string) *Runner {
|
||||
func New(managerURL, name, hostname string, forceCPURendering, disableHIPRT bool) *Runner {
|
||||
manager := api.NewManagerClient(managerURL)
|
||||
|
||||
r := &Runner{
|
||||
@@ -67,6 +72,9 @@ func New(managerURL, name, hostname string) *Runner {
|
||||
processes: executils.NewProcessTracker(),
|
||||
stopChan: make(chan struct{}),
|
||||
processors: make(map[string]tasks.Processor),
|
||||
|
||||
forceCPURendering: forceCPURendering,
|
||||
disableHIPRT: disableHIPRT,
|
||||
}
|
||||
|
||||
// Generate fingerprint
|
||||
@@ -307,6 +315,8 @@ func (r *Runner) executeJob(job *api.NextJobResponse) (err error) {
|
||||
r.IsGPULockedOut(),
|
||||
r.HasHIP(),
|
||||
r.GPUDetectionFailed(),
|
||||
r.forceCPURendering,
|
||||
r.disableHIPRT,
|
||||
func() { r.SetGPULockedOut(true) },
|
||||
)
|
||||
|
||||
|
||||
@@ -49,6 +49,10 @@ type Context struct {
|
||||
GPUDetectionFailed bool
|
||||
// OnGPUError is called when a GPU error line is seen in render logs; typically sets runner GPU lockout.
|
||||
OnGPUError func()
|
||||
// ForceCPURendering is a runner-level override that forces CPU rendering for all jobs.
|
||||
ForceCPURendering bool
|
||||
// DisableHIPRT is a runner-level override that disables HIPRT acceleration in Blender.
|
||||
DisableHIPRT bool
|
||||
}
|
||||
|
||||
// ErrJobCancelled indicates the manager-side job was cancelled during execution.
|
||||
@@ -73,6 +77,8 @@ func NewContext(
|
||||
gpuLockedOut bool,
|
||||
hasHIP bool,
|
||||
gpuDetectionFailed bool,
|
||||
forceCPURendering bool,
|
||||
disableHIPRT bool,
|
||||
onGPUError func(),
|
||||
) *Context {
|
||||
if frameEnd < frameStart {
|
||||
@@ -97,6 +103,8 @@ func NewContext(
|
||||
GPULockedOut: gpuLockedOut,
|
||||
HasHIP: hasHIP,
|
||||
GPUDetectionFailed: gpuDetectionFailed,
|
||||
ForceCPURendering: forceCPURendering,
|
||||
DisableHIPRT: disableHIPRT,
|
||||
OnGPUError: onGPUError,
|
||||
}
|
||||
}
|
||||
@@ -182,6 +190,9 @@ func (c *Context) ShouldEnableExecution() bool {
|
||||
// (runner GPU lockout, GPU detection failed at startup for any version, metadata force_cpu,
|
||||
// or Blender < 4.x when the runner has HIP).
|
||||
func (c *Context) ShouldForceCPU() bool {
|
||||
if c.ForceCPURendering {
|
||||
return true
|
||||
}
|
||||
if c.GPULockedOut {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ func NewRenderProcessor() *RenderProcessor {
|
||||
|
||||
// gpuErrorSubstrings are log line substrings that indicate a GPU backend error (matched case-insensitively); any match triggers full GPU lockout.
|
||||
var gpuErrorSubstrings = []string{
|
||||
"illegal address in hip", // HIP (AMD) e.g. "Illegal address in HIP" or "Illegal address in hip"
|
||||
"hiperror", // hipError* codes
|
||||
"illegal address in hip", // HIP (AMD) e.g. "Illegal address in HIP" or "Illegal address in hip"
|
||||
"hiperror", // hipError* codes
|
||||
"hip error",
|
||||
"cuda error",
|
||||
"cuerror",
|
||||
@@ -107,7 +107,9 @@ func (p *RenderProcessor) Process(ctx *Context) error {
|
||||
v := ctx.GetBlenderVersion()
|
||||
major := parseBlenderMajor(v)
|
||||
isPre4 := v != "" && major >= 0 && major < 4
|
||||
if ctx.GPUDetectionFailed {
|
||||
if ctx.ForceCPURendering {
|
||||
ctx.Info("Runner compatibility flag is enabled: forcing CPU rendering for this job")
|
||||
} else if ctx.GPUDetectionFailed {
|
||||
ctx.Info("GPU backend detection failed at startup—we could not determine whether this machine has HIP (AMD) or NVIDIA GPUs, so rendering will use CPU to avoid compatibility issues")
|
||||
} else if isPre4 && ctx.HasHIP {
|
||||
ctx.Info("Blender < 4.x has no official HIP support: using CPU rendering only")
|
||||
@@ -193,6 +195,7 @@ func (p *RenderProcessor) createRenderScript(ctx *Context, renderFormat string)
|
||||
settingsMap = make(map[string]interface{})
|
||||
}
|
||||
settingsMap["force_cpu"] = ctx.ShouldForceCPU()
|
||||
settingsMap["disable_hiprt"] = ctx.DisableHIPRT
|
||||
settingsJSON, err := json.Marshal(settingsMap)
|
||||
if err == nil {
|
||||
if err := os.WriteFile(renderSettingsFilePath, settingsJSON, 0644); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user