Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions SerialPrograms/Source/ML/Models/ML_ONNXRuntimeHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ Ort::Session create_session(
try{
logger.log("Attempting to create Ort::Session with GPU acceleration...");
Ort::SessionOptions gpu_options = create_session_options(model_cache_path, true);
gpu_options.DisablePerSessionThreads();
Ort::Session session{global_ort_env(), onnx_path.c_str(), gpu_options};
logger.log("Ort::Session created");
// when Ort::Ssssion is created, if possible, it will create a model cache
Expand All @@ -221,6 +222,7 @@ Ort::Session create_session(
logger.log("Creating dedicated CPU-only session...");

Ort::SessionOptions cpu_options = create_session_options(model_cache_path, false);
cpu_options.DisablePerSessionThreads();

Ort::Session session{global_ort_env(), onnx_path.c_str(), cpu_options};
logger.log("Ort::Session created");
Expand Down
14 changes: 13 additions & 1 deletion SerialPrograms/Source/ML/Models/ML_OrtEnv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/

#include "Common/Cpp/Exceptions.h"
#include "Common/Cpp/PrettyPrint.h"
#include "CommonFramework/Logging/Logger.h"
#include "CommonFramework/Options/Environment/PerformanceOptions.h"
#include "ML_OrtEnv.h"

Expand All @@ -14,7 +16,17 @@ namespace PokemonAutomation{

Ort::ThreadingOptions make_ort_threading_options(){
Ort::ThreadingOptions ret;
ret.SetGlobalIntraOpNumThreads((int)PerformanceOptions::instance().NORMAL_THREAD_POOL.MAX_THREADS);
{
int threads = (int)PerformanceOptions::instance().ONNX_OPTIONS.MAX_INTRA_OP_THREADS;
global_logger_tagged().log("Setting ONNX Intra-Op Threads: " + tostr_u_commas(threads));
ret.SetGlobalIntraOpNumThreads(threads);
}
{
int threads = (int)PerformanceOptions::instance().ONNX_OPTIONS.MAX_INTER_OP_THREADS;
global_logger_tagged().log("Setting ONNX Inter-Op Threads: " + tostr_u_commas(threads));
ret.SetGlobalInterOpNumThreads(threads);
}
ret.SetGlobalSpinControl(0);
return ret;
}

Expand Down
Loading