Older Nvidia graphics cards may cause Python on Linux to crash.
To use CPU instead of GPU and also to disable ANSI color in stdout
output on Linux you can use code of this form.
string venvPath = null;
var options = new PythonOptions { SetNoSiteFlag = !string.IsNullOrEmpty(venvPath) };
options.Initialize(PythonEnvironment.Current, null);
using var rt = PythonEnvironment.Current.GetRuntime();
using var scope = rt.CreateScope();
rt.StdOutWriter = Console.Out;
rt.StdErrWriter = Console.Error;
rt.AutoInitializeRuntime(scope, null);
var p = Environment.OSVersion.Platform;
bool isWindows = p == PlatformID.Win32NT || p == PlatformID.Win32S || p == PlatformID.Win32Windows;
scope.Exec("import os\n" +
"os.environ['NO_COLOR'] = '1'\n" +
"from docling.datamodel.accelerator_options import AcceleratorDevice, AcceleratorOptions\n" +
"from docling.datamodel.base_models import InputFormat\n" +
"from docling.datamodel.pipeline_options import ThreadedPdfPipelineOptions\n" +
"from docling.document_converter import PdfFormatOption\n");
var op = new AccessibilityOperationAI();
op.ConversionOptions = "{InputFormat.PDF: PdfFormatOption(pipeline_options=ThreadedPdfPipelineOptions(do_ocr=False, accelerator_options=AcceleratorOptions(device=AcceleratorDevice.CPU)))}";
using var doc = op.Tag(scope, "../Rez/spacex_nasa_dragon.pdf");
doc.Save("accessibility_ai_cpu.pdf");