PBFT algorithm - how do we know how many nodes are faulty? I am reading this article about PBFT and I have trouble understanding how it can be used in practice. If we don't how many nodes are faulty (which I believe is a valid assumption), then how can we calculate the number of rounds during which processes send messages to each other?

The linked article shows an example with n = 7 and m = 2 and in that example two rounds of messaging are executed and then the output values are calculated. But how can we know that m = 2 in the first place? Can the algorithm itself figure it out during execution?
The n and m parameters are chosen by the implementer when they choose to use the algorithm. For example, I may decide to use this algorithm on 50 nodes and choose to be able to tolerate up to 4 faulty nodes. Thus, my n is 50 and my m is 4.

If I need to design a system to tolerate a variety of different n values, I'll have some piece of code somewhere that, given the actual number of nodes being used (the n value), picks the number of faulty nodes I want the algorithm to be able to tolerate (the m value).

In all cases, n must be known. You have to know how many nodes are in your system or you don't have a system. Then m can be chosen by code, subject to the limitations of the algorithm. Then both n and m are known.

For example, you might have some code that reads a configuration file that specifies the identity of the other nodes in the system as well as the number of faulty nodes that the system is going to tolerate. Then people using that code create that configuration file and load it into all of the nodes. Now you have a usable system.