Skip to content

[C-API]需要一个GPU的运行示例 #6389

@peterzhang2029

Description

@peterzhang2029

目前CAPI中的demo没有直接给出gpu运行的示例,如果将dense目录下的直接改成:

// Initalize Paddle
  char* argv[] = {"--use_gpu=True"};
  CHECK(paddle_init(1, (char**)argv));

  // Reading config binary file. It is generated by `convert_protobin.sh`
  long size;
  void* buf = read_config(CONFIG_BIN, &size);

  // Create a gradient machine for inference.
  paddle_gradient_machine machine;
  CHECK(paddle_gradient_machine_create_for_inference(&machine, buf, (int)size));
  CHECK(paddle_gradient_machine_randomize_param(machine));

  // Loading parameter. Uncomment the following line and change the directory.
  // CHECK(paddle_gradient_machine_load_parameter_from_disk(machine,
  //                                                "./some_where_to_params"));
  paddle_arguments in_args = paddle_arguments_create_none();

  // There is only one input of this network.
  CHECK(paddle_arguments_resize(in_args, 1));

  // Create input matrix.
  paddle_matrix mat = paddle_matrix_create(/* sample_num */ 1,
                                           /* size */ 784,
                                           /* useGPU */ true);

运行会出问题:

Prob:
*** Aborted at 1512642274 (unix time) try "date -d @1512642274" if you are using GNU date ***
PC: @                0x0 (unknown)
*** SIGSEGV (@0x33048a1a00) received by PID 17009 (TID 0x7f6c5f37b8c0) from PID 76159488; stack trace: ***
    @     0x7f6c5de65470 (unknown)
    @           0x4017ae main
    @     0x7f6c5de51bd5 __libc_start_main
    @           0x401209 (unknown)
    @                0x0 (unknown)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions