Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to create simple model on cpu #5

Open
magicaltoast opened this issue Nov 16, 2021 · 0 comments
Open

Failed to create simple model on cpu #5

magicaltoast opened this issue Nov 16, 2021 · 0 comments

Comments

@magicaltoast
Copy link

I'm trying to do inference with model generated with Keras and saved to onnx format. But I'm getting an error while creating the model. Code was based on provided example

Error

go run -tags='nogpu' main.go 
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xcd36ff]

goroutine 1 [running]:
main.main()
        /home/idk/golang_onnx/main.go:27 +0x1ff
exit status 2
(base) idk@idk:~

Code

package main

import (
	"context"
	"fmt"
	"path/filepath"

	"github.com/c3sr/dlframework/framework/options"
	"github.com/c3sr/go-onnxruntime"
	"github.com/c3sr/tracer"
)

func main() {
	device := options.CPU_DEVICE
	graph := filepath.Join("/home/idk/golang_onnx", "model.onnx")

	ctx := context.Background()
	opts := options.New(options.Context(ctx),
		options.Graph([]byte(graph)),
		options.Device(device, 0),
		options.BatchSize(9))

	opts.SetTraceLevel(tracer.FULL_TRACE)

	span, ctx := tracer.StartSpanFromContext(ctx, tracer.FULL_TRACE, "onnxruntime_batch")
	defer span.Finish()

	predictor, err := onnxruntime.New(
		ctx,
		options.WithOptions(opts),
	)
	defer predictor.Close()
	fmt.Println(err)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant