Platforms equipped with GPU processors help mitigating the ever-increasing computational demands of modern embedded systems. Such systems can be specifically developed by using component-based development thanks to the concept of flexible components. Through this concept, a component can be transparently executed either on a CPU or a GPU. However, this flexibility complicates the allocation process because it adds additional complexity (i.e., due to the undecided CPU or GPU execution) and constraints to consider (i.e., CPUs and GPUs properties). In this work, we address this problem by providing an optimization model for component-based embedded systems executing on both CPU and GPU. The model addresses important optimization goals, characteristic to the embedded system domain, such as memory usage, energy usage and execution time. A novelty of this work is the formal description of the optimization model, which supports the usage of mixed integer nonlinear programming to compute optimal allocation schemes. To examine the feasibility of the proposed method, we apply the optimization model on a vision system constructed using the industrial Rubus component model.