HACK: Dynamically import the AITrainer when it's needed to avoid crashes when the AVX instruction set isn't available
This commit is contained in:
parent
a1516a67bc
commit
ebbc96ec8c
2 changed files with 14 additions and 2 deletions
|
@ -2,6 +2,10 @@
|
|||
|
||||
import show_help from '../help.mjs';
|
||||
import { decode_payload } from '../ttn-app-server/DecodePayload.mjs';
|
||||
import path from 'path';
|
||||
|
||||
// HACK
|
||||
import awilix from 'awilix';
|
||||
|
||||
export default async function(c) {
|
||||
let { ansi: a, log: l, settings } = c.cradle;
|
||||
|
@ -78,6 +82,16 @@ export default async function(c) {
|
|||
break;
|
||||
|
||||
case "train-ai":
|
||||
// Do ninja dynamic import
|
||||
// This avoid loading TensorFlow when it's not needed, as it causes
|
||||
// a crash if the AVX2 CPU instruction set isn't available for some
|
||||
// reason. Hrm.
|
||||
let AITrainer = (await import(path.join(c.cradle.root_dir, "train-ai/AITrainer.mjs"))).default;
|
||||
|
||||
c.register({
|
||||
AITrainer: awilix.asClass(AITrainer)
|
||||
});
|
||||
|
||||
l.log(`${a.fgreen}${a.hicol}Training AIs${a.reset}`);
|
||||
let ai_trainer = c.cradle.AITrainer;
|
||||
await ai_trainer.train_all();
|
||||
|
|
|
@ -13,7 +13,6 @@ import MessageHandler from '../ttn-app-server/MessageHandler.mjs';
|
|||
|
||||
import DataProcessor from '../process-data/DataProcessor.mjs';
|
||||
|
||||
import AITrainer from '../train-ai/AITrainer.mjs';
|
||||
import DatasetFetcher from '../train-ai/DatasetFetcher.mjs';
|
||||
|
||||
import settings from './settings.mjs';
|
||||
|
@ -37,7 +36,6 @@ export default async function setup() {
|
|||
|
||||
DataProcessor: a.asClass(DataProcessor),
|
||||
|
||||
AITrainer: a.asClass(AITrainer),
|
||||
DatasetFetcher: a.asClass(DatasetFetcher)
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue