How costly is to find millions of large prime numbers for RSA? Consider I need to assign a large distinct prime number to each element in a large set. This must be deterministic so the function always gives me the same prime to the same value. 


What is the most efficient way to do this (if there is any). 
Would this function work if I need to find millions of prime number to assign them to the set elements.


Btw.: With “large prime number”, I mean the one is usually considered for RSA.
Yes, this is doable.  Here is a construction, built out of several basic primitives:


Let $R$ be a randomized  primality generation algorithm; there are many of them.

It uses randomness, so let's make the bits of randomness it uses explicit as input: $R(c)$ is the output it produces, when given a random number generator that outputs the random bits $c$.
Let $G$ be a cryptographically secure pseudorandom generator: something that stretches a short seed (key) to a long pseudorandom output.  You could use AES in CTR mode, or any stream cipher, for this.
Let $H$ be a cryptographic hash function, e.g., SHA256.


Now, to element $x$, you can assign the prime number $R(G(H(x)))$ to $x$.  It's as simple as that.

This is a deterministic algorithm that will assign a prime to each element, and always assign the same prime to each possible element.  Also, if you generate primes from a large enough range, then the primes will almost surely be distinct.  For instance, if you generate 256-bit primes, then by the birthday paradox, it is essentially guaranteed that all the primes will be distinct (the chances that two different elements $x,x'$ is exponentially small, and negligible in practice).