Skip to content

Commit

Permalink
ci: Fix GPU usage
Browse files Browse the repository at this point in the history
  • Loading branch information
marcojob committed Nov 13, 2024
1 parent cb1fe4d commit de7dc11
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ jobs:
runs-on: self-hosted
container:
image: omavteam/v4l2_camera:latest
options: |
--gpus all
strategy:
matrix:
Expand All @@ -31,4 +33,6 @@ jobs:
- name: Run ${{ matrix.ci_script }}
run: |
export ONNX_VERBOSE=1
export TRT_LOGGER=VERBOSE
bash -x ./ci/${{ matrix.ci_script }}.sh
18 changes: 11 additions & 7 deletions src/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,21 @@ void LearningInterface::_build(std::string onnx_path) {
// TODO: What about different hardware?
config->setMemoryPoolLimit(nvinfer1::MemoryPoolType::kWORKSPACE, JETSON_MEM_LIMIT_B);
nvonnxparser::IParser* parser = nvonnxparser::createParser(*network, _logger);
bool parsed = parser->parseFromFile(onnx_path.c_str(), static_cast<int>(nvinfer1::ILogger::Severity::kINFO));
IHostMemory* plan{ builder->buildSerializedNetwork(*network, *config) };

_runtime = createInferRuntime(_logger);
_engine = _runtime->deserializeCudaEngine(plan->data(), plan->size());
_context = _engine->createExecutionContext();
const bool parsed = parser->parseFromFile(onnx_path.c_str(), static_cast<int>(nvinfer1::ILogger::Severity::kVERBOSE));
if (parsed) {
IHostMemory* plan = builder->buildSerializedNetwork(*network, *config);

_runtime = createInferRuntime(_logger);
_engine = _runtime->deserializeCudaEngine(plan->data(), plan->size());
_context = _engine->createExecutionContext();
delete plan;
} else {
std::cerr << "Could not parse onnx file: " << onnx_path.c_str() << std::endl;
}

delete network;
delete config;
delete parser;
delete plan;
}

bool LearningInterface::_save_engine(const std::string& engine_path) {
Expand Down
15 changes: 15 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import onnx

model_path = "test/resources/depth_anything_v2_vits.onnx"
onnx_model = onnx.load(model_path)

# Print all model outputs
print("Model outputs:")
for output in onnx_model.graph.output:
print(output.name)

# Print all model inputs
print("Model inputs:")
for input in onnx_model.graph.input:
print(input.name)

0 comments on commit de7dc11

Please sign in to comment.