1
$\begingroup$

I've recently asked Going to try to move some of my scipy/numpy calculation to GPU, how to avoid disappointing results? I've taken some time to explain the computational problem, that it runs in numpy and might require calls to scipy.special. One of the things I would like to try to improve its speed is to move part of the calculation to a GPU and have outlined some concerns I have before going out and investing in a GPU.

In it I link to three similar questions asking for help/advice on moving a calculation to GPU

Each of these questions was relatively well received, and has received two answers with good advice.

None of these questions received a request of specific code. In each case the OP was trusted to be asking the question to which they would like an answer.

However under my question there is more than one request for specific code.

Of course there are many ways that one can try to speed up a program and especially a python script. It's important to structure the arrays properly and there are options (e.g. numba) for more efficient compilation.

But this question is not about that. Similarly to the three linked questions, this questions asks for specific pointers for how to avoid being disappointed purchasing a GPU and finding out it does not add performance. They can be expensive.

In a comment I've said:

In this case I feel the script is distracting and will tend to attract well-meaning answers about how to better script it which is not what this question is about.

I feel that the direction the comments have taken has somewhat derailed my question. Of course they are all well-meaning and are reaching out to try to help, but I also feel that unlike the authors of the three linked questions I am not being given sufficient credibility that I know the question to which I would like answers.

Is there something about the way my question is written that might be causing this?

$\endgroup$

1 Answer 1

5
$\begingroup$

Not my comments on the linked post, but I can speculate based on my impression of the differences between your post and the previous ones. I think the big difference was in the scope of the routine you were trying to speed up.

  • In the first question, they are asking for a library for GPU differential equation solvers. This was the broadest problem domain of the three posts, but even still, ODE solvers are fairly well established, to point where it's very common to have "solve this ODE" as just a single line in your code. While its fairly high level, you could think of "solve this ODE" as a single operation.

  • The second question was effectively asking how GPUs would affect the time for matrix multiplication. Even more so than the first example, this would qualify as trying to speed up a single operation.

  • The last question was about using GPUs for computing large factorials, so essentially about splitting up the work of many multiplications. Again, a single operation.

Your question (or at least the background, more on this below) focused on being able to do numpy or special function evaluations, which are fairly general and could potentially refer to a wide variety of different operations that may or may not benefit from GPUs. A lot of users seemed to infer from this that your question was an XY problem: you had decided that you needed GPUs to speed up your program (X), when your real issue may just have been a slow algorithm for some step in the process (Y). While GPUs wouldn't necessarily be the wrong way to go, they thought they might be just papering over the real problem.

But based on this meta post, your comments, and the title of your question, the mathematical problem you are solving is not the core of your question. You are just trying to determine, in general, how to best (as in best practices/principles, rather than the optimal in terms of performance) move over code from a CPU to a GPU implementation to improve performance.

While in general I think background is great to include, I think here the particular computational problem you are solving is distracting from the question you want answered. So I would say to remove the problem specific details and just leave the latter part of your question.

$\endgroup$
6
  • $\begingroup$ Thanks for your help! It's not so much "how to best move over code" as it is "how to avoid disappointing results". In other words, what are some pitfalls I can try to avoid when trying, and especially when selecting a first GPU. A "best" question would be a different animal, and would definitely require more specifics. $\endgroup$
    – uhoh
    Dec 5, 2021 at 2:29
  • 2
    $\begingroup$ @uhoh, I interpret your comment as you want some sort of "Best practices while moving code from CPU to GPU". If that's the case, I agree with Tyberius comment on the problem being a distractor. $\endgroup$
    – nicoguaro Mod
    Dec 6, 2021 at 16:44
  • $\begingroup$ @nicoguaro thanks, yes I think the question does need to be refactored, and I will today. While a "best practices" question would be great, I'm currently ill-prepared to ask it myself. The two helpful comments about "how to avoid disappointing results" (which is my current concern) have been 1) gain some experience using a cloud service, possibly one with a free trial period, and 2) give some thought as to how well your problem can actually be parallelized and take advantage of thousands of cores. Had those been posted in an answer I'd wait a week and then likely accept it. $\endgroup$
    – uhoh
    Dec 6, 2021 at 22:42
  • $\begingroup$ @nicoguaro I'm currently working on a new, specific question with code about the parallelization aspect and will post in a day or two. Also I may simply get a small, relatively inexpensive CUDA GPU and start with CuPy and simply just see what happens. Perhaps disappointing results (at first) are exactly what I need in order to learn how to get better results! $\endgroup$
    – uhoh
    Dec 6, 2021 at 22:43
  • 2
    $\begingroup$ "How to avoid disappointing results" is pretty close to "How to do it right", but you are right that they are not the same. Once you refactor the question we can clean the comments and leave the ones related to the real purpose of it. $\endgroup$
    – nicoguaro Mod
    Dec 6, 2021 at 23:53
  • $\begingroup$ @nicoguaro thanks for the ping/reminder, I've just edited the question. Thanks for your help here/there; if you see room for further refinement please feel free to edit the question. $\endgroup$
    – uhoh
    Dec 8, 2021 at 0:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .