File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
examples/model_inference/multi_thread Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 99
1010pthread_mutex_t mutex ;
1111
12+ /*
13+ * @brief It is an simple inference example that runs multi-threads on a GPU.
14+ * Each thread holds it own local gradient_machine but shares the same
15+ * parameters.
16+ * If you want to run on different GPUs, you need to launch
17+ * multi-processes or set trainer_count > 1.
18+ */
1219void * thread_main (void * gm_ptr ) {
1320 // Initialize the thread environment of Paddle.
1421 CHECK (paddle_init_thread ());
@@ -29,7 +36,7 @@ void* thread_main(void* gm_ptr) {
2936 paddle_real * cpu_input = (paddle_real * )malloc (784 * sizeof (paddle_real ));
3037 paddle_real * cpu_output = (paddle_real * )malloc (10 * sizeof (paddle_real ));
3138 for (int iter = 0 ; iter < NUM_ITER ; ++ iter ) {
32- // There is only one input of this network.
39+ // There is only one input layer of this network.
3340 CHECK (paddle_arguments_resize (in_args , 1 ));
3441 CHECK (paddle_arguments_set_value (in_args , 0 , mat ));
3542
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ PD_API paddle_error paddle_init(int argc, char** argv);
2929/**
3030 * Initialize the thread environment of Paddle.
3131 * @note it is requisite for GPU runs but optional for CPU runs.
32+ * For GPU runs, all threads will run on the same GPU devices.
3233 */
3334PD_API paddle_error paddle_init_thread ();
3435
You can’t perform that action at this time.
0 commit comments